Skip to content

associate_vpc_cidr_block

associate_vpc_cidr_block(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    cidr_block: Optional[String] = None,
    ipv6_cidr_block_network_border_group: Optional[String] = None,
    ipv6_pool: Optional[Ipv6PoolEc2Id] = None,
    ipv6_cidr_block: Optional[String] = None,
    ipv4_ipam_pool_id: Optional[IpamPoolId] = None,
    ipv4_netmask_length: Optional[NetmaskLength] = None,
    ipv6_ipam_pool_id: Optional[IpamPoolId] = None,
    ipv6_netmask_length: Optional[NetmaskLength] = None,
    vpc_id: Optional[VpcId] = None,
    amazon_provided_ipv6_cidr_block: Optional[Boolean] = None,
) -> AssociateVpcCidrBlockResult

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).

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 in the Amazon VPC User Guide.

Parameters:

  • cidr_block (Optional[String], default: None ) –

    An IPv4 CIDR block to associate with the VPC.

  • ipv6_cidr_block_network_border_group (Optional[String], default: None ) –

    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.

  • ipv6_pool (Optional[Ipv6PoolEc2Id], default: None ) –

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

  • ipv6_cidr_block (Optional[String], default: None ) –

    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.

  • ipv4_ipam_pool_id (Optional[IpamPoolId], default: None ) –

    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.

  • ipv4_netmask_length (Optional[NetmaskLength], default: None ) –

    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.

  • ipv6_ipam_pool_id (Optional[IpamPoolId], default: None ) –

    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.

  • ipv6_netmask_length (Optional[NetmaskLength], default: None ) –

    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.

  • vpc_id (Optional[VpcId], default: None ) –

    The ID of the VPC.

  • amazon_provided_ipv6_cidr_block (Optional[Boolean], default: None ) –

    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.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def associate_vpc_cidr_block(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    cidr_block: Optional["capo_ec2.types.string.String"] = None,
    ipv6_cidr_block_network_border_group: Optional[
        "capo_ec2.types.string.String"
    ] = None,
    ipv6_pool: Optional["capo_ec2.types.ipv6_pool_ec2_id.Ipv6PoolEc2Id"] = None,
    ipv6_cidr_block: Optional["capo_ec2.types.string.String"] = None,
    ipv4_ipam_pool_id: Optional["capo_ec2.types.ipam_pool_id.IpamPoolId"] = None,
    ipv4_netmask_length: Optional[
        "capo_ec2.types.netmask_length.NetmaskLength"
    ] = None,
    ipv6_ipam_pool_id: Optional["capo_ec2.types.ipam_pool_id.IpamPoolId"] = None,
    ipv6_netmask_length: Optional[
        "capo_ec2.types.netmask_length.NetmaskLength"
    ] = None,
    vpc_id: Optional["capo_ec2.types.vpc_id.VpcId"] = None,
    amazon_provided_ipv6_cidr_block: Optional[
        "capo_ec2.types.boolean.Boolean"
    ] = None,
) -> "capo_ec2.types.associate_vpc_cidr_block_result.AssociateVpcCidrBlockResult":
    """<p>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 (<a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-byoip.html">BYOIP</a>).</p> <p>You must specify one of the following in the request: an IPv4 CIDR block, an IPv6 pool, or an Amazon-provided IPv6 CIDR block.</p> <p>For more information about associating CIDR blocks with your VPC and applicable restrictions, see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-ip-addressing.html">IP addressing for your VPCs and subnets</a> in the <i>Amazon VPC User Guide</i>.</p>

    Args:
        cidr_block: <p>An IPv4 CIDR block to associate with the VPC.</p>
        ipv6_cidr_block_network_border_group: <p>The name of the location from which we advertise the IPV6 CIDR block. Use this parameter to limit the CIDR block to this location.</p> <p> You must set <code>AmazonProvidedIpv6CidrBlock</code> to <code>true</code> to use this parameter.</p> <p> You can have one IPv6 CIDR block association per network border group.</p>
        ipv6_pool: <p>The ID of an IPv6 address pool from which to allocate the IPv6 CIDR block.</p>
        ipv6_cidr_block: <p>An IPv6 CIDR block from the IPv6 address pool. You must also specify <code>Ipv6Pool</code> in the request.</p> <p>To let Amazon choose the IPv6 CIDR block for you, omit this parameter.</p>
        ipv4_ipam_pool_id: <p>Associate a CIDR allocated from an IPv4 IPAM pool to a VPC. For more information about Amazon VPC IP Address Manager (IPAM), see <a href="https://docs.aws.amazon.com/vpc/latest/ipam/what-is-it-ipam.html">What is IPAM?</a> in the <i>Amazon VPC IPAM User Guide</i>.</p>
        ipv4_netmask_length: <p>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 <a href="https://docs.aws.amazon.com/vpc/latest/ipam/what-is-it-ipam.html">What is IPAM?</a> in the <i>Amazon VPC IPAM User Guide</i>. </p>
        ipv6_ipam_pool_id: <p>Associates a CIDR allocated from an IPv6 IPAM pool to a VPC. For more information about Amazon VPC IP Address Manager (IPAM), see <a href="https://docs.aws.amazon.com/vpc/latest/ipam/what-is-it-ipam.html">What is IPAM?</a> in the <i>Amazon VPC IPAM User Guide</i>.</p>
        ipv6_netmask_length: <p>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 <a href="https://docs.aws.amazon.com/vpc/latest/ipam/what-is-it-ipam.html">What is IPAM?</a> in the <i>Amazon VPC IPAM User Guide</i>. </p>
        vpc_id: <p>The ID of the VPC.</p>
        amazon_provided_ipv6_cidr_block: <p>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.</p>

    Raises:
        capo_ec2.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.associate_vpc_cidr_block_request.AssociateVpcCidrBlockRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.associate_vpc_cidr_block_result.AssociateVpcCidrBlockResult"
    ]:
        import capo_ec2._operations.amazon_ec2.associate_vpc_cidr_block

        output, http_response = (
            capo_ec2._operations.amazon_ec2.associate_vpc_cidr_block.associate_vpc_cidr_block(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("AssociateVpcCidrBlock")
    )
    input_: capo_ec2.types.associate_vpc_cidr_block_request.AssociateVpcCidrBlockRequest = {}
    if cidr_block is not None:
        input_["cidr_block"] = cidr_block
    if ipv6_cidr_block_network_border_group is not None:
        input_["ipv6_cidr_block_network_border_group"] = (
            ipv6_cidr_block_network_border_group
        )
    if ipv6_pool is not None:
        input_["ipv6_pool"] = ipv6_pool
    if ipv6_cidr_block is not None:
        input_["ipv6_cidr_block"] = ipv6_cidr_block
    if ipv4_ipam_pool_id is not None:
        input_["ipv4_ipam_pool_id"] = ipv4_ipam_pool_id
    if ipv4_netmask_length is not None:
        input_["ipv4_netmask_length"] = ipv4_netmask_length
    if ipv6_ipam_pool_id is not None:
        input_["ipv6_ipam_pool_id"] = ipv6_ipam_pool_id
    if ipv6_netmask_length is not None:
        input_["ipv6_netmask_length"] = ipv6_netmask_length
    if vpc_id is not None:
        input_["vpc_id"] = vpc_id
    if amazon_provided_ipv6_cidr_block is not None:
        input_["amazon_provided_ipv6_cidr_block"] = amazon_provided_ipv6_cidr_block

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output