Use CreateNetworkAcl with a CLI - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use CreateNetworkAcl with a CLI

The following code examples show how to use CreateNetworkAcl.

CLI
AWS CLI

To create a network ACL

This example creates a network ACL for the specified VPC.

Command:

aws ec2 create-network-acl --vpc-id vpc-a01106c2

Output:

{ "NetworkAcl": { "Associations": [], "NetworkAclId": "acl-5fb85d36", "VpcId": "vpc-a01106c2", "Tags": [], "Entries": [ { "CidrBlock": "0.0.0.0/0", "RuleNumber": 32767, "Protocol": "-1", "Egress": true, "RuleAction": "deny" }, { "CidrBlock": "0.0.0.0/0", "RuleNumber": 32767, "Protocol": "-1", "Egress": false, "RuleAction": "deny" } ], "IsDefault": false } }
PowerShell
Tools for PowerShell

Example 1: This example creates a network ACL for the specified VPC.

New-EC2NetworkAcl -VpcId vpc-12345678

Output:

Associations : {} Entries : {Amazon.EC2.Model.NetworkAclEntry, Amazon.EC2.Model.NetworkAclEntry} IsDefault : False NetworkAclId : acl-12345678 Tags : {} VpcId : vpc-12345678
  • For API details, see CreateNetworkAcl in AWS Tools for PowerShell Cmdlet Reference.