Resource: aws_db_proxy_target

Provides an RDS DB proxy target resource.

Example Usage

resource "aws_db_proxy" "example" {
  name                   = "example"
  debug_logging          = false
  engine_family          = "MYSQL"
  idle_client_timeout    = 1800
  require_tls            = true
  role_arn               = aws_iam_role.example.arn
  vpc_security_group_ids = [aws_security_group.example.id]
  vpc_subnet_ids         = [aws_subnet.example.id]

  auth {
    auth_scheme = "SECRETS"
    description = "example"
    iam_auth    = "DISABLED"
    secret_arn  = aws_secretsmanager_secret.example.arn
  }

  tags = {
    Name = "example"
    Key  = "value"
  }
}

resource "aws_db_proxy_default_target_group" "example" {
  db_proxy_name = aws_db_proxy.example.name

  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"]
  }
}

resource "aws_db_proxy_target" "example" {
  db_instance_identifier = aws_db_instance.example.identifier
  db_proxy_name          = aws_db_proxy.example.name
  target_group_name      = aws_db_proxy_default_target_group.example.name
}

Argument Reference

This resource supports the following arguments:

NOTE: Either db_instance_identifier or db_cluster_identifier should be specified and both should not be specified together

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import RDS DB Proxy Targets using the db_proxy_name, target_group_name, target type (such as RDS_INSTANCE or TRACKED_CLUSTER), and resource identifier separated by forward slashes (/). For example:

Instances:

import {
  to = aws_db_proxy_target.example
  id = "example-proxy/default/RDS_INSTANCE/example-instance"
}

Provisioned Clusters:

import {
  to = aws_db_proxy_target.example
  id = "example-proxy/default/TRACKED_CLUSTER/example-cluster"
}

Using terraform import to import RDS DB Proxy Targets using the db_proxy_name, target_group_name, target type (such as RDS_INSTANCE or TRACKED_CLUSTER), and resource identifier separated by forward slashes (/). For example:

Instances:

% terraform import aws_db_proxy_target.example example-proxy/default/RDS_INSTANCE/example-instance

Provisioned Clusters:

% terraform import aws_db_proxy_target.example example-proxy/default/TRACKED_CLUSTER/example-cluster