How to use RDS Proxy Module
View SourceRelease NotesIn 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
- Terraform
- Terragrunt
# ------------------------------------------------------------------------------------------------------
# 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.29.2"
# ----------------------------------------------------------------------------------------------------
# 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
}
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S RDS-PROXY MODULE
# ------------------------------------------------------------------------------------------------------
terraform {
source = "git::git@github.com:gruntwork-io/terraform-aws-data-storage.git//modules/rds-proxy?ref=v0.29.2"
}
inputs = {
# ----------------------------------------------------------------------------------------------------
# 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
- Inputs
- Outputs
Required
connection_pool_configobject(…)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)
})
db_instance_identifierstringThe DB instance identifier
db_secret_arnstringThe 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_familystringThe 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.
namestringThe identifier for the proxy.
subnet_idslist(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.
vpc_idstringThe id of the VPC in which this DB should be deployed.
Optional
allow_connections_from_cidr_blockslist(string)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_timeoutnumberThe 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.
nullportnumberThe port the RDS proxy will listen on (e.g. 3306)
3306require_tlsboolThe 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