Skip to content
v2.275.0

SubnetGroupProps Struct ​

Properties for creating a SubnetGroup.

Example ​

ts
// 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 subnetGroupProps: rds.SubnetGroupProps = {
  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,
  },
};

Properties ​

descriptionstringdescriptionstrdescriptionStringDescriptionstringDescription*stringrequired#
Description of the subnet group.
removalPolicyoptionalRemovalPolicyremoval_policyoptionalRemovalPolicyremovalPolicyoptionalRemovalPolicyRemovalPolicyoptionalRemovalPolicyRemovalPolicyoptionalRemovalPolicy= RemovalPolicy.DESTROY#
The removal policy to apply when the subnet group are removed from the stack or replaced during an update.
subnetGroupNameoptionalstringsubnet_group_nameoptionalstrsubnetGroupNameoptionalStringSubnetGroupNameoptionalstringSubnetGroupNameoptional*string#
The name of the subnet group.

Default: a name is generated

vpcIVpcvpcIVpcvpcIVpcVpcIVpcVpcIVpcrequired#
The VPC to place the subnet group in.
vpcSubnetsoptionalSubnetSelectionvpc_subnetsoptionalSubnetSelectionvpcSubnetsoptionalSubnetSelectionVpcSubnetsoptionalSubnetSelectionVpcSubnetsoptionalSubnetSelection#
Which subnets within the VPC to associate with this group.

Default: private subnets