Skip to content

modify_vpc_attribute

modify_vpc_attribute(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    enable_dns_hostnames: Optional[AttributeBooleanValue] = None,
    enable_dns_support: Optional[AttributeBooleanValue] = None,
    vpc_id: Optional[VpcId] = None,
    enable_network_address_usage_metrics: Optional[AttributeBooleanValue] = None,
) -> None

Modifies the specified attribute of the specified VPC.

Parameters:

  • enable_dns_hostnames (Optional[AttributeBooleanValue], default: None ) –

    Indicates whether the instances launched in the VPC get DNS hostnames. If enabled, instances in the VPC get DNS hostnames; otherwise, they do not.

    You cannot modify the DNS resolution and DNS hostnames attributes in the same request. Use separate requests for each attribute. You can only enable DNS hostnames if you've enabled DNS support.

  • enable_dns_support (Optional[AttributeBooleanValue], default: None ) –

    Indicates whether the DNS resolution is supported for the VPC. If enabled, queries to the Amazon provided DNS server at the 169.254.169.253 IP address, or the reserved IP address at the base of the VPC network range "plus two" succeed. If disabled, the Amazon provided DNS service in the VPC that resolves public DNS hostnames to IP addresses is not enabled.

    You cannot modify the DNS resolution and DNS hostnames attributes in the same request. Use separate requests for each attribute.

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

    The ID of the VPC.

  • enable_network_address_usage_metrics (Optional[AttributeBooleanValue], default: None ) –

    Indicates whether Network Address Usage metrics are enabled for your VPC.

Raises:

Examples:

To modify the enableDnsSupport attribute This example modifies the enableDnsSupport attribute. This attribute indicates whether DNS resolution is enabled for the VPC. If this attribute is true, the Amazon DNS server resolves DNS hostnames for instances in the VPC to their corresponding IP addresses; otherwise, it does not.

>>> client.modify_vpc_attribute(vpc_id='vpc-a01106c2', enable_dns_support={'Value': False})
To modify the enableDnsHostnames attribute
This example modifies the enableDnsHostnames attribute. This attribute indicates whether instances launched in the VPC get DNS hostnames. If this attribute is true, instances in the VPC get DNS hostnames; otherwise, they do not.
>>> client.modify_vpc_attribute(vpc_id='vpc-a01106c2', enable_dns_hostnames={'Value': False})
Source code in docs_src/capo_ec2/_services/ec2.py
def modify_vpc_attribute(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    enable_dns_hostnames: Optional[
        "capo_ec2.types.attribute_boolean_value.AttributeBooleanValue"
    ] = None,
    enable_dns_support: Optional[
        "capo_ec2.types.attribute_boolean_value.AttributeBooleanValue"
    ] = None,
    vpc_id: Optional["capo_ec2.types.vpc_id.VpcId"] = None,
    enable_network_address_usage_metrics: Optional[
        "capo_ec2.types.attribute_boolean_value.AttributeBooleanValue"
    ] = None,
) -> None:
    """<p>Modifies the specified attribute of the specified VPC.</p>

    Args:
        enable_dns_hostnames: <p>Indicates whether the instances launched in the VPC get DNS hostnames. If enabled, instances in the VPC get DNS hostnames; otherwise, they do not.</p> <p>You cannot modify the DNS resolution and DNS hostnames attributes in the same request. Use separate requests for each attribute. You can only enable DNS hostnames if you've enabled DNS support.</p>
        enable_dns_support: <p>Indicates whether the DNS resolution is supported for the VPC. If enabled, queries to the Amazon provided DNS server at the 169.254.169.253 IP address, or the reserved IP address at the base of the VPC network range "plus two" succeed. If disabled, the Amazon provided DNS service in the VPC that resolves public DNS hostnames to IP addresses is not enabled.</p> <p>You cannot modify the DNS resolution and DNS hostnames attributes in the same request. Use separate requests for each attribute.</p>
        vpc_id: <p>The ID of the VPC.</p>
        enable_network_address_usage_metrics: <p>Indicates whether Network Address Usage metrics are enabled for your VPC.</p>

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

    Examples:
        To modify the enableDnsSupport attribute
        This example modifies the enableDnsSupport attribute. This attribute indicates whether DNS resolution is enabled for the VPC. If this attribute is true, the Amazon DNS server resolves DNS hostnames for instances in the VPC to their corresponding IP addresses; otherwise, it does not.

        >>> client.modify_vpc_attribute(vpc_id='vpc-a01106c2', enable_dns_support={'Value': False})
        To modify the enableDnsHostnames attribute
        This example modifies the enableDnsHostnames attribute. This attribute indicates whether instances launched in the VPC get DNS hostnames. If this attribute is true, instances in the VPC get DNS hostnames; otherwise, they do not.

        >>> client.modify_vpc_attribute(vpc_id='vpc-a01106c2', enable_dns_hostnames={'Value': False})
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.modify_vpc_attribute_request.ModifyVpcAttributeRequest]",
    ) -> OperationResponse[None]:
        import capo_ec2._operations.amazon_ec2.modify_vpc_attribute

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ModifyVpcAttribute")
    )
    input_: capo_ec2.types.modify_vpc_attribute_request.ModifyVpcAttributeRequest = {}
    if enable_dns_hostnames is not None:
        input_["enable_dns_hostnames"] = enable_dns_hostnames
    if enable_dns_support is not None:
        input_["enable_dns_support"] = enable_dns_support
    if vpc_id is not None:
        input_["vpc_id"] = vpc_id
    if enable_network_address_usage_metrics is not None:
        input_["enable_network_address_usage_metrics"] = (
            enable_network_address_usage_metrics
        )

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