Skip to content

modify_vpc_block_public_access_options

modify_vpc_block_public_access_options(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    dry_run: Optional[Boolean] = None,
    internet_gateway_block_mode: Optional[InternetGatewayBlockMode] = None,
) -> ModifyVpcBlockPublicAccessOptionsResult

Modify VPC Block Public Access (BPA) options. VPC Block Public Access (BPA) enables you to block resources in VPCs and subnets that you own in a Region from reaching or being reached from the internet through internet gateways and egress-only internet gateways. To learn more about VPC BPA, see Block public access to VPCs and subnets in the Amazon VPC User Guide.

Parameters:

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

    Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • internet_gateway_block_mode (Optional[InternetGatewayBlockMode], default: None ) –

    The mode of VPC BPA.

    • off: VPC BPA is not enabled and traffic is allowed to and from internet gateways and egress-only internet gateways in this Region.

    • block-bidirectional: Block all traffic to and from internet gateways and egress-only internet gateways in this Region (except for excluded VPCs and subnets).

    • block-ingress: Block all internet traffic to the VPCs in this Region (except for VPCs or subnets which are excluded). Only traffic to and from NAT gateways and egress-only internet gateways is allowed because these gateways only allow outbound connections to be established.

Raises:

Source code in docs_src/capo_ec2/_services/ec2.py
def modify_vpc_block_public_access_options(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    internet_gateway_block_mode: Optional[
        "capo_ec2.types.internet_gateway_block_mode.InternetGatewayBlockMode"
    ] = None,
) -> "capo_ec2.types.modify_vpc_block_public_access_options_result.ModifyVpcBlockPublicAccessOptionsResult":
    """<p>Modify VPC Block Public Access (BPA) options. VPC Block Public Access (BPA) enables you to block resources in VPCs and subnets that you own in a Region from reaching or being reached from the internet through internet gateways and egress-only internet gateways. To learn more about VPC BPA, see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/security-vpc-bpa.html">Block public access to VPCs and subnets</a> in the <i>Amazon VPC User Guide</i>.</p>

    Args:
        dry_run: <p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>
        internet_gateway_block_mode: <p>The mode of VPC BPA.</p> <ul> <li> <p> <code>off</code>: VPC BPA is not enabled and traffic is allowed to and from internet gateways and egress-only internet gateways in this Region.</p> </li> <li> <p> <code>block-bidirectional</code>: Block all traffic to and from internet gateways and egress-only internet gateways in this Region (except for excluded VPCs and subnets).</p> </li> <li> <p> <code>block-ingress</code>: Block all internet traffic to the VPCs in this Region (except for VPCs or subnets which are excluded). Only traffic to and from NAT gateways and egress-only internet gateways is allowed because these gateways only allow outbound connections to be established.</p> </li> </ul>

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

    def _handler(
        req: "OperationRequest[capo_ec2.types.modify_vpc_block_public_access_options_request.ModifyVpcBlockPublicAccessOptionsRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.modify_vpc_block_public_access_options_result.ModifyVpcBlockPublicAccessOptionsResult"
    ]:
        import capo_ec2._operations.amazon_ec2.modify_vpc_block_public_access_options

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ModifyVpcBlockPublicAccessOptions")
    )
    input_: capo_ec2.types.modify_vpc_block_public_access_options_request.ModifyVpcBlockPublicAccessOptionsRequest = {}
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if internet_gateway_block_mode is not None:
        input_["internet_gateway_block_mode"] = internet_gateway_block_mode

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