Skip to content

Resource: awsDbProxyTarget

Provides an RDS DB proxy target resource.

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");
const awsDbProxyTargetExample = new aws.dbProxyTarget.DbProxyTarget(
  this,
  "example_2",
  {
    dbInstanceIdentifier: "${aws_db_instance.example.id}",
    dbProxyName: awsDbProxyExample.name,
    targetGroupName: awsDbProxyDefaultTargetGroupExample.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.*/
awsDbProxyTargetExample.overrideLogicalId("example");

Argument Reference

The following arguments are supported:

  • dbProxyName - (Required, Forces new resource) The name of the DB proxy.
  • targetGroupName - (Required, Forces new resource) The name of the target group.
  • dbInstanceIdentifier - (Optional, Forces new resource) DB instance identifier.
  • dbClusterIdentifier - (Optional, Forces new resource) DB cluster identifier.

NOTE: Either dbInstanceIdentifier or dbClusterIdentifier should be specified and both should not be specified together

Attributes Reference

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

  • endpoint - Hostname for the target RDS DB Instance. Only returned for RDS_INSTANCE type.
  • id - Identifier of dbProxyName, targetGroupName, target type (e.g., RDS_INSTANCE or TRACKED_CLUSTER), and resource identifier separated by forward slashes (/).
  • port - Port for the target RDS DB Instance or Aurora DB Cluster.
  • rdsResourceId - Identifier representing the DB Instance or DB Cluster target.
  • targetArn - Amazon Resource Name (ARN) for the DB instance or DB cluster. Currently not returned by the RDS API.
  • trackedClusterId - DB Cluster identifier for the DB Instance target. Not returned unless manually importing an RDS_INSTANCE target that is part of a DB Cluster.
  • type - Type of targetE.g., RDS_INSTANCE or TRACKED_CLUSTER

Import

RDS DB Proxy Targets can be imported using the dbProxyName, targetGroupName, target type (e.g., RDS_INSTANCE or TRACKED_CLUSTER), and resource identifier separated by forward slashes (/), e.g.,

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