Skip to content

Commit 3b2d34d

Browse files
committed
revamp rds
1 parent cdd84f4 commit 3b2d34d

File tree

1 file changed

+46
-49
lines changed
  • src/content/docs/aws/services

1 file changed

+46
-49
lines changed

src/content/docs/aws/services/rds.md

Lines changed: 46 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: "Relational Database Service (RDS)"
3-
linkTitle: "Relational Database Service (RDS)"
43
description: Get started with Relational Database Service (RDS) on LocalStack
54
tags: ["Base"]
65
persistence: supported with limitations
@@ -13,15 +12,15 @@ RDS allows you to deploy and manage various relational database engines like MyS
1312
RDS handles routine database tasks such as provisioning, patching, backup, recovery, and scaling.
1413

1514
LocalStack allows you to use the RDS APIs in your local environment to create and manage RDS clusters and instances for testing & integration purposes.
16-
The supported APIs are available on our [API coverage page]({{< ref "coverage_rds" >}}), which provides information on the extent of RDS's integration with LocalStack.
15+
The supported APIs are available on our [API coverage page](), which provides information on the extent of RDS's integration with LocalStack.
1716

18-
{{< callout >}}
17+
:::note
1918
We’ve introduced a new native RDS provider in LocalStack and made it the default.
2019
This replaces Moto-based CRUD operations with a more reliable setup.
2120

2221
RDS state created in version 4.3 or earlier using Cloud Pods or standard persistence will not be compatible with the new provider introduced in version 4.4.
2322
Recreating the RDS state is recommended for compatibility.
24-
{{< /callout >}}
23+
:::
2524

2625
## Getting started
2726

@@ -42,14 +41,14 @@ To create an RDS cluster, you can use the [`CreateDBCluster`](https://docs.aws.a
4241
The following command creates a new cluster with the name `db1` and the engine `aurora-postgresql`.
4342
Instances for the cluster must be added manually.
4443

45-
{{< command >}}
46-
$ awslocal rds create-db-cluster \
44+
```bash
45+
awslocal rds create-db-cluster \
4746
--db-cluster-identifier db1 \
4847
--engine aurora-postgresql \
4948
--database-name test \
5049
--master-username myuser \
5150
--master-user-password mypassword
52-
{{< / command >}}
51+
```
5352

5453
You should see the following output:
5554

@@ -67,22 +66,22 @@ You should see the following output:
6766

6867
To add an instance you can run the following command:
6968

70-
{{< command >}}
71-
$ awslocal rds create-db-instance \
69+
```bash
70+
awslocal rds create-db-instance \
7271
--db-instance-identifier db1-instance \
7372
--db-cluster-identifier db1 \
7473
--engine aurora-postgresql \
7574
--db-instance-class db.t3.large
76-
{{< / command >}}
75+
```
7776

7877
### Create a SecretsManager secret
7978

8079
To create a `SecretsManager` secret, you can use the [`CreateSecret`](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateSecret.html) API.
8180
Before creating the secret, you need to create a JSON file containing the credentials for the database.
8281
The following command creates a file called `mycreds.json` with the credentials for the database.
8382

84-
{{< command >}}
85-
$ cat << 'EOF' > mycreds.json
83+
```bash
84+
cat << 'EOF' > mycreds.json
8685
{
8786
"engine": "aurora-postgresql",
8887
"username": "myuser",
@@ -92,15 +91,15 @@ $ cat << 'EOF' > mycreds.json
9291
"port": "4510"
9392
}
9493
EOF
95-
{{< / command >}}
94+
```
9695

9796
Run the following command to create the secret:
9897

99-
{{< command >}}
100-
$ awslocal secretsmanager create-secret \
98+
```bash
99+
awslocal secretsmanager create-secret \
101100
--name dbpass \
102101
--secret-string file://mycreds.json
103-
{{< / command >}}
102+
```
104103

105104
You should see the following output:
106105

@@ -121,13 +120,13 @@ Make sure to replace the `secret-arn` with the ARN from the secret you just crea
121120
The following command executes a query against the database.
122121
The query returns the value `123`.
123122

124-
{{< command >}}
125-
$ awslocal rds-data execute-statement \
123+
```bash
124+
awslocal rds-data execute-statement \
126125
--database test \
127126
--resource-arn arn:aws:rds:us-east-1:000000000000:cluster:db1 \
128127
--secret-arn arn:aws:secretsmanager:us-east-1:000000000000:secret:dbpass-cfnAX \
129128
--include-result-metadata --sql 'SELECT 123'
130-
{{< / command >}}
129+
```
131130

132131
You should see the following output:
133132

@@ -165,9 +164,9 @@ You should see the following output:
165164
Alternative clients, such as `psql`, can also be employed to interact with the database.
166165
You can retrieve the hostname and port of your created instance either from the preceding output or by using the [`DescribeDbInstances`](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeDBInstances.html) API.
167166

168-
{{< command >}}
169-
$ psql -d test -U test -p 4513 -h localhost -W
170-
{{< / command >}}
167+
```bash
168+
psql -d test -U test -p 4513 -h localhost -W
169+
```
171170

172171
## Supported DB engines
173172

@@ -185,10 +184,10 @@ It's important to note that the selection of minor versions is not available.
185184
The latest major version will be installed within the Docker environment.
186185
If you wish to prevent the installation of customized versions, adjusting the `RDS_PG_CUSTOM_VERSIONS` environment variable to `0` will enforce the use of the default PostgreSQL version 17.
187186

188-
{{< callout >}}
187+
:::note
189188
While the [`DescribeDbCluster`](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeDBClusters.html) and [`DescribeDbInstances`](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeDBInstances.html) APIs will still reflect the initially defined `engine-version`, the actual installed PostgreSQL engine might differ.
190189
This can have implications, particularly when employing a Terraform configuration, where unexpected changes should be avoided.
191-
{{< /callout >}}
190+
:::
192191

193192
Instances and clusters with the PostgreSQL engine have the capability to both create and restore snapshots.
194193

@@ -205,10 +204,10 @@ A MySQL community server will be launched in a new Docker container upon request
205204
The `engine-version` will serve as the tag for the Docker image, allowing you to freely select the desired MySQL version from those available on the [official MySQL Docker Hub](https://hub.docker.com/_/mysql).
206205
If you have a specific image in mind, you can also use the environment variable `MYSQL_IMAGE=<my-image:tag>`.
207206

208-
{{< callout >}}
207+
:::note
209208
The `arm64` MySQL images are limited to newer versions.
210209
For more information about availability, check the [MySQL Docker Hub repository](https://hub.docker.com/_/mysql).
211-
{{< /callout >}}
210+
:::
212211

213212
It's essential to understand that the `MasterUserPassword` you define for the database cluster/instance will be used as the `MYSQL_ROOT_PASSWORD` environment variable for the `root` user within the MySQL container.
214213
The user specified in `MasterUserName` will use the same password and will have complete access to the database.
@@ -255,50 +254,50 @@ In this example, you will be able to verify the IAM authentication process for R
255254
The following command creates a new database instance with the name `mydb` and the engine `postgres`.
256255
The database will be created with a single instance, which will be used as the master instance.
257256

258-
{{< command >}}
259-
$ MASTER_USER=hello
260-
$ MASTER_PW='MyPassw0rd!'
261-
$ DB_NAME=test
262-
$ awslocal rds create-db-instance \
257+
```bash
258+
MASTER_USER=hello
259+
MASTER_PW='MyPassw0rd!'
260+
DB_NAME=test
261+
awslocal rds create-db-instance \
263262
--master-username $MASTER_USER \
264263
--master-user-password $MASTER_PW \
265264
--db-instance-identifier mydb \
266265
--engine postgres \
267266
--db-name $DB_NAME \
268267
--enable-iam-database-authentication \
269268
--db-instance-class db.t3.small
270-
{{< / command >}}
269+
```
271270

272271
### Connect to the database
273272

274273
You can retrieve the hostname and port of your created instance either from the preceding output or by using the [`DescribeDbInstances`](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_DescribeDBInstances.html) API.
275274
Run the following command to retrieve the host and port of the instance:
276275

277-
{{< command >}}
278-
$ PORT=$(awslocal rds describe-db-instances --db-instance-identifier mydb | jq -r ".DBInstances[0].Endpoint.Port")
279-
$ HOST=$(awslocal rds describe-db-instances --db-instance-identifier mydb | jq -r ".DBInstances[0].Endpoint.Address")
280-
{{< / command >}}
276+
```bash
277+
PORT=$(awslocal rds describe-db-instances --db-instance-identifier mydb | jq -r ".DBInstances[0].Endpoint.Port")
278+
HOST=$(awslocal rds describe-db-instances --db-instance-identifier mydb | jq -r ".DBInstances[0].Endpoint.Address")
279+
```
281280

282281
Next, you can connect to the database using the master username and password:
283282

284-
{{< command >}}
285-
$ PGPASSWORD=$MASTER_PW psql -d $DB_NAME -U $MASTER_USER -p $PORT -h $HOST -w -c 'CREATE USER myiam WITH LOGIN'
286-
$ PGPASSWORD=$MASTER_PW psql -d $DB_NAME -U $MASTER_USER -p $PORT -h $HOST -w -c 'GRANT rds_iam TO myiam'
287-
{{< / command >}}
283+
```bash
284+
PGPASSWORD=$MASTER_PW psql -d $DB_NAME -U $MASTER_USER -p $PORT -h $HOST -w -c 'CREATE USER myiam WITH LOGIN'
285+
PGPASSWORD=$MASTER_PW psql -d $DB_NAME -U $MASTER_USER -p $PORT -h $HOST -w -c 'GRANT rds_iam TO myiam'
286+
```
288287

289288
### Create a token
290289

291290
You can create a token for the user you generated using the [`generate-db-auth-token`](https://docs.aws.amazon.com/cli/latest/reference/rds/generate-db-auth-token.html) command:
292291

293-
{{< command >}}
294-
$ TOKEN=$(awslocal rds generate-db-auth-token --username myiam --hostname $HOST --port $PORT)
295-
{{< / command >}}
292+
```bash
293+
TOKEN=$(awslocal rds generate-db-auth-token --username myiam --hostname $HOST --port $PORT)
294+
```
296295

297296
You can now connect to the database utilizing the user you generated and the token obtained in the previous step as the password:
298297

299-
{{< command >}}
300-
$ PGPASSWORD=$TOKEN psql -d $DB_NAME -U myiam -w -p $PORT -h $HOST
301-
{{< / command >}}
298+
```bash
299+
PGPASSWORD=$TOKEN psql -d $DB_NAME -U myiam -w -p $PORT -h $HOST
300+
```
302301

303302
## Global Database Support
304303

@@ -369,9 +368,7 @@ In addition to the `aws_*` extensions described in the sections above, LocalStac
369368
The LocalStack Web Application provides a Resource Browser for managing RDS instances and clusters.
370369
You can access the Resource Browser by opening the LocalStack Web Application in your browser, navigating to the **Resources** section, and then clicking on **RDS** under the **Database** section.
371370

372-
<img src="rds-resource-browser.png" alt="RDS Resource Browser" title="RDS Resource Browser" width="900" />
373-
<br>
374-
<br>
371+
![RDS Resource Browser](/images/aws/rds-resource-browser.png)
375372

376373
The Resource Browser allows you to perform the following actions:
377374

0 commit comments

Comments
 (0)