Skip to content
v2.278.0

CfnVPCCidrBlockProps ​

Struct External

Properties for defining a CfnVPCCidrBlock.

Example ​

ts
import { KubectlV37Layer } from '@aws-cdk/lambda-layer-kubectl-v37';
declare const vpc: ec2.Vpc;

function associateSubnetWithV6Cidr(vpc: ec2.Vpc, count: number, subnet: ec2.ISubnet) {
  const cfnSubnet = subnet.node.defaultChild as ec2.CfnSubnet;
  cfnSubnet.ipv6CidrBlock = Fn.select(count, Fn.cidr(Fn.select(0, vpc.vpcIpv6CidrBlocks), 256, (128 - 64).toString()));
  cfnSubnet.assignIpv6AddressOnCreation = true;
}

// make an ipv6 cidr
const ipv6cidr = new ec2.CfnVPCCidrBlock(this, 'CIDR6', {
  vpcId: vpc.vpcId,
  amazonProvidedIpv6CidrBlock: true,
});

// connect the ipv6 cidr to all vpc subnets
let subnetcount = 0;
const subnets = vpc.publicSubnets.concat(vpc.privateSubnets);
for (let subnet of subnets) {
  // Wait for the ipv6 cidr to complete
  subnet.node.addDependency(ipv6cidr);
  associateSubnetWithV6Cidr(vpc, subnetcount, subnet);
  subnetcount = subnetcount + 1;
}

const cluster = new eks.Cluster(this, 'hello-eks', {
  version: eks.KubernetesVersion.V1_37,
  vpc: vpc,
  ipFamily: eks.IpFamily.IP_V6,
  vpcSubnets: [{ subnets: vpc.publicSubnets }],
  kubectlLayer: new KubectlV37Layer(this, 'kubectl'),
});
python
from aws_cdk.lambda_layer_kubectl_v37 import KubectlV37Layer
# vpc: ec2.Vpc


def associate_subnet_with_v6_cidr(self, vpc, count, subnet):
    cfn_subnet = subnet.node.default_child
    cfn_subnet.ipv6_cidr_block = Fn.select(count, Fn.cidr(Fn.select(0, vpc.vpc_ipv6_cidr_blocks), 256, (128 - 64).to_string()))
    cfn_subnet.assign_ipv6_address_on_creation = True

# make an ipv6 cidr
ipv6cidr = ec2.CfnVPCCidrBlock(self, "CIDR6",
    vpc_id=vpc.vpc_id,
    amazon_provided_ipv6_cidr_block=True
)

# connect the ipv6 cidr to all vpc subnets
subnetcount = 0
subnets = vpc.public_subnets.concat(vpc.private_subnets)
for subnet in subnets:
    # Wait for the ipv6 cidr to complete
    subnet.node.add_dependency(ipv6cidr)
    associate_subnet_with_v6_cidr(vpc, subnetcount, subnet)
    subnetcount = subnetcount + 1

cluster = eks.Cluster(self, "hello-eks",
    version=eks.KubernetesVersion.V1_37,
    vpc=vpc,
    ip_family=eks.IpFamily.IP_V6,
    vpc_subnets=[ec2.SubnetSelection(subnets=vpc.public_subnets)],
    kubectl_layer=KubectlV37Layer(self, "kubectl")
)
java
import software.amazon.awscdk.cdk.lambdalayer.kubectl.v37.KubectlV37Layer;
Vpc vpc;


public void associateSubnetWithV6Cidr(Vpc vpc, Number count, ISubnet subnet) {
    CfnSubnet cfnSubnet = (CfnSubnet)subnet.getNode().getDefaultChild();
    cfnSubnet.getIpv6CidrBlock() = Fn.select(count, Fn.cidr(Fn.select(0, vpc.getVpcIpv6CidrBlocks()), 256, (128 - 64).toString()));
    cfnSubnet.getAssignIpv6AddressOnCreation() = true;
}

// make an ipv6 cidr
CfnVPCCidrBlock ipv6cidr = CfnVPCCidrBlock.Builder.create(this, "CIDR6")
        .vpcId(vpc.getVpcId())
        .amazonProvidedIpv6CidrBlock(true)
        .build();

// connect the ipv6 cidr to all vpc subnets
Number subnetcount = 0;
ISubnet[] subnets = vpc.publicSubnets.concat(vpc.getPrivateSubnets());
for (Object subnet : subnets) {
    // Wait for the ipv6 cidr to complete
    subnet.node.addDependency(ipv6cidr);
    associateSubnetWithV6Cidr(vpc, subnetcount, subnet);
    subnetcount = subnetcount + 1;
}

Cluster cluster = Cluster.Builder.create(this, "hello-eks")
        .version(KubernetesVersion.V1_37)
        .vpc(vpc)
        .ipFamily(IpFamily.IP_V6)
        .vpcSubnets(List.of(SubnetSelection.builder().subnets(vpc.getPublicSubnets()).build()))
        .kubectlLayer(new KubectlV37Layer(this, "kubectl"))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
using Amazon.CDK.LambdaLayer.KubectlV37;
Vpc vpc;


public void AssociateSubnetWithV6Cidr(Vpc vpc, int count, ISubnet subnet)
{
    var cfnSubnet = (CfnSubnet)subnet.Node.DefaultChild;
    cfnSubnet.Ipv6CidrBlock = Fn.Select(count, Fn.Cidr(Fn.Select(0, vpc.VpcIpv6CidrBlocks), 256, (128 - 64).ToString()));
    cfnSubnet.AssignIpv6AddressOnCreation = true;
}

// make an ipv6 cidr
var ipv6cidr = new CfnVPCCidrBlock(this, "CIDR6", new CfnVPCCidrBlockProps {
    VpcId = vpc.VpcId,
    AmazonProvidedIpv6CidrBlock = true
});

// connect the ipv6 cidr to all vpc subnets
var subnetcount = 0;
var subnets = vpc.PublicSubnets.Concat(vpc.PrivateSubnets);
for (var subnet in subnets)
{
    // Wait for the ipv6 cidr to complete
    subnet.Node.AddDependency(ipv6cidr);
    AssociateSubnetWithV6Cidr(vpc, subnetcount, subnet);
    subnetcount = subnetcount + 1;
}

var cluster = new Cluster(this, "hello-eks", new ClusterProps {
    Version = KubernetesVersion.V1_37,
    Vpc = vpc,
    IpFamily = IpFamily.IP_V6,
    VpcSubnets = new [] { new SubnetSelection { Subnets = vpc.PublicSubnets } },
    KubectlLayer = new KubectlV37Layer(this, "kubectl")
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
import "github.com/cdklabs/awscdk-kubectl-go/kubectlv37"
var vpc Vpc


func associateSubnetWithV6Cidr(vpc Vpc, count *f64, subnet ISubnet) {
	cfnSubnet := *subnet.Node.defaultChild.(CfnSubnet)
	cfnSubnet.ipv6CidrBlock = awscdk.Fn_Select(*count, awscdk.Fn_Cidr(awscdk.Fn_Select(jsii.Number(0), *vpc.VpcIpv6CidrBlocks), jsii.Number(256), (jsii.Number(128 - 64)).toString()))
	cfnSubnet.assignIpv6AddressOnCreation = true
}

// make an ipv6 cidr
ipv6cidr := ec2.NewCfnVPCCidrBlock(this, jsii.String("CIDR6"), &CfnVPCCidrBlockProps{
	VpcId: vpc.VpcId,
	AmazonProvidedIpv6CidrBlock: jsii.Boolean(true),
})

// connect the ipv6 cidr to all vpc subnets
subnetcount := 0
subnets := vpc.PublicSubnets.concat(vpc.PrivateSubnets)
for _, subnet := range subnets {
	// Wait for the ipv6 cidr to complete
	subnet.Node.AddDependency(ipv6cidr)
	associateSubnetWithV6Cidr(vpc, subnetcount, subnet)
	subnetcount = subnetcount + 1
}

cluster := eks.NewCluster(this, jsii.String("hello-eks"), &ClusterProps{
	Version: eks.KubernetesVersion_V1_37(),
	Vpc: vpc,
	IpFamily: eks.IpFamily_IP_V6,
	VpcSubnets: []SubnetSelection{
		&SubnetSelection{
			Subnets: vpc.*PublicSubnets,
		},
	},
	KubectlLayer: kubectlv37.NewKubectlV37Layer(this, jsii.String("kubectl")),
})

Properties ​

amazonProvidedIpv6CidrBlockoptionalboolean | IResolvableamazon_provided_ipv6_cidr_blockoptionaltyping.Union[bool, IResolvable]amazonProvidedIpv6CidrBlockoptionalBooleanAmazonProvidedIpv6CidrBlockoptionalboolAmazonProvidedIpv6CidrBlockoptionalinterface{} #
Requests an Amazon-provided IPv6 CIDR block with a /56 prefix length for the VPC.

You cannot specify the range of IPv6 addresses or the size of the CIDR block.

cidrBlockoptionalstringcidr_blockoptionalstrcidrBlockoptionalStringCidrBlockoptionalstringCidrBlockoptional*string #
An IPv4 CIDR block to associate with the VPC.
ipv4IpamPoolIdoptionalstringipv4_ipam_pool_idoptionalstripv4IpamPoolIdoptionalStringIpv4IpamPoolIdoptionalstringIpv4IpamPoolIdoptional*string #
Associate a CIDR allocated from an IPv4 IPAM pool to a VPC.

For more information about Amazon VPC IP Address Manager (IPAM), see What is IPAM? in the Amazon VPC IPAM User Guide .

ipv4NetmaskLengthoptionalnumberipv4_netmask_lengthoptionalint | floatipv4NetmaskLengthoptionalNumberIpv4NetmaskLengthoptionaldoubleIpv4NetmaskLengthoptional*float64 #
The netmask length of the IPv4 CIDR you would like to associate from an Amazon VPC IP Address Manager (IPAM) pool.

For more information about IPAM, see What is IPAM? in the Amazon VPC IPAM User Guide .

ipv6CidrBlockoptionalstringipv6_cidr_blockoptionalstripv6CidrBlockoptionalStringIpv6CidrBlockoptionalstringIpv6CidrBlockoptional*string #
An IPv6 CIDR block from the IPv6 address pool. You must also specify `Ipv6Pool` in the request.

To let Amazon choose the IPv6 CIDR block for you, omit this parameter.

ipv6CidrBlockNetworkBorderGroupoptionalstringipv6_cidr_block_network_border_groupoptionalstripv6CidrBlockNetworkBorderGroupoptionalStringIpv6CidrBlockNetworkBorderGroupoptionalstringIpv6CidrBlockNetworkBorderGroupoptional*string #
The name of the location from which we advertise the IPV6 CIDR block.

Use this parameter to limit the CIDR block to this location.

You must set AmazonProvidedIpv6CidrBlock to true to use this parameter.

You can have one IPv6 CIDR block association per network border group.

ipv6IpamPoolIdoptionalstringipv6_ipam_pool_idoptionalstripv6IpamPoolIdoptionalStringIpv6IpamPoolIdoptionalstringIpv6IpamPoolIdoptional*string #
Associates a CIDR allocated from an IPv6 IPAM pool to a VPC.

For more information about Amazon VPC IP Address Manager (IPAM), see What is IPAM? in the Amazon VPC IPAM User Guide .

ipv6NetmaskLengthoptionalnumberipv6_netmask_lengthoptionalint | floatipv6NetmaskLengthoptionalNumberIpv6NetmaskLengthoptionaldoubleIpv6NetmaskLengthoptional*float64 #
The netmask length of the IPv6 CIDR you would like to associate from an Amazon VPC IP Address Manager (IPAM) pool.

For more information about IPAM, see What is IPAM? in the Amazon VPC IPAM User Guide .

ipv6Pooloptionalstringipv6_pooloptionalstripv6PooloptionalStringIpv6PooloptionalstringIpv6Pooloptional*string #
The ID of an IPv6 address pool from which to allocate the IPv6 CIDR block.
vpcIdstring | IVPCRefvpc_idtyping.Union[str, IVPCRef]vpcIdStringVpcIdstringVpcIdinterface{} required #
The ID of the VPC.