You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/aws/services/rds.md
+46-49Lines changed: 46 additions & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,5 @@
1
1
---
2
2
title: "Relational Database Service (RDS)"
3
-
linkTitle: "Relational Database Service (RDS)"
4
3
description: Get started with Relational Database Service (RDS) on LocalStack
5
4
tags: ["Base"]
6
5
persistence: supported with limitations
@@ -13,15 +12,15 @@ RDS allows you to deploy and manage various relational database engines like MyS
13
12
RDS handles routine database tasks such as provisioning, patching, backup, recovery, and scaling.
14
13
15
14
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.
17
16
18
-
{{< callout >}}
17
+
:::note
19
18
We’ve introduced a new native RDS provider in LocalStack and made it the default.
20
19
This replaces Moto-based CRUD operations with a more reliable setup.
21
20
22
21
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.
23
22
Recreating the RDS state is recommended for compatibility.
24
-
{{< /callout >}}
23
+
:::
25
24
26
25
## Getting started
27
26
@@ -42,14 +41,14 @@ To create an RDS cluster, you can use the [`CreateDBCluster`](https://docs.aws.a
42
41
The following command creates a new cluster with the name `db1` and the engine `aurora-postgresql`.
43
42
Instances for the cluster must be added manually.
44
43
45
-
{{< command >}}
46
-
$ awslocal rds create-db-cluster \
44
+
```bash
45
+
awslocal rds create-db-cluster \
47
46
--db-cluster-identifier db1 \
48
47
--engine aurora-postgresql \
49
48
--database-name test \
50
49
--master-username myuser \
51
50
--master-user-password mypassword
52
-
{{< / command >}}
51
+
```
53
52
54
53
You should see the following output:
55
54
@@ -67,22 +66,22 @@ You should see the following output:
67
66
68
67
To add an instance you can run the following command:
69
68
70
-
{{< command >}}
71
-
$ awslocal rds create-db-instance \
69
+
```bash
70
+
awslocal rds create-db-instance \
72
71
--db-instance-identifier db1-instance \
73
72
--db-cluster-identifier db1 \
74
73
--engine aurora-postgresql \
75
74
--db-instance-class db.t3.large
76
-
{{< / command >}}
75
+
```
77
76
78
77
### Create a SecretsManager secret
79
78
80
79
To create a `SecretsManager` secret, you can use the [`CreateSecret`](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateSecret.html) API.
81
80
Before creating the secret, you need to create a JSON file containing the credentials for the database.
82
81
The following command creates a file called `mycreds.json` with the credentials for the database.
83
82
84
-
{{< command >}}
85
-
$ cat << 'EOF' > mycreds.json
83
+
```bash
84
+
cat << 'EOF' > mycreds.json
86
85
{
87
86
"engine": "aurora-postgresql",
88
87
"username": "myuser",
@@ -92,15 +91,15 @@ $ cat << 'EOF' > mycreds.json
92
91
"port": "4510"
93
92
}
94
93
EOF
95
-
{{< / command >}}
94
+
```
96
95
97
96
Run the following command to create the secret:
98
97
99
-
{{< command >}}
100
-
$ awslocal secretsmanager create-secret \
98
+
```bash
99
+
awslocal secretsmanager create-secret \
101
100
--name dbpass \
102
101
--secret-string file://mycreds.json
103
-
{{< / command >}}
102
+
```
104
103
105
104
You should see the following output:
106
105
@@ -121,13 +120,13 @@ Make sure to replace the `secret-arn` with the ARN from the secret you just crea
121
120
The following command executes a query against the database.
@@ -165,9 +164,9 @@ You should see the following output:
165
164
Alternative clients, such as `psql`, can also be employed to interact with the database.
166
165
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.
167
166
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
+
```
171
170
172
171
## Supported DB engines
173
172
@@ -185,10 +184,10 @@ It's important to note that the selection of minor versions is not available.
185
184
The latest major version will be installed within the Docker environment.
186
185
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.
187
186
188
-
{{< callout >}}
187
+
:::note
189
188
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.
190
189
This can have implications, particularly when employing a Terraform configuration, where unexpected changes should be avoided.
191
-
{{< /callout >}}
190
+
:::
192
191
193
192
Instances and clusters with the PostgreSQL engine have the capability to both create and restore snapshots.
194
193
@@ -205,10 +204,10 @@ A MySQL community server will be launched in a new Docker container upon request
205
204
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).
206
205
If you have a specific image in mind, you can also use the environment variable `MYSQL_IMAGE=<my-image:tag>`.
207
206
208
-
{{< callout >}}
207
+
:::note
209
208
The `arm64` MySQL images are limited to newer versions.
210
209
For more information about availability, check the [MySQL Docker Hub repository](https://hub.docker.com/_/mysql).
211
-
{{< /callout >}}
210
+
:::
212
211
213
212
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.
214
213
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
255
254
The following command creates a new database instance with the name `mydb` and the engine `postgres`.
256
255
The database will be created with a single instance, which will be used as the master instance.
257
256
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 \
263
262
--master-username $MASTER_USER \
264
263
--master-user-password $MASTER_PW \
265
264
--db-instance-identifier mydb \
266
265
--engine postgres \
267
266
--db-name $DB_NAME \
268
267
--enable-iam-database-authentication \
269
268
--db-instance-class db.t3.small
270
-
{{< / command >}}
269
+
```
271
270
272
271
### Connect to the database
273
272
274
273
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.
275
274
Run the following command to retrieve the host and port of the instance:
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:
@@ -369,9 +368,7 @@ In addition to the `aws_*` extensions described in the sections above, LocalStac
369
368
The LocalStack Web Application provides a Resource Browser for managing RDS instances and clusters.
370
369
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.
0 commit comments