Skip to main content
Data Storage Modules 0.32Last updated in version 0.31.4

How to use RDS Proxy Module

View SourceRelease Notes

In order to setup a RDS proxy, you need to setup database credentials in AWS Secrets Manager and pass it to this module. Refer to the examples/rds-proxy or https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/rds-proxy-setup.html#rds-proxy-secrets-arns for more information.

Setting up a RDS proxy requires the following steps, which is handled by this module:

  • Setting up network prerequisites
  • Setting up database credentials
  • Setting up AWS Identity and Access Management (IAM) policies

Sample Usage

main.tf

# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S RDS-PROXY MODULE
# ------------------------------------------------------------------------------------------------------

module "rds_proxy" {

source = "git::git@github.com:gruntwork-io/terraform-aws-data-storage.git//modules/rds-proxy?ref=v0.32"

# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------

# The number of seconds that a connection to the proxy can be inactive before
# the proxy disconnects it. You can set this value higher or lower than the
# connection timeout limit for the associated database.
connection_pool_config = <object(
connection_borrow_timeout = number
init_query = string
max_connections_percent = number
max_idle_connections_percent = number
session_pinning_filters = list(string)
)>

# The DB instance identifier
db_instance_identifier = <string>

# The DB secret should contain username and password for the DB as a key-value
# pairs. Otherwise, you can insert plaintext secret with the format should
# look like {"username":"your_username","password":"your_password"}.
db_secret_arn = <string>

# 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.
engine_family = <string>

# The identifier for the proxy.
name = <string>

# A list of subnet ids where the database instances should be deployed. In the
# standard Gruntwork VPC setup, these should be the private persistence subnet
# ids. This is ignored if create_subnet_group=false.
subnet_ids = <list(string)>

# The id of the VPC in which this DB should be deployed.
vpc_id = <string>

# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------

# A list of CIDR-formatted IP address ranges that can connect to this DB.
# Should typically be the CIDR blocks of the private app subnet in this VPC
# plus the private subnet in the mgmt VPC.
allow_connections_from_cidr_blocks = []

# The number of seconds that a connection to the proxy can be inactive before
# the proxy disconnects it. You can set this value higher or lower than the
# connection timeout limit for the associated database.
idle_client_timeout = null

# The port the RDS proxy will listen on (e.g. 3306)
port = 3306

# The number of seconds that a connection to the proxy can be inactive before
# the proxy disconnects it. You can set this value higher or lower than the
# connection timeout limit for the associated database.
require_tls = null

}


Reference

Required

connection_pool_configobject(…)required

The number of seconds that a connection to the proxy can be inactive before the proxy disconnects it. You can set this value higher or lower than the connection timeout limit for the associated database.

object({
connection_borrow_timeout = number
init_query = string
max_connections_percent = number
max_idle_connections_percent = number
session_pinning_filters = list(string)
})

The DB instance identifier

db_secret_arnstringrequired

The DB secret should contain username and password for the DB as a key-value pairs. Otherwise, you can insert plaintext secret with the format should look like {'username':'your_username','password':'your_password'}.

engine_familystringrequired

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.

namestringrequired

The identifier for the proxy.

subnet_idslist(string)required

A list of subnet ids where the database instances should be deployed. In the standard Gruntwork VPC setup, these should be the private persistence subnet ids. This is ignored if create_subnet_group=false.

vpc_idstringrequired

The id of the VPC in which this DB should be deployed.

Optional

A list of CIDR-formatted IP address ranges that can connect to this DB. Should typically be the CIDR blocks of the private app subnet in this VPC plus the private subnet in the mgmt VPC.

[]
idle_client_timeoutnumberoptional

The number of seconds that a connection to the proxy can be inactive before the proxy disconnects it. You can set this value higher or lower than the connection timeout limit for the associated database.

null
portnumberoptional

The port the RDS proxy will listen on (e.g. 3306)

3306
require_tlsbooloptional

The number of seconds that a connection to the proxy can be inactive before the proxy disconnects it. You can set this value higher or lower than the connection timeout limit for the associated database.

null