Skip to content

Commit

Permalink
cmd/atlas/internal: fix IAM Authentication for RDS MySQL (#2617)
Browse files Browse the repository at this point in the history
* cmd/atlas/internal: register rds CRA on mysql driver when using aws_rds_token

* update doc

* fix readme
  • Loading branch information
ronenlu authored Mar 15, 2024
1 parent 4970c53 commit 42befa3
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions doc/md/guides/deploying/secrets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -199,23 +199,49 @@ values={[

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

<Tabs>
<TabItem value="postgres" label="postgres" default>

```hcl
locals {
user = "iamuser"
endpoint = "hostname-of-db.example9y7k.us-east-1.rds.amazonaws.com:5432"
}
data "aws_rds_token" "db" {
region = "us-east-1"
endpoint = local.endpoint
username = local.user
region = "us-east-1"
endpoint = local.endpoint
username = local.user
}
env "rds" {
url = "postgres://${local.user}:${urlescape(data.aws_rds_token.db)}@${local.endpoint}/postgres"
}
```

</TabItem>
<TabItem value="mysql" label="mysql">

```hcl
locals {
user = "iamuser"
endpoint = "hostname-of-db.example9y7k.us-east-1.rds.amazonaws.com:3306"
}
data "aws_rds_token" "db" {
region = "us-east-1"
endpoint = local.endpoint
username = local.user
}
env "rds" {
url = "mysql://${local.user}:${urlescape(data.aws_rds_token.db)}@${local.endpoint}?tls=preferred&allowCleartextPasswords=true"
}
```

</TabItem>
</Tabs>

Let's breakdown the configuration:
* The `aws_rds_token` data source is used to retrieve the database password from AWS Secrets Manager.
* We define an `env` named `rds`. The value retrieved by the `aws_rds_token` data source
Expand Down

0 comments on commit 42befa3

Please sign in to comment.