AWS Amazon EC2 IPv4 Cidr Block Association

This page shows how to write Terraform and CloudFormation for Amazon EC2 IPv4 Cidr Block Association and write them securely.

aws_vpc_ipv4_cidr_block_association (Terraform)

The IPv4 Cidr Block Association in Amazon EC2 can be configured in Terraform with the resource name aws_vpc_ipv4_cidr_block_association. The following sections describe 2 examples of how to use the resource and its parameters.

Example Usage from GitHub

c3-vpc-instance.tf#L11
resource "aws_vpc_ipv4_cidr_block_association" "secondary_cidr" {
  vpc_id     = aws_vpc.main.id
  cidr_block = "10.0.1.0/16"
}
resource "aws_vpc_ipv4_cidr_block_association" "secondary_cidr" {
  vpc_id     = aws_vpc.main.id
20-vpc.tf#L9
resource "aws_vpc_ipv4_cidr_block_association" "cidr2" {
  vpc_id     = aws_vpc.vpc1.id
  cidr_block = "172.2.0.0/16"
}

# nie chce tego przyjac

Parameters

Explanation in Terraform Registry

Provides a resource to associate additional IPv4 CIDR blocks with a VPC. When a VPC is created, a primary IPv4 CIDR block for the VPC must be specified. The aws_vpc_ipv4_cidr_block_association resource allows further IPv4 CIDR blocks to be added to the VPC.

AWS::EC2::VPCCidrBlock (CloudFormation)

The VPCCidrBlock in EC2 can be configured in CloudFormation with the resource name AWS::EC2::VPCCidrBlock. The following sections describe 10 examples of how to use the resource and its parameters.

Example Usage from GitHub

base-vpc-example-improved.template.yml#L71
    Type: AWS::EC2::VPCCidrBlock
    Properties:
      CidrBlock: !GetAtt CidrGenerator.VpcCidrExtra1
      VpcId: !Ref VPC

  VPCExtraBlock2:
ec2_networkaclentry_protocol_icmpv6.yml#L11
    Type: AWS::EC2::VPCCidrBlock
    Properties:
      AmazonProvidedIpv6CidrBlock: true
      VpcId: !Ref myVPC
  myNetworkAcl:
    Type: AWS::EC2::NetworkAcl
ec2_networkaclentry_deny_full_ipv6_cidr_range.yml#L11
    Type: AWS::EC2::VPCCidrBlock
    Properties:
      AmazonProvidedIpv6CidrBlock: true
      VpcId: !Ref myVPC
  myNetworkAcl:
    Type: AWS::EC2::NetworkAcl
ec2_networkaclentry_protocol_icmpv6_missing_icmp.yml#L11
    Type: AWS::EC2::VPCCidrBlock
    Properties:
      AmazonProvidedIpv6CidrBlock: true
      VpcId: !Ref myVPC
  myNetworkAcl:
    Type: AWS::EC2::NetworkAcl
create-vpc.yml#L10
    Type: AWS::EC2::VPCCidrBlock
    Properties:
      AmazonProvidedIpv6CidrBlock: true
#      CidrBlock: 10.0.0.0/16
#      VpcId: vpc-036dd04db74375617
      VpcId: !Ref JKFirstCFVPC
Ec2VpcCidrBlockSpecification.json#L3
    "AWS::EC2::VPCCidrBlock": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpccidrblock.html",
      "Properties": {
        "AmazonProvidedIpv6CidrBlock": {
          "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpccidrblock.html#cfn-ec2-vpccidrblock-amazonprovidedipv6cidrblock",
          "PrimitiveType": "Boolean",
Ec2VpcCidrBlockSpecification.json#L3
    "AWS::EC2::VPCCidrBlock": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpccidrblock.html",
      "Properties": {
        "AmazonProvidedIpv6CidrBlock": {
          "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpccidrblock.html#cfn-ec2-vpccidrblock-amazonprovidedipv6cidrblock",
          "PrimitiveType": "Boolean",
Ec2VpcCidrBlockSpecification.json#L3
    "AWS::EC2::VPCCidrBlock": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpccidrblock.html",
      "Properties": {
        "AmazonProvidedIpv6CidrBlock": {
          "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpccidrblock.html#cfn-ec2-vpccidrblock-amazonprovidedipv6cidrblock",
          "PrimitiveType": "Boolean",
EC2VPCCidrBlockSpecification.json#L3
    "AWS::EC2::VPCCidrBlock": {
      "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpccidrblock.html",
      "Properties": {
        "AmazonProvidedIpv6CidrBlock": {
          "Documentation": "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-vpccidrblock.html#cfn-ec2-vpccidrblock-amazonprovidedipv6cidrblock",
          "PrimitiveType": "Boolean",
cidr.json#L12
        "Type" : "AWS::EC2::VPCCidrBlock",
        "Properties" : {
          "AmazonProvidedIpv6CidrBlock" : true,
          "VpcId" : { "Ref" : "ExampleVpc" }
        }
      },

Parameters

Explanation in CloudFormation Registry

Associates a CIDR block with your VPC. You can only associate a single IPv6 CIDR block with your VPC. The IPv6 CIDR block size is fixed at /56.

For more information about associating CIDR blocks with your VPC and applicable restrictions, see VPC and Subnet Sizing in the Amazon Virtual Private Cloud User Guide.

Frequently asked questions

What is AWS Amazon EC2 IPv4 Cidr Block Association?

AWS Amazon EC2 IPv4 Cidr Block Association is a resource for Amazon EC2 of Amazon Web Service. Settings can be wrote in Terraform and CloudFormation.

Where can I find the example code for the AWS Amazon EC2 IPv4 Cidr Block Association?

For Terraform, the karkarbhautik/certified-terraform-associate and lukdeboss/aws_tf source code examples are useful. See the Terraform Example section for further details.

For CloudFormation, the kennyk65/aws-teaching-demos, stelligent/cfn_nag and stelligent/cfn_nag source code examples are useful. See the CloudFormation Example section for further details.