aws-cdk-lib.aws_rds.ProxyTarget

class ProxyTarget

LanguageType name
.NETAmazon.CDK.AWS.RDS.ProxyTarget
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsrds#ProxyTarget
Javasoftware.amazon.awscdk.services.rds.ProxyTarget
Pythonaws_cdk.aws_rds.ProxyTarget
TypeScript (source)aws-cdk-lib » aws_rds » ProxyTarget

Proxy target: Instance or Cluster.

A target group is a collection of databases that the proxy can connect to. Currently, you can specify only one RDS DB instance or Aurora DB cluster.

Example

declare const vpc: ec2.Vpc;
const cluster = new rds.DatabaseCluster(this, 'Database', {
  engine: rds.DatabaseClusterEngine.auroraMysql({
    version: rds.AuroraMysqlEngineVersion.VER_3_03_0,
  }),
  writer: rds.ClusterInstance.provisioned('writer'),
  vpc,
});

const proxy = new rds.DatabaseProxy(this, 'Proxy', {
  proxyTarget: rds.ProxyTarget.fromCluster(cluster),
  secrets: [cluster.secret!],
  vpc,
});

const role = new iam.Role(this, 'DBProxyRole', { assumedBy: new iam.AccountPrincipal(this.account) });
proxy.grantConnect(role, 'admin'); // Grant the role connection access to the DB Proxy for database user 'admin'.

Methods

NameDescription
bind(proxy)Bind this target to the specified database proxy.
static fromCluster(cluster)From cluster.
static fromInstance(instance)From instance.

bind(proxy)

public bind(proxy: DatabaseProxy): ProxyTargetConfig

Parameters

  • proxy DatabaseProxy

Returns

  • ProxyTargetConfig

Bind this target to the specified database proxy.


static fromCluster(cluster)

public static fromCluster(cluster: IDatabaseCluster): ProxyTarget

Parameters

  • cluster IDatabaseCluster — RDS database cluster.

Returns

  • ProxyTarget

From cluster.


static fromInstance(instance)

public static fromInstance(instance: IDatabaseInstance): ProxyTarget

Parameters

  • instance IDatabaseInstance — RDS database instance.

Returns

  • ProxyTarget

From instance.