class ProxyTarget
Language | Type name |
---|---|
.NET | Amazon.CDK.AWS.RDS.ProxyTarget |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsrds#ProxyTarget |
Java | software.amazon.awscdk.services.rds.ProxyTarget |
Python | aws_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
Name | Description |
---|---|
bind(proxy) | Bind this target to the specified database proxy. |
static from | From cluster. |
static from | From instance. |
bind(proxy)
public bind(proxy: DatabaseProxy): ProxyTargetConfig
Parameters
- proxy
Database
Proxy
Returns
Bind this target to the specified database proxy.
Cluster(cluster)
static frompublic static fromCluster(cluster: IDatabaseCluster): ProxyTarget
Parameters
- cluster
IDatabase
— RDS database cluster.Cluster
Returns
From cluster.
Instance(instance)
static frompublic static fromInstance(instance: IDatabaseInstance): ProxyTarget
Parameters
- instance
IDatabase
— RDS database instance.Instance
Returns
From instance.