:doc:`EC2 <../../ec2>` / Client / associate_vpc_cidr_block

************************
associate_vpc_cidr_block
************************



.. py:method:: EC2.Client.associate_vpc_cidr_block(**kwargs)

  

  Associates a CIDR block with your VPC. You can associate a secondary IPv4 CIDR block, an Amazon-provided IPv6 CIDR block, or an IPv6 CIDR block from an IPv6 address pool that you provisioned through bring your own IP addresses ( `BYOIP <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-byoip.html>`__).

   

  You must specify one of the following in the request: an IPv4 CIDR block, an IPv6 pool, or an Amazon-provided IPv6 CIDR block.

   

  For more information about associating CIDR blocks with your VPC and applicable restrictions, see `IP addressing for your VPCs and subnets <https://docs.aws.amazon.com/vpc/latest/userguide/vpc-ip-addressing.html>`__ in the *Amazon VPC User Guide*.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/ec2-2016-11-15/AssociateVpcCidrBlock>`_  


  **Request Syntax**
  ::

    response = client.associate_vpc_cidr_block(
        CidrBlock='string',
        Ipv6CidrBlockNetworkBorderGroup='string',
        Ipv6Pool='string',
        Ipv6CidrBlock='string',
        Ipv4IpamPoolId='string',
        Ipv4NetmaskLength=123,
        Ipv6IpamPoolId='string',
        Ipv6NetmaskLength=123,
        VpcId='string',
        AmazonProvidedIpv6CidrBlock=True|False
    )
    
  :type CidrBlock: string
  :param CidrBlock: 

    An IPv4 CIDR block to associate with the VPC.

    

  
  :type Ipv6CidrBlockNetworkBorderGroup: string
  :param Ipv6CidrBlockNetworkBorderGroup: 

    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.

    

  
  :type Ipv6Pool: string
  :param Ipv6Pool: 

    The ID of an IPv6 address pool from which to allocate the IPv6 CIDR block.

    

  
  :type Ipv6CidrBlock: string
  :param Ipv6CidrBlock: 

    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.

    

  
  :type Ipv4IpamPoolId: string
  :param Ipv4IpamPoolId: 

    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? <https://docs.aws.amazon.com/vpc/latest/ipam/what-is-it-ipam.html>`__ in the *Amazon VPC IPAM User Guide*.

    

  
  :type Ipv4NetmaskLength: integer
  :param Ipv4NetmaskLength: 

    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? <https://docs.aws.amazon.com/vpc/latest/ipam/what-is-it-ipam.html>`__ in the *Amazon VPC IPAM User Guide*.

    

  
  :type Ipv6IpamPoolId: string
  :param Ipv6IpamPoolId: 

    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? <https://docs.aws.amazon.com/vpc/latest/ipam/what-is-it-ipam.html>`__ in the *Amazon VPC IPAM User Guide*.

    

  
  :type Ipv6NetmaskLength: integer
  :param Ipv6NetmaskLength: 

    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? <https://docs.aws.amazon.com/vpc/latest/ipam/what-is-it-ipam.html>`__ in the *Amazon VPC IPAM User Guide*.

    

  
  :type VpcId: string
  :param VpcId: **[REQUIRED]** 

    The ID of the VPC.

    

  
  :type AmazonProvidedIpv6CidrBlock: boolean
  :param AmazonProvidedIpv6CidrBlock: 

    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.

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'Ipv6CidrBlockAssociation': {
              'AssociationId': 'string',
              'Ipv6CidrBlock': 'string',
              'Ipv6CidrBlockState': {
                  'State': 'associating'|'associated'|'disassociating'|'disassociated'|'failing'|'failed',
                  'StatusMessage': 'string'
              },
              'NetworkBorderGroup': 'string',
              'Ipv6Pool': 'string',
              'Ipv6AddressAttribute': 'public'|'private',
              'IpSource': 'amazon'|'byoip'|'none'
          },
          'CidrBlockAssociation': {
              'AssociationId': 'string',
              'CidrBlock': 'string',
              'CidrBlockState': {
                  'State': 'associating'|'associated'|'disassociating'|'disassociated'|'failing'|'failed',
                  'StatusMessage': 'string'
              }
          },
          'VpcId': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **Ipv6CidrBlockAssociation** *(dict) --* 

        Information about the IPv6 CIDR block association.

        
        

        - **AssociationId** *(string) --* 

          The association ID for the IPv6 CIDR block.

          
        

        - **Ipv6CidrBlock** *(string) --* 

          The IPv6 CIDR block.

          
        

        - **Ipv6CidrBlockState** *(dict) --* 

          Information about the state of the CIDR block.

          
          

          - **State** *(string) --* 

            The state of the CIDR block.

            
          

          - **StatusMessage** *(string) --* 

            A message about the status of the CIDR block, if applicable.

            
      
        

        - **NetworkBorderGroup** *(string) --* 

          The name of the unique set of Availability Zones, Local Zones, or Wavelength Zones from which Amazon Web Services advertises IP addresses, for example, ``us-east-1-wl1-bos-wlz-1``.

          
        

        - **Ipv6Pool** *(string) --* 

          The ID of the IPv6 address pool from which the IPv6 CIDR block is allocated.

          
        

        - **Ipv6AddressAttribute** *(string) --* 

          Public IPv6 addresses are those advertised on the internet from Amazon Web Services. Private IP addresses are not and cannot be advertised on the internet from Amazon Web Services.

          
        

        - **IpSource** *(string) --* 

          The source that allocated the IP address space. ``byoip`` or ``amazon`` indicates public IP address space allocated by Amazon or space that you have allocated with Bring your own IP (BYOIP). ``none`` indicates private space.

          
    
      

      - **CidrBlockAssociation** *(dict) --* 

        Information about the IPv4 CIDR block association.

        
        

        - **AssociationId** *(string) --* 

          The association ID for the IPv4 CIDR block.

          
        

        - **CidrBlock** *(string) --* 

          The IPv4 CIDR block.

          
        

        - **CidrBlockState** *(dict) --* 

          Information about the state of the CIDR block.

          
          

          - **State** *(string) --* 

            The state of the CIDR block.

            
          

          - **StatusMessage** *(string) --* 

            A message about the status of the CIDR block, if applicable.

            
      
    
      

      - **VpcId** *(string) --* 

        The ID of the VPC.

        
  