Skip to content
v2.277.0

VpcSubnetGroup Struct ​

A group of subnets returned by the VPC provider.

The included subnets do NOT have to be symmetric!

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { cx_api } from 'aws-cdk-lib';
const vpcSubnetGroup: cx_api.VpcSubnetGroup = {
  name: 'name',
  subnets: [{
    availabilityZone: 'availabilityZone',
    routeTableId: 'routeTableId',
    subnetId: 'subnetId',

    // the properties below are optional
    cidr: 'cidr',
  }],
  type: cx_api.VpcSubnetGroupType.PUBLIC,
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import cx_api

vpc_subnet_group = cx_api.VpcSubnetGroup(
    name="name",
    subnets=[cx_api.VpcSubnet(
        availability_zone="availabilityZone",
        route_table_id="routeTableId",
        subnet_id="subnetId",

        # the properties below are optional
        cidr="cidr"
    )],
    type=cx_api.VpcSubnetGroupType.PUBLIC
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.cxapi.*;

VpcSubnetGroup vpcSubnetGroup = VpcSubnetGroup.builder()
        .name("name")
        .subnets(List.of(VpcSubnet.builder()
                .availabilityZone("availabilityZone")
                .routeTableId("routeTableId")
                .subnetId("subnetId")

                // the properties below are optional
                .cidr("cidr")
                .build()))
        .type(VpcSubnetGroupType.PUBLIC)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.CXAPI;

var vpcSubnetGroup = new VpcSubnetGroup {
    Name = "name",
    Subnets = new [] { new VpcSubnet {
        AvailabilityZone = "availabilityZone",
        RouteTableId = "routeTableId",
        SubnetId = "subnetId",

        // the properties below are optional
        Cidr = "cidr"
    } },
    Type = VpcSubnetGroupType.PUBLIC
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

vpcSubnetGroup := &VpcSubnetGroup{
	Name: jsii.String("name"),
	Subnets: []VpcSubnet{
		&VpcSubnet{
			AvailabilityZone: jsii.String("availabilityZone"),
			RouteTableId: jsii.String("routeTableId"),
			SubnetId: jsii.String("subnetId"),

			// the properties below are optional
			Cidr: jsii.String("cidr"),
		},
	},
	Type: awscdk.Cx_api.VpcSubnetGroupType_PUBLIC,
}

Properties ​

namestringnamestrnameStringNamestringName*stringrequired#
The name of the subnet group, determined by looking at the tags of of the subnets that belong to it.
subnetsVpcSubnet[]subnetstyping.List[VpcSubnet]subnetsList<VpcSubnet>SubnetsVpcSubnet[]Subnets*[]VpcSubnetrequired#
The subnets that are part of this group.

There is no condition that the subnets have to be symmetric in the group.