NetworkAcl
The NetworkAcl resource allows you to manage AWS EC2 Network Acls for controlling inbound and outbound traffic to and from your subnets.
Minimal Example
Section titled “Minimal Example”Create a basic NetworkAcl in a specified VPC with a tag.
import AWS from "alchemy/aws/control";
const basicNetworkAcl = await AWS.EC2.NetworkAcl("basicNetworkAcl", { VpcId: "vpc-123abc45", Tags: [{ Key: "Name", Value: "BasicNetworkAcl" }]});
Advanced Configuration
Section titled “Advanced Configuration”Configure a NetworkAcl with additional tags and adopt existing resources.
const advancedNetworkAcl = await AWS.EC2.NetworkAcl("advancedNetworkAcl", { VpcId: "vpc-678def90", Tags: [ { Key: "Environment", Value: "Production" }, { Key: "Department", Value: "IT" } ], adopt: true});
Example with Security Rules
Section titled “Example with Security Rules”Create a NetworkAcl that includes specific traffic rules for inbound and outbound access.
const secureNetworkAcl = await AWS.EC2.NetworkAcl("secureNetworkAcl", { VpcId: "vpc-abc123de", Tags: [{ Key: "Name", Value: "SecureNetworkAcl" }], Rules: [ { RuleAction: "allow", RuleNumber: 100, Protocol: "tcp", PortRange: { From: 22, To: 22 }, CidrBlock: "0.0.0.0/0", Egress: false }, { RuleAction: "allow", RuleNumber: 101, Protocol: "tcp", PortRange: { From: 80, To: 80 }, CidrBlock: "0.0.0.0/0", Egress: true }, { RuleAction: "deny", RuleNumber: 102, Protocol: "-1", CidrBlock: "0.0.0.0/0", Egress: false } ]});
Adoption of Existing NetworkAcl
Section titled “Adoption of Existing NetworkAcl”Adopt an existing NetworkAcl with the option to manage it through Alchemy.
const adoptExistingNetworkAcl = await AWS.EC2.NetworkAcl("adoptNetworkAcl", { VpcId: "vpc-existing-01", adopt: true});