class SubnetGroup (construct)
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.RDS.SubnetGroup |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsrds#SubnetGroup |
![]() | software.amazon.awscdk.services.rds.SubnetGroup |
![]() | aws_cdk.aws_rds.SubnetGroup |
![]() | aws-cdk-lib » aws_rds » SubnetGroup |
Implements
IConstruct
, IDependable
, IResource
, ISubnet
Class for creating a RDS DB subnet group.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_ec2 as ec2 } from 'aws-cdk-lib';
import { aws_rds as rds } from 'aws-cdk-lib';
declare const subnet: ec2.Subnet;
declare const subnetFilter: ec2.SubnetFilter;
declare const vpc: ec2.Vpc;
const subnetGroup = new rds.SubnetGroup(this, 'MySubnetGroup', {
description: 'description',
vpc: vpc,
// the properties below are optional
removalPolicy: cdk.RemovalPolicy.DESTROY,
subnetGroupName: 'subnetGroupName',
vpcSubnets: {
availabilityZones: ['availabilityZones'],
onePerAz: false,
subnetFilters: [subnetFilter],
subnetGroupName: 'subnetGroupName',
subnets: [subnet],
subnetType: ec2.SubnetType.PRIVATE_ISOLATED,
},
});
Initializer
new SubnetGroup(scope: Construct, id: string, props: SubnetGroupProps)
Parameters
- scope
Construct
- id
string
- props
Subnet
Group Props
Construct Props
Name | Type | Description |
---|---|---|
description | string | Description of the subnet group. |
vpc | IVpc | The VPC to place the subnet group in. |
removal | Removal | The removal policy to apply when the subnet group are removed from the stack or replaced during an update. |
subnet | string | The name of the subnet group. |
vpc | Subnet | Which subnets within the VPC to associate with this group. |
description
Type:
string
Description of the subnet group.
vpc
Type:
IVpc
The VPC to place the subnet group in.
removalPolicy?
Type:
Removal
(optional, default: RemovalPolicy.DESTROY)
The removal policy to apply when the subnet group are removed from the stack or replaced during an update.
subnetGroupName?
Type:
string
(optional, default: a name is generated)
The name of the subnet group.
vpcSubnets?
Type:
Subnet
(optional, default: private subnets)
Which subnets within the VPC to associate with this group.
Properties
Name | Type | Description |
---|---|---|
env | Resource | The environment this resource belongs to. |
node | Node | The tree node. |
stack | Stack | The stack in which this resource is defined. |
subnet | string | The name of the subnet group. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed by the CDK (generally, those created by creating new class instances like Role, Bucket, etc.), this is always the same as the environment of the stack they belong to; however, for imported resources (those obtained from static methods like fromRoleArn, fromBucketName, etc.), that might be different than the stack they were imported into.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
subnetGroupName
Type:
string
The name of the subnet group.
Methods
Name | Description |
---|---|
apply | Apply the given removal policy to this resource. |
to | Returns a string representation of this construct. |
static from | Imports an existing subnet group by name. |
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
Removal
Policy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY
), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN
).
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromSubnetGroupName(scope, id, subnetGroupName)
public static fromSubnetGroupName(scope: Construct, id: string, subnetGroupName: string): ISubnetGroup
Parameters
- scope
Construct
- id
string
- subnetGroupName
string
Returns
Imports an existing subnet group by name.