AWS RDS Proxy Terraform module

January 15, 2026 ยท View on GitHub

Terraform module which creates an AWS RDS Proxy and its supporting resources.

Usage

See examples directory for working examples to reference:

module "rds_proxy" {
  source = "terraform-aws-modules/rds-proxy/aws"

  name                   = "rds-proxy"
  iam_role_name          = "rds-proxy-role"
  vpc_subnet_ids         = ["subnet-30ef7b3c", "subnet-1ecda77b", "subnet-ca09ddbc"]
  vpc_security_group_ids = ["sg-f1d03a88"]

  endpoints = {
    read_write = {
      name                   = "read-write-endpoint"
      vpc_subnet_ids         = ["subnet-30ef7b3c", "subnet-1ecda77b", "subnet-ca09ddbc"]
      vpc_security_group_ids = ["sg-f1d03a88"]
    },
    read_only = {
      name                   = "read-only-endpoint"
      vpc_subnet_ids         = ["subnet-30ef7b3c", "subnet-1ecda77b", "subnet-ca09ddbc"]
      vpc_security_group_ids = ["sg-f1d03a88"]
      target_role            = "READ_ONLY"
    }
  }

  auth = {
    "superuser" = {
      description        = "Aurora PostgreSQL superuser password"
      secret_arn         = "arn:aws:secretsmanager:us-east-1:123456789012:secret:superuser-6gsjLD"
    }
  }

  # Target Aurora cluster
  engine_family         = "POSTGRESQL"
  target_db_cluster     = true
  db_cluster_identifier = "my-endpoint"

  tags = {
    Terraform   = "true"
    Environment = "dev"
  }
}

Examples

Examples codified under the examples are intended to give users references for how to use the module(s) as well as testing/validating changes to the source code of the module(s). If contributing to the project, please be sure to make any appropriate updates to the relevant examples to allow maintainers to test your changes and to keep the examples up to date for users. Thank you!

Requirements

NameVersion
terraform>= 1.5.7
aws>= 6.28

Providers

NameVersion
aws>= 6.28

Modules

No modules.

Resources

NameType
aws_cloudwatch_log_group.thisresource
aws_db_proxy.thisresource
aws_db_proxy_default_target_group.thisresource
aws_db_proxy_endpoint.thisresource
aws_db_proxy_target.db_clusterresource
aws_db_proxy_target.db_instanceresource
aws_iam_role.thisresource
aws_iam_role_policy.thisresource
aws_iam_policy_document.assume_roledata source
aws_iam_policy_document.thisdata source
aws_partition.currentdata source
aws_region.currentdata source
aws_service_principal.rdsdata source

Inputs

NameDescriptionTypeDefaultRequired
authConfiguration block(s) with authorization mechanisms to connect to the associated instances or clusters
map(object({
auth_scheme = optional(string)
client_password_auth_type = optional(string)
description = optional(string)
iam_auth = optional(string)
secret_arn = optional(string)
username = optional(string)
}))
{
"default": {
"auth_scheme": "SECRETS"
}
}
no
connection_borrow_timeoutThe number of seconds for a proxy to wait for a connection to become available in the connection poolnumbernullno
createWhether cluster should be created (affects nearly all resources)booltrueno
create_iam_policyDetermines whether an IAM policy is createdbooltrueno
create_iam_roleDetermines whether an IAM role is createdbooltrueno
db_cluster_identifierDB cluster identifierstring""no
db_instance_identifierDB instance identifierstring""no
debug_loggingWhether the proxy includes detailed information about SQL statements in its logsboolfalseno
default_auth_schemeDefault authentication scheme that the proxy uses for client connections to the proxy and connections from the proxy to the underlying database. Valid values are NONE and IAM_AUTH. Defaults to NONEstringnullno
endpoint_network_typeNetwork type of the DB proxy endpoint. Valid values are IPV4, IPV6 and DUAL. Defaults to IPV4. If IPV6 is specified, the subnets associated with the proxy must be IPv6-only, and target_connection_network_type must be IPV6stringnullno
endpointsMap of DB proxy endpoints to create and their attributes
map(object({
name = optional(string)
vpc_subnet_ids = list(string)
vpc_security_group_ids = optional(list(string))
target_role = optional(string)
tags = optional(map(string), {})
}))
{}no
engine_familyThe kind of database engine that the proxy will connect to. Valid values are MYSQL or POSTGRESQLstring""no
iam_policy_nameThe name of the role policy. If omitted, Terraform will assign a random, unique namestring""no
iam_role_descriptionThe description of the rolestring""no
iam_role_force_detach_policiesSpecifies to force detaching any policies the role has before destroying itbooltrueno
iam_role_max_session_durationThe maximum session duration (in seconds) that you want to set for the specified rolenumber43200no
iam_role_nameThe name of the role. If omitted, Terraform will assign a random, unique namestring""no
iam_role_pathThe path to the rolestringnullno
iam_role_permissions_boundaryThe ARN of the policy that is used to set the permissions boundary for the rolestringnullno
iam_role_tagsA map of tags to apply to the IAM rolemap(string){}no
idle_client_timeoutThe number of seconds that a connection to the proxy can be inactive before the proxy disconnects itnumber1800no
init_queryOne or more SQL statements for the proxy to run when opening each new database connectionstring""no
kms_key_arnsList of KMS Key ARNs to allow access to decrypt SecretsManager secretslist(string)[]no
log_group_classSpecified the log class of the log group. Possible values are: STANDARD or INFREQUENT_ACCESSstringnullno
log_group_kms_key_idThe ARN of the KMS Key to use when encrypting log datastringnullno
log_group_retention_in_daysSpecifies the number of days you want to retain log events in the log groupnumber30no
log_group_tagsA map of tags to apply to the CloudWatch log groupmap(string){}no
manage_log_groupDetermines whether Terraform will create/manage the CloudWatch log group or not. Note - this will fail if set to true after the log group has been created as the resource will already existbooltrueno
max_connections_percentThe maximum size of the connection pool for each target in a target groupnumber90no
max_idle_connections_percentControls how actively the proxy closes idle database connections in the connection poolnumber50no
nameThe identifier for the proxy. This name must be unique for all proxies owned by your AWS account in the specified AWS Region. An identifier must begin with a letter and must contain only ASCII letters, digits, and hyphens; it can't end with a hyphen or contain two consecutive hyphensstring""no
proxy_tagsA map of tags to apply to the RDS Proxymap(string){}no
regionRegion where the resource(s) will be managed. Defaults to the Region set in the provider configurationstringnullno
require_tlsA Boolean parameter that specifies whether Transport Layer Security (TLS) encryption is required for connections to the proxybooltrueno
role_arnThe Amazon Resource Name (ARN) of the IAM role that the proxy uses to access secrets in AWS Secrets Managerstring""no
session_pinning_filtersEach item in the list represents a class of SQL operations that normally cause all later statements in a session using a proxy to be pinned to the same underlying database connectionlist(string)[]no
tagsA map of tags to add to all resourcesmap(string){}no
target_connection_network_typeNetwork type that the proxy uses to connect to the target database. Valid values are IPV4 and IPV6. Defaults to IPV4stringnullno
target_db_clusterDetermines whether DB cluster is targeted by proxyboolfalseno
target_db_instanceDetermines whether DB instance is targeted by proxyboolfalseno
use_policy_name_prefixWhether to use unique name beginning with the specified iam_policy_nameboolfalseno
use_role_name_prefixWhether to use unique name beginning with the specified iam_role_nameboolfalseno
vpc_security_group_idsOne or more VPC security group IDs to associate with the new proxylist(string)[]no
vpc_subnet_idsOne or more VPC subnet IDs to associate with the new proxylist(string)[]no

Outputs

NameDescription
db_proxy_endpointsArray containing the full resource object and attributes for all DB proxy endpoints created
iam_role_arnThe Amazon Resource Name (ARN) of the IAM role that the proxy uses to access secrets in AWS Secrets Manager.
iam_role_nameIAM role name
iam_role_unique_idStable and unique string identifying the IAM role
log_group_arnThe Amazon Resource Name (ARN) of the CloudWatch log group
log_group_nameThe name of the CloudWatch log group
proxy_arnThe Amazon Resource Name (ARN) for the proxy
proxy_default_target_group_arnThe Amazon Resource Name (ARN) for the default target group
proxy_default_target_group_idThe ID for the default target group
proxy_default_target_group_nameThe name of the default target group
proxy_endpointThe endpoint that you can use to connect to the proxy
proxy_idThe ID for the proxy
proxy_target_endpointHostname for the target RDS DB Instance. Only returned for RDS_INSTANCE type
proxy_target_idIdentifier of db_proxy_name, target_group_name, target type (e.g. RDS_INSTANCE or TRACKED_CLUSTER), and resource identifier separated by forward slashes (/)
proxy_target_portPort for the target RDS DB Instance or Aurora DB Cluster
proxy_target_rds_resource_idIdentifier representing the DB Instance or DB Cluster target
proxy_target_target_arnAmazon Resource Name (ARN) for the DB instance or DB cluster. Currently not returned by the RDS API
proxy_target_tracked_cluster_idDB Cluster identifier for the DB Instance target. Not returned unless manually importing an RDS_INSTANCE target that is part of a DB Cluster
proxy_target_typeType of target. e.g. RDS_INSTANCE or TRACKED_CLUSTER

License

Apache-2.0 Licensed. See LICENSE.