Skip to content

Resource: awsDbProxyDefaultTargetGroup

Provides a resource to manage an RDS DB proxy default target group resource.

The awsDbProxyDefaultTargetGroup behaves differently from normal resources, in that Terraform does not create or destroy this resource, since it implicitly exists as part of an RDS DB Proxy. On Terraform resource creation it is automatically imported and on resource destruction, Terraform performs no actions in RDS.

Example Usage

/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
const awsDbProxyExample = new aws.dbProxy.DbProxy(this, "example", {
  auth: [
    {
      authScheme: "SECRETS",
      description: "example",
      iamAuth: "DISABLED",
      secretArn: "${aws_secretsmanager_secret.example.arn}",
    },
  ],
  debugLogging: false,
  engineFamily: "MYSQL",
  idleClientTimeout: 1800,
  name: "example",
  requireTls: true,
  roleArn: "${aws_iam_role.example.arn}",
  tags: {
    Key: "value",
    Name: "example",
  },
  vpcSecurityGroupIds: ["${aws_security_group.example.id}"],
  vpcSubnetIds: ["${aws_subnet.example.id}"],
});
const awsDbProxyDefaultTargetGroupExample =
  new aws.dbProxyDefaultTargetGroup.DbProxyDefaultTargetGroup(
    this,
    "example_1",
    {
      connectionPoolConfig: {
        connectionBorrowTimeout: 120,
        initQuery: "SET x=1, y=2",
        maxConnectionsPercent: 100,
        maxIdleConnectionsPercent: 50,
        sessionPinningFilters: ["EXCLUDE_VARIABLE_SETS"],
      },
      dbProxyName: awsDbProxyExample.name,
    }
  );
/*This allows the Terraform resource name to match the original name. You can remove the call if you don't need them to match.*/
awsDbProxyDefaultTargetGroupExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • dbProxyName - (Required) Name of the RDS DB Proxy.
  • connectionPoolConfig - (Optional) The settings that determine the size and behavior of the connection pool for the target group.

connectionPoolConfig blocks support the following:

  • connectionBorrowTimeout - (Optional) The number of seconds for a proxy to wait for a connection to become available in the connection pool. Only applies when the proxy has opened its maximum number of connections and all connections are busy with client sessions.
  • initQuery - (Optional) One or more SQL statements for the proxy to run when opening each new database connection. Typically used with set statements to make sure that each connection has identical settings such as time zone and character set. This setting is empty by default. For multiple statements, use semicolons as the separator. You can also include multiple variables in a single set statement, such as setX=1,Y=2.
  • maxConnectionsPercent - (Optional) The maximum size of the connection pool for each target in a target group. For Aurora MySQL, it is expressed as a percentage of the max_connections setting for the RDS DB instance or Aurora DB cluster used by the target group.
  • maxIdleConnectionsPercent - (Optional) Controls how actively the proxy closes idle database connections in the connection pool. A high value enables the proxy to leave a high percentage of idle connections open. A low value causes the proxy to close idle client connections and return the underlying database connections to the connection pool. For Aurora MySQL, it is expressed as a percentage of the max_connections setting for the RDS DB instance or Aurora DB cluster used by the target group.
  • sessionPinningFilters - (Optional) Each 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 connection. Including an item in the list exempts that class of SQL operations from the pinning behavior. Currently, the only allowed value is EXCLUDE_VARIABLE_SETS.

Attributes Reference

In addition to all arguments above, the following attributes are exported:

  • id - Name of the RDS DB Proxy.
  • arn - The Amazon Resource Name (ARN) representing the target group.
  • name - The name of the default target group.

Timeouts

Configuration options:

  • create - (Default 30M)
  • update - (Default 30M)

Import

DB proxy default target groups can be imported using the dbProxyName, e.g.,

$ terraform import aws_db_proxy_default_target_group.example example