This template configures an AWS RDS DB Proxy along with its default target group, setting up connection pool configurations and other proxy settings.

Terraform Template

resource "aws_db_proxy" "example" {

  auth {
    auth_scheme = "SECRETS"
    description = "example"
    iam_auth = "DISABLED"
    secret_arn = "aws_secretsmanager_secret.example.arn"
  }
  debug_logging = false
  engine_family = "MYSQL"
  idle_client_timeout = 1800
  name = "example"
  require_tls = true
  role_arn = "aws_iam_role.example.arn"

  tags = {
    Key = "value"
    Name = "example"
  }
  vpc_security_group_ids = ["aws_security_group.example.id"]
  vpc_subnet_ids = ["aws_subnet.example.id"]
}

resource "aws_db_proxy_default_target_group" "example" {

  connection_pool_config {
    connection_borrow_timeout = 120
    init_query = "SET x=1, y=2"
    max_connections_percent = 100
    max_idle_connections_percent = 50
    session_pinning_filters = ["EXCLUDE_VARIABLE_SETS"]
  }
  db_proxy_name = aws_db_proxy.example.name
}