Skip to content

Commit 42befa3

Browse files
authored
cmd/atlas/internal: fix IAM Authentication for RDS MySQL (#2617)
* cmd/atlas/internal: register rds CRA on mysql driver when using aws_rds_token * update doc * fix readme
1 parent 4970c53 commit 42befa3

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

doc/md/guides/deploying/secrets.mdx

+29-3
Original file line numberDiff line numberDiff line change
@@ -199,23 +199,49 @@ values={[
199199

200200
4. Create a new file named `atlas.hcl` with the following contents:
201201

202+
<Tabs>
203+
<TabItem value="postgres" label="postgres" default>
204+
202205
```hcl
203206
locals {
204207
user = "iamuser"
205208
endpoint = "hostname-of-db.example9y7k.us-east-1.rds.amazonaws.com:5432"
206209
}
207210
208211
data "aws_rds_token" "db" {
209-
region = "us-east-1"
210-
endpoint = local.endpoint
211-
username = local.user
212+
region = "us-east-1"
213+
endpoint = local.endpoint
214+
username = local.user
212215
}
213216
214217
env "rds" {
215218
url = "postgres://${local.user}:${urlescape(data.aws_rds_token.db)}@${local.endpoint}/postgres"
216219
}
217220
```
218221

222+
</TabItem>
223+
<TabItem value="mysql" label="mysql">
224+
225+
```hcl
226+
locals {
227+
user = "iamuser"
228+
endpoint = "hostname-of-db.example9y7k.us-east-1.rds.amazonaws.com:3306"
229+
}
230+
231+
data "aws_rds_token" "db" {
232+
region = "us-east-1"
233+
endpoint = local.endpoint
234+
username = local.user
235+
}
236+
237+
env "rds" {
238+
url = "mysql://${local.user}:${urlescape(data.aws_rds_token.db)}@${local.endpoint}?tls=preferred&allowCleartextPasswords=true"
239+
}
240+
```
241+
242+
</TabItem>
243+
</Tabs>
244+
219245
Let's breakdown the configuration:
220246
* The `aws_rds_token` data source is used to retrieve the database password from AWS Secrets Manager.
221247
* We define an `env` named `rds`. The value retrieved by the `aws_rds_token` data source

0 commit comments

Comments
 (0)