Skip to content

create_network_acl

create_network_acl(
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    tag_specifications: Optional[TagSpecificationList] = None,
    client_token: Optional[String] = None,
    dry_run: Optional[Boolean] = None,
    vpc_id: Optional[VpcId] = None,
) -> CreateNetworkAclResult

Creates a network ACL in a VPC. Network ACLs provide an optional layer of security (in addition to security groups) for the instances in your VPC.

For more information, see Network ACLs in the Amazon VPC User Guide.

Parameters:

  • tag_specifications (Optional[TagSpecificationList], default: None ) –

    The tags to assign to the network ACL.

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

    Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see Ensuring idempotency.

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

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

    The ID of the VPC.

Raises:

Examples:

To create a network ACL This example creates a network ACL for the specified VPC.

>>> client.create_network_acl(vpc_id='vpc-a01106c2')
Source code in docs_src/capo_ec2/_services/ec2.py
def create_network_acl(
    self,
    *,
    config_overrides: Optional[EC2ClientConfig] = None,
    tag_specifications: Optional[
        "capo_ec2.types.tag_specification_list.TagSpecificationList"
    ] = None,
    client_token: Optional["capo_ec2.types.string.String"] = None,
    dry_run: Optional["capo_ec2.types.boolean.Boolean"] = None,
    vpc_id: Optional["capo_ec2.types.vpc_id.VpcId"] = None,
) -> "capo_ec2.types.create_network_acl_result.CreateNetworkAclResult":
    """<p>Creates a network ACL in a VPC. Network ACLs provide an optional layer of security (in addition to security groups) for the instances in your VPC.</p> <p>For more information, see <a href="https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html">Network ACLs</a> in the <i>Amazon VPC User Guide</i>.</p>

    Args:
        tag_specifications: <p>The tags to assign to the network ACL.</p>
        client_token: <p>Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see <a href="https://docs.aws.amazon.com/ec2/latest/devguide/ec2-api-idempotency.html">Ensuring idempotency</a>.</p>
        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>
        vpc_id: <p>The ID of the VPC.</p>

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

    Examples:
        To create a network ACL
        This example creates a network ACL for the specified VPC.

        >>> client.create_network_acl(vpc_id='vpc-a01106c2')
    """

    def _handler(
        req: "OperationRequest[capo_ec2.types.create_network_acl_request.CreateNetworkAclRequest]",
    ) -> OperationResponse[
        "capo_ec2.types.create_network_acl_result.CreateNetworkAclResult"
    ]:
        import capo_ec2._operations.amazon_ec2.create_network_acl

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

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateNetworkAcl")
    )
    input_: capo_ec2.types.create_network_acl_request.CreateNetworkAclRequest = {}
    if tag_specifications is not None:
        input_["tag_specifications"] = tag_specifications
    if client_token is None:
        client_token = str(uuid.uuid4())
    input_["client_token"] = client_token
    if dry_run is not None:
        input_["dry_run"] = dry_run
    if vpc_id is not None:
        input_["vpc_id"] = vpc_id

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