Skip to content

Commit a545752

Browse files
johncblandiiclaude
andauthored
feat: update db_proxy module with latest AWS provider arguments (#46)
* Update db_proxy module with latest AWS provider arguments Add new auth block fields (client_password_auth_type, username), support SQL Server engine family, and update version constraints to Terraform 1.3+ and AWS provider 5.0+. These changes align the module with the latest Terraform AWS provider capabilities and prepare for wider database engine support. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com> * docs: Update README with latest module changes Auto-generated documentation reflecting updated auth block fields, version constraints, and SQL Server support. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * fix: Use dynamic client_password_auth_type based on engine_family The client_password_auth_type must match the engine_family - MySQL uses MYSQL_NATIVE_PASSWORD, PostgreSQL uses POSTGRES_SCRAM_SHA_256, and SQL Server uses SQL_SERVER_AUTHENTICATION. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 4e69e7c commit a545752

File tree

7 files changed

+91
-29
lines changed

7 files changed

+91
-29
lines changed

README.md

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22

33
<!-- markdownlint-disable -->
44
<a href="https://cpco.io/homepage"><img src="https://github.com/cloudposse/terraform-aws-rds-db-proxy/blob/main/.github/banner.png?raw=true" alt="Project Banner"/></a><br/>
5-
<p align="right">
6-
<a href="https://github.com/cloudposse/terraform-aws-rds-db-proxy/releases/latest"><img src="https://img.shields.io/github/release/cloudposse/terraform-aws-rds-db-proxy.svg?style=for-the-badge" alt="Latest Release"/></a><a href="https://github.com/cloudposse/terraform-aws-rds-db-proxy/commits"><img src="https://img.shields.io/github/last-commit/cloudposse/terraform-aws-rds-db-proxy.svg?style=for-the-badge" alt="Last Updated"/></a><a href="https://cloudposse.com/slack"><img src="https://slack.cloudposse.com/for-the-badge.svg" alt="Slack Community"/></a></p>
5+
6+
7+
<p align="right"><a href="https://github.com/cloudposse/terraform-aws-rds-db-proxy/releases/latest"><img src="https://img.shields.io/github/release/cloudposse/terraform-aws-rds-db-proxy.svg?style=for-the-badge" alt="Latest Release"/></a><a href="https://github.com/cloudposse/terraform-aws-rds-db-proxy/commits"><img src="https://img.shields.io/github/last-commit/cloudposse/terraform-aws-rds-db-proxy.svg?style=for-the-badge" alt="Last Updated"/></a><a href="https://cloudposse.com/slack"><img src="https://slack.cloudposse.com/for-the-badge.svg" alt="Slack Community"/></a><a href="https://cloudposse.com/support/"><img src="https://img.shields.io/badge/Get_Support-success.svg?style=for-the-badge" alt="Get Support"/></a>
8+
9+
</p>
710
<!-- markdownlint-restore -->
811

912
<!--
@@ -15,8 +18,8 @@
1518
**
1619
** This file was automatically generated by the `cloudposse/build-harness`.
1720
** 1) Make all changes to `README.yaml`
18-
** 2) Run `make init` (you only need to do this once)
19-
** 3) Run`make readme` to rebuild this file.
21+
** 2) Install [atmos](https://atmos.tools/install/) (you only need to do this once)
22+
** 3) Run`atmos readme` to rebuild this file.
2023
**
2124
** (We maintain HUNDREDS of open source projects. This is how we maintain our sanity.)
2225
**
@@ -47,6 +50,7 @@ Terraform module to provision an Amazon [RDS Proxy](https://docs.aws.amazon.com/
4750

4851
## Usage
4952

53+
5054
For a complete example, see [examples/complete](examples/complete).
5155

5256
For automated tests of the complete example using [bats](https://github.com/bats-core/bats-core) and [Terratest](https://github.com/gruntwork-io/terratest)
@@ -187,14 +191,14 @@ Review the [complete example](examples/complete) to see how to use this module.
187191

188192
| Name | Version |
189193
|------|---------|
190-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.0 |
191-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.1.15 |
194+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3 |
195+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.0 |
192196

193197
## Providers
194198

195199
| Name | Version |
196200
|------|---------|
197-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 3.1.15 |
201+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 6.27.0 |
198202

199203
## Modules
200204

@@ -224,7 +228,7 @@ Review the [complete example](examples/complete) to see how to use this module.
224228
|------|-------------|------|---------|:--------:|
225229
| <a name="input_additional_tag_map"></a> [additional\_tag\_map](#input\_additional\_tag\_map) | Additional key-value pairs to add to each map in `tags_as_list_of_maps`. Not added to `tags` or `id`.<br/>This is for some rare cases where resources want additional configuration of tags<br/>and therefore take a list of maps with tag key, value, and additional configuration. | `map(string)` | `{}` | no |
226230
| <a name="input_attributes"></a> [attributes](#input\_attributes) | ID element. Additional attributes (e.g. `workers` or `cluster`) to add to `id`,<br/>in the order they appear in the list. New attributes are appended to the<br/>end of the list. The elements of the list are joined by the `delimiter`<br/>and treated as a single ID element. | `list(string)` | `[]` | no |
227-
| <a name="input_auth"></a> [auth](#input\_auth) | Configuration blocks with authorization mechanisms to connect to the associated database instances or clusters | <pre>list(object({<br/> auth_scheme = string<br/> description = string<br/> iam_auth = string<br/> secret_arn = string<br/> }))</pre> | n/a | yes |
231+
| <a name="input_auth"></a> [auth](#input\_auth) | Configuration blocks with authorization mechanisms to connect to the associated database instances or clusters.<br/>- `auth_scheme` - The type of authentication that the proxy uses for connections from the proxy to the underlying database. Valid values are `SECRETS`.<br/>- `client_password_auth_type` - The type of authentication the proxy uses for connections from clients. Valid values are `MYSQL_NATIVE_PASSWORD`, `POSTGRES_SCRAM_SHA_256`, `POSTGRES_MD5`, and `SQL_SERVER_AUTHENTICATION`.<br/>- `description` - A user-specified description about the authentication used by a proxy to log in as a specific database user.<br/>- `iam_auth` - Whether to require or disallow AWS Identity and Access Management (IAM) authentication for connections to the proxy. Valid values are `DISABLED`, `REQUIRED`.<br/>- `secret_arn` - The Amazon Resource Name (ARN) representing the secret that the proxy uses to authenticate to the RDS DB instance or Aurora DB cluster.<br/>- `username` - The name of the database user to which the proxy connects. Note: `username` must NOT be set when `auth_scheme` is `SECRETS`. | <pre>list(object({<br/> auth_scheme = optional(string, "SECRETS")<br/> client_password_auth_type = optional(string)<br/> description = optional(string)<br/> iam_auth = optional(string, "DISABLED")<br/> secret_arn = optional(string)<br/> username = optional(string)<br/> }))</pre> | n/a | yes |
228232
| <a name="input_connection_borrow_timeout"></a> [connection\_borrow\_timeout](#input\_connection\_borrow\_timeout) | The number of seconds for a proxy to wait for a connection to become available in the connection pool. Only applies when the proxy has opened its maximum number of connections and all connections are busy with client sessions | `number` | `120` | no |
229233
| <a name="input_context"></a> [context](#input\_context) | Single object for setting entire context at once.<br/>See description of individual variables for details.<br/>Leave string and numeric variables as `null` to use default value.<br/>Individual variable settings (non-null) override settings in context object,<br/>except for attributes, tags, and additional\_tag\_map, which are merged. | `any` | <pre>{<br/> "additional_tag_map": {},<br/> "attributes": [],<br/> "delimiter": null,<br/> "descriptor_formats": {},<br/> "enabled": true,<br/> "environment": null,<br/> "id_length_limit": null,<br/> "label_key_case": null,<br/> "label_order": [],<br/> "label_value_case": null,<br/> "labels_as_tags": [<br/> "unset"<br/> ],<br/> "name": null,<br/> "namespace": null,<br/> "regex_replace_chars": null,<br/> "stage": null,<br/> "tags": {},<br/> "tenant": null<br/>}</pre> | no |
230234
| <a name="input_db_cluster_identifier"></a> [db\_cluster\_identifier](#input\_db\_cluster\_identifier) | DB cluster identifier. Either `db_instance_identifier` or `db_cluster_identifier` should be specified and both should not be specified together | `string` | `null` | no |
@@ -233,7 +237,7 @@ Review the [complete example](examples/complete) to see how to use this module.
233237
| <a name="input_delimiter"></a> [delimiter](#input\_delimiter) | Delimiter to be used between ID elements.<br/>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
234238
| <a name="input_descriptor_formats"></a> [descriptor\_formats](#input\_descriptor\_formats) | Describe additional descriptors to be output in the `descriptors` output map.<br/>Map of maps. Keys are names of descriptors. Values are maps of the form<br/>`{<br/> format = string<br/> labels = list(string)<br/>}`<br/>(Type is `any` so the map values can later be enhanced to provide additional options.)<br/>`format` is a Terraform format string to be passed to the `format()` function.<br/>`labels` is a list of labels, in order, to pass to `format()` function.<br/>Label values will be normalized before being passed to `format()` so they will be<br/>identical to how they appear in `id`.<br/>Default is `{}` (`descriptors` output will be empty). | `any` | `{}` | no |
235239
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Set to false to prevent the module from creating any resources | `bool` | `null` | no |
236-
| <a name="input_engine_family"></a> [engine\_family](#input\_engine\_family) | The kinds of databases that the proxy can connect to. This value determines which database network protocol the proxy recognizes when it interprets network traffic to and from the database. The engine family applies to MySQL and PostgreSQL for both RDS and Aurora. Valid values are MYSQL and POSTGRESQL | `string` | `"MYSQL"` | no |
240+
| <a name="input_engine_family"></a> [engine\_family](#input\_engine\_family) | The kinds of databases that the proxy can connect to. This value determines which database network protocol the proxy recognizes when it interprets network traffic to and from the database. Valid values are `MYSQL`, `POSTGRESQL`, and `SQLSERVER` | `string` | `"MYSQL"` | no |
237241
| <a name="input_environment"></a> [environment](#input\_environment) | ID element. Usually used for region e.g. 'uw2', 'us-west-2', OR role 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
238242
| <a name="input_existing_iam_role_arn"></a> [existing\_iam\_role\_arn](#input\_existing\_iam\_role\_arn) | The ARN of an existing IAM role that the proxy can use to access secrets in AWS Secrets Manager. If not provided, the module will create a role to access secrets in Secrets Manager | `string` | `null` | no |
239243
| <a name="input_iam_role_attributes"></a> [iam\_role\_attributes](#input\_iam\_role\_attributes) | Additional attributes to add to the ID of the IAM role that the proxy uses to access secrets in AWS Secrets Manager | `list(string)` | `null` | no |
@@ -335,7 +339,8 @@ Check out these related projects.
335339
> - **Customer Workshops.** Engage with our team in weekly workshops, gaining insights and strategies to continuously improve and innovate.
336340
>
337341
> <a href="https://cpco.io/commercial-support?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-rds-db-proxy&utm_content=commercial_support"><img alt="Request Quote" src="https://img.shields.io/badge/request%20quote-success.svg?style=for-the-badge"/></a>
338-
> </details>
342+
>
343+
</details>
339344
340345
## ✨ Contributing
341346

@@ -361,6 +366,38 @@ In general, PRs are welcome. We follow the typical "fork-and-pull" Git workflow.
361366

362367
**NOTE:** Be sure to merge the latest changes from "upstream" before making a pull request!
363368

369+
370+
## Running Terraform Tests
371+
372+
We use [Atmos](https://atmos.tools) to streamline how Terraform tests are run. It centralizes configuration and wraps common test workflows with easy-to-use commands.
373+
374+
All tests are located in the [`test/`](test) folder.
375+
376+
Under the hood, tests are powered by Terratest together with our internal [Test Helpers](https://github.com/cloudposse/test-helpers) library, providing robust infrastructure validation.
377+
378+
Setup dependencies:
379+
- Install Atmos ([installation guide](https://atmos.tools/install/))
380+
- Install Go [1.24+ or newer](https://go.dev/doc/install)
381+
- Install Terraform or OpenTofu
382+
383+
To run tests:
384+
385+
- Run all tests:
386+
```sh
387+
atmos test run
388+
```
389+
- Clean up test artifacts:
390+
```sh
391+
atmos test clean
392+
```
393+
- Explore additional test options:
394+
```sh
395+
atmos test --help
396+
```
397+
The configuration for test commands is centrally managed. To review what's being imported, see the [`atmos.yaml`](https://raw.githubusercontent.com/cloudposse/.github/refs/heads/main/.github/atmos/terraform-module.yaml) file.
398+
399+
Learn more about our [automated testing in our documentation](https://docs.cloudposse.com/community/contribute/automated-testing/) or implementing [custom commands](https://atmos.tools/core-concepts/custom-commands/) with atmos.
400+
364401
### 🌎 Slack Community
365402

366403
Join our [Open Source Community](https://cpco.io/slack?utm_source=github&utm_medium=readme&utm_campaign=cloudposse/terraform-aws-rds-db-proxy&utm_content=slack) on Slack. It's **FREE** for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally *sweet* infrastructure.

examples/complete/main.tf

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,20 @@ locals {
1919
password = local.database_password
2020
}
2121

22+
# Map engine family to appropriate client password auth type
23+
client_password_auth_type = {
24+
MYSQL = "MYSQL_NATIVE_PASSWORD"
25+
POSTGRESQL = "POSTGRES_SCRAM_SHA_256"
26+
SQLSERVER = "SQL_SERVER_AUTHENTICATION"
27+
}
28+
2229
auth = [
2330
{
24-
auth_scheme = "SECRETS"
25-
description = "Access the database instance using username and password from AWS Secrets Manager"
26-
iam_auth = "DISABLED"
27-
secret_arn = aws_secretsmanager_secret.rds_username_and_password.arn
31+
auth_scheme = "SECRETS"
32+
client_password_auth_type = local.client_password_auth_type[var.engine_family]
33+
description = "Access the database instance using username and password from AWS Secrets Manager"
34+
iam_auth = "DISABLED"
35+
secret_arn = aws_secretsmanager_secret.rds_username_and_password.arn
2836
}
2937
]
3038

examples/complete/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ variable "debug_logging" {
100100
variable "engine_family" {
101101
type = string
102102
default = "MYSQL"
103-
description = "The kinds of databases that the proxy can connect to. This value determines which database network protocol the proxy recognizes when it interprets network traffic to and from the database. The engine family applies to MySQL and PostgreSQL for both RDS and Aurora. Valid values are MYSQL and POSTGRESQL"
103+
description = "The kinds of databases that the proxy can connect to. This value determines which database network protocol the proxy recognizes when it interprets network traffic to and from the database. Valid values are `MYSQL`, `POSTGRESQL`, and `SQLSERVER`"
104104
}
105105

106106
variable "idle_client_timeout" {

examples/complete/versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 1"
2+
required_version = ">= 1.3"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 3.1.15"
7+
version = ">= 5.0"
88
}
99
}
1010
}

main.tf

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ resource "aws_db_proxy" "this" {
1818
for_each = var.auth
1919

2020
content {
21-
auth_scheme = auth.value.auth_scheme
22-
description = auth.value.description
23-
iam_auth = auth.value.iam_auth
24-
secret_arn = auth.value.secret_arn
21+
auth_scheme = auth.value.auth_scheme
22+
client_password_auth_type = auth.value.client_password_auth_type
23+
description = auth.value.description
24+
iam_auth = auth.value.iam_auth
25+
secret_arn = auth.value.secret_arn
26+
username = auth.value.username
2527
}
2628
}
2729

variables.tf

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ variable "debug_logging" {
77
variable "engine_family" {
88
type = string
99
default = "MYSQL"
10-
description = "The kinds of databases that the proxy can connect to. This value determines which database network protocol the proxy recognizes when it interprets network traffic to and from the database. The engine family applies to MySQL and PostgreSQL for both RDS and Aurora. Valid values are MYSQL and POSTGRESQL"
10+
description = "The kinds of databases that the proxy can connect to. This value determines which database network protocol the proxy recognizes when it interprets network traffic to and from the database. Valid values are `MYSQL`, `POSTGRESQL`, and `SQLSERVER`"
11+
12+
validation {
13+
condition = contains(["MYSQL", "POSTGRESQL", "SQLSERVER"], var.engine_family)
14+
error_message = "Valid values for engine_family are MYSQL, POSTGRESQL, and SQLSERVER."
15+
}
1116
}
1217

1318
variable "idle_client_timeout" {
@@ -34,12 +39,22 @@ variable "vpc_subnet_ids" {
3439

3540
variable "auth" {
3641
type = list(object({
37-
auth_scheme = string
38-
description = string
39-
iam_auth = string
40-
secret_arn = string
42+
auth_scheme = optional(string, "SECRETS")
43+
client_password_auth_type = optional(string)
44+
description = optional(string)
45+
iam_auth = optional(string, "DISABLED")
46+
secret_arn = optional(string)
47+
username = optional(string)
4148
}))
42-
description = "Configuration blocks with authorization mechanisms to connect to the associated database instances or clusters"
49+
description = <<-EOT
50+
Configuration blocks with authorization mechanisms to connect to the associated database instances or clusters.
51+
- `auth_scheme` - The type of authentication that the proxy uses for connections from the proxy to the underlying database. Valid values are `SECRETS`.
52+
- `client_password_auth_type` - The type of authentication the proxy uses for connections from clients. Valid values are `MYSQL_NATIVE_PASSWORD`, `POSTGRES_SCRAM_SHA_256`, `POSTGRES_MD5`, and `SQL_SERVER_AUTHENTICATION`.
53+
- `description` - A user-specified description about the authentication used by a proxy to log in as a specific database user.
54+
- `iam_auth` - Whether to require or disallow AWS Identity and Access Management (IAM) authentication for connections to the proxy. Valid values are `DISABLED`, `REQUIRED`.
55+
- `secret_arn` - The Amazon Resource Name (ARN) representing the secret that the proxy uses to authenticate to the RDS DB instance or Aurora DB cluster.
56+
- `username` - The name of the database user to which the proxy connects. Note: `username` must NOT be set when `auth_scheme` is `SECRETS`.
57+
EOT
4358
}
4459

4560
variable "db_instance_identifier" {

versions.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
terraform {
2-
required_version = ">= 0.13.0"
2+
required_version = ">= 1.3"
33

44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 3.1.15"
7+
version = ">= 5.0"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)