NetworkAcl

Provides an network ACL resource. You might set up network ACLs with rules similar to your security groups in order to add an additional layer of security to your VPC.

NOTE on Network ACLs and Network ACL Rules: This provider currently provides both a standalone Network ACL Rule resource and a Network ACL resource with rules defined in-line. At this time you cannot use a Network ACL with in-line rules in conjunction with any Network ACL Rule resources. Doing so will cause a conflict of rule settings and will overwrite rules.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var main = new Aws.Ec2.NetworkAcl("main", new Aws.Ec2.NetworkAclArgs
        {
            VpcId = aws_vpc.Main.Id,
            Egress = 
            {
                new Aws.Ec2.Inputs.NetworkAclEgressArgs
                {
                    Protocol = "tcp",
                    RuleNo = 200,
                    Action = "allow",
                    CidrBlock = "10.3.0.0/18",
                    FromPort = 443,
                    ToPort = 443,
                },
            },
            Ingress = 
            {
                new Aws.Ec2.Inputs.NetworkAclIngressArgs
                {
                    Protocol = "tcp",
                    RuleNo = 100,
                    Action = "allow",
                    CidrBlock = "10.3.0.0/18",
                    FromPort = 80,
                    ToPort = 80,
                },
            },
            Tags = 
            {
                { "Name", "main" },
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ec2.NewNetworkAcl(ctx, "main", &ec2.NetworkAclArgs{
			VpcId: pulumi.Any(aws_vpc.Main.Id),
			Egress: ec2.NetworkAclEgressArray{
				&ec2.NetworkAclEgressArgs{
					Protocol:  pulumi.String("tcp"),
					RuleNo:    pulumi.Int(200),
					Action:    pulumi.String("allow"),
					CidrBlock: pulumi.String("10.3.0.0/18"),
					FromPort:  pulumi.Int(443),
					ToPort:    pulumi.Int(443),
				},
			},
			Ingress: ec2.NetworkAclIngressArray{
				&ec2.NetworkAclIngressArgs{
					Protocol:  pulumi.String("tcp"),
					RuleNo:    pulumi.Int(100),
					Action:    pulumi.String("allow"),
					CidrBlock: pulumi.String("10.3.0.0/18"),
					FromPort:  pulumi.Int(80),
					ToPort:    pulumi.Int(80),
				},
			},
			Tags: pulumi.StringMap{
				"Name": pulumi.String("main"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_aws as aws

main = aws.ec2.NetworkAcl("main",
    vpc_id=aws_vpc["main"]["id"],
    egress=[aws.ec2.NetworkAclEgressArgs(
        protocol="tcp",
        rule_no=200,
        action="allow",
        cidr_block="10.3.0.0/18",
        from_port=443,
        to_port=443,
    )],
    ingress=[aws.ec2.NetworkAclIngressArgs(
        protocol="tcp",
        rule_no=100,
        action="allow",
        cidr_block="10.3.0.0/18",
        from_port=80,
        to_port=80,
    )],
    tags={
        "Name": "main",
    })
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const main = new aws.ec2.NetworkAcl("main", {
    vpcId: aws_vpc.main.id,
    egress: [{
        protocol: "tcp",
        ruleNo: 200,
        action: "allow",
        cidrBlock: "10.3.0.0/18",
        fromPort: 443,
        toPort: 443,
    }],
    ingress: [{
        protocol: "tcp",
        ruleNo: 100,
        action: "allow",
        cidrBlock: "10.3.0.0/18",
        fromPort: 80,
        toPort: 80,
    }],
    tags: {
        Name: "main",
    },
});

Create a NetworkAcl Resource

new NetworkAcl(name: string, args: NetworkAclArgs, opts?: CustomResourceOptions);
@overload
def NetworkAcl(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               egress: Optional[Sequence[NetworkAclEgressArgs]] = None,
               ingress: Optional[Sequence[NetworkAclIngressArgs]] = None,
               subnet_ids: Optional[Sequence[str]] = None,
               tags: Optional[Mapping[str, str]] = None,
               tags_all: Optional[Mapping[str, str]] = None,
               vpc_id: Optional[str] = None)
@overload
def NetworkAcl(resource_name: str,
               args: NetworkAclArgs,
               opts: Optional[ResourceOptions] = None)
func NewNetworkAcl(ctx *Context, name string, args NetworkAclArgs, opts ...ResourceOption) (*NetworkAcl, error)
public NetworkAcl(string name, NetworkAclArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args NetworkAclArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name str
The unique name of the resource.
args NetworkAclArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name string
The unique name of the resource.
args NetworkAclArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args NetworkAclArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

NetworkAcl Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.

Inputs

The NetworkAcl resource accepts the following input properties:

VpcId string
The ID of the associated VPC.
Egress List<NetworkAclEgressArgs>
Specifies an egress rule. Parameters defined below.
Ingress List<NetworkAclIngressArgs>
Specifies an ingress rule. Parameters defined below.
SubnetIds List<string>
A list of Subnet IDs to apply the ACL to
Tags Dictionary<string, string>
A mapping of tags to assign to the resource.
TagsAll Dictionary<string, string>
A map of tags assigned to the resource, including those inherited from the provider.
VpcId string
The ID of the associated VPC.
Egress []NetworkAclEgress
Specifies an egress rule. Parameters defined below.
Ingress []NetworkAclIngress
Specifies an ingress rule. Parameters defined below.
SubnetIds []string
A list of Subnet IDs to apply the ACL to
Tags map[string]string
A mapping of tags to assign to the resource.
TagsAll map[string]string
A map of tags assigned to the resource, including those inherited from the provider.
vpcId string
The ID of the associated VPC.
egress NetworkAclEgressArgs[]
Specifies an egress rule. Parameters defined below.
ingress NetworkAclIngressArgs[]
Specifies an ingress rule. Parameters defined below.
subnetIds string[]
A list of Subnet IDs to apply the ACL to
tags {[key: string]: string}
A mapping of tags to assign to the resource.
tagsAll {[key: string]: string}
A map of tags assigned to the resource, including those inherited from the provider.
vpc_id str
The ID of the associated VPC.
egress Sequence[NetworkAclEgressArgs]
Specifies an egress rule. Parameters defined below.
ingress Sequence[NetworkAclIngressArgs]
Specifies an ingress rule. Parameters defined below.
subnet_ids Sequence[str]
A list of Subnet IDs to apply the ACL to
tags Mapping[str, str]
A mapping of tags to assign to the resource.
tags_all Mapping[str, str]
A map of tags assigned to the resource, including those inherited from the provider.

Outputs

All input properties are implicitly available as output properties. Additionally, the NetworkAcl resource produces the following output properties:

Arn string
The ARN of the network ACL
Id string
The provider-assigned unique ID for this managed resource.
OwnerId string
The ID of the AWS account that owns the network ACL.
Arn string
The ARN of the network ACL
Id string
The provider-assigned unique ID for this managed resource.
OwnerId string
The ID of the AWS account that owns the network ACL.
arn string
The ARN of the network ACL
id string
The provider-assigned unique ID for this managed resource.
ownerId string
The ID of the AWS account that owns the network ACL.
arn str
The ARN of the network ACL
id str
The provider-assigned unique ID for this managed resource.
owner_id str
The ID of the AWS account that owns the network ACL.

Look up an Existing NetworkAcl Resource

Get an existing NetworkAcl resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: NetworkAclState, opts?: CustomResourceOptions): NetworkAcl
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        arn: Optional[str] = None,
        egress: Optional[Sequence[NetworkAclEgressArgs]] = None,
        ingress: Optional[Sequence[NetworkAclIngressArgs]] = None,
        owner_id: Optional[str] = None,
        subnet_ids: Optional[Sequence[str]] = None,
        tags: Optional[Mapping[str, str]] = None,
        tags_all: Optional[Mapping[str, str]] = None,
        vpc_id: Optional[str] = None) -> NetworkAcl
func GetNetworkAcl(ctx *Context, name string, id IDInput, state *NetworkAclState, opts ...ResourceOption) (*NetworkAcl, error)
public static NetworkAcl Get(string name, Input<string> id, NetworkAclState? state, CustomResourceOptions? opts = null)
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name
The unique name of the resulting resource.
id
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.

The following state arguments are supported:

Arn string
The ARN of the network ACL
Egress List<NetworkAclEgressArgs>
Specifies an egress rule. Parameters defined below.
Ingress List<NetworkAclIngressArgs>
Specifies an ingress rule. Parameters defined below.
OwnerId string
The ID of the AWS account that owns the network ACL.
SubnetIds List<string>
A list of Subnet IDs to apply the ACL to
Tags Dictionary<string, string>
A mapping of tags to assign to the resource.
TagsAll Dictionary<string, string>
A map of tags assigned to the resource, including those inherited from the provider.
VpcId string
The ID of the associated VPC.
Arn string
The ARN of the network ACL
Egress []NetworkAclEgress
Specifies an egress rule. Parameters defined below.
Ingress []NetworkAclIngress
Specifies an ingress rule. Parameters defined below.
OwnerId string
The ID of the AWS account that owns the network ACL.
SubnetIds []string
A list of Subnet IDs to apply the ACL to
Tags map[string]string
A mapping of tags to assign to the resource.
TagsAll map[string]string
A map of tags assigned to the resource, including those inherited from the provider.
VpcId string
The ID of the associated VPC.
arn string
The ARN of the network ACL
egress NetworkAclEgressArgs[]
Specifies an egress rule. Parameters defined below.
ingress NetworkAclIngressArgs[]
Specifies an ingress rule. Parameters defined below.
ownerId string
The ID of the AWS account that owns the network ACL.
subnetIds string[]
A list of Subnet IDs to apply the ACL to
tags {[key: string]: string}
A mapping of tags to assign to the resource.
tagsAll {[key: string]: string}
A map of tags assigned to the resource, including those inherited from the provider.
vpcId string
The ID of the associated VPC.
arn str
The ARN of the network ACL
egress Sequence[NetworkAclEgressArgs]
Specifies an egress rule. Parameters defined below.
ingress Sequence[NetworkAclIngressArgs]
Specifies an ingress rule. Parameters defined below.
owner_id str
The ID of the AWS account that owns the network ACL.
subnet_ids Sequence[str]
A list of Subnet IDs to apply the ACL to
tags Mapping[str, str]
A mapping of tags to assign to the resource.
tags_all Mapping[str, str]
A map of tags assigned to the resource, including those inherited from the provider.
vpc_id str
The ID of the associated VPC.

Supporting Types

NetworkAclEgress

Action string
The action to take.
FromPort int
The from port to match.
Protocol string
The protocol to match. If using the -1 ‘all’ protocol, you must specify a from and to port of 0.
RuleNo int
The rule number. Used for ordering.
ToPort int
The to port to match.
CidrBlock string
The CIDR block to match. This must be a valid network mask.
IcmpCode int
The ICMP type code to be used. Default 0.
IcmpType int
The ICMP type to be used. Default 0.
Ipv6CidrBlock string
The IPv6 CIDR block.
Action string
The action to take.
FromPort int
The from port to match.
Protocol string
The protocol to match. If using the -1 ‘all’ protocol, you must specify a from and to port of 0.
RuleNo int
The rule number. Used for ordering.
ToPort int
The to port to match.
CidrBlock string
The CIDR block to match. This must be a valid network mask.
IcmpCode int
The ICMP type code to be used. Default 0.
IcmpType int
The ICMP type to be used. Default 0.
Ipv6CidrBlock string
The IPv6 CIDR block.
action string
The action to take.
fromPort number
The from port to match.
protocol string
The protocol to match. If using the -1 ‘all’ protocol, you must specify a from and to port of 0.
ruleNo number
The rule number. Used for ordering.
toPort number
The to port to match.
cidrBlock string
The CIDR block to match. This must be a valid network mask.
icmpCode number
The ICMP type code to be used. Default 0.
icmpType number
The ICMP type to be used. Default 0.
ipv6CidrBlock string
The IPv6 CIDR block.
action str
The action to take.
from_port int
The from port to match.
protocol str
The protocol to match. If using the -1 ‘all’ protocol, you must specify a from and to port of 0.
rule_no int
The rule number. Used for ordering.
to_port int
The to port to match.
cidr_block str
The CIDR block to match. This must be a valid network mask.
icmp_code int
The ICMP type code to be used. Default 0.
icmp_type int
The ICMP type to be used. Default 0.
ipv6_cidr_block str
The IPv6 CIDR block.

NetworkAclIngress

Action string
The action to take.
FromPort int
The from port to match.
Protocol string
The protocol to match. If using the -1 ‘all’ protocol, you must specify a from and to port of 0.
RuleNo int
The rule number. Used for ordering.
ToPort int
The to port to match.
CidrBlock string
The CIDR block to match. This must be a valid network mask.
IcmpCode int
The ICMP type code to be used. Default 0.
IcmpType int
The ICMP type to be used. Default 0.
Ipv6CidrBlock string
The IPv6 CIDR block.
Action string
The action to take.
FromPort int
The from port to match.
Protocol string
The protocol to match. If using the -1 ‘all’ protocol, you must specify a from and to port of 0.
RuleNo int
The rule number. Used for ordering.
ToPort int
The to port to match.
CidrBlock string
The CIDR block to match. This must be a valid network mask.
IcmpCode int
The ICMP type code to be used. Default 0.
IcmpType int
The ICMP type to be used. Default 0.
Ipv6CidrBlock string
The IPv6 CIDR block.
action string
The action to take.
fromPort number
The from port to match.
protocol string
The protocol to match. If using the -1 ‘all’ protocol, you must specify a from and to port of 0.
ruleNo number
The rule number. Used for ordering.
toPort number
The to port to match.
cidrBlock string
The CIDR block to match. This must be a valid network mask.
icmpCode number
The ICMP type code to be used. Default 0.
icmpType number
The ICMP type to be used. Default 0.
ipv6CidrBlock string
The IPv6 CIDR block.
action str
The action to take.
from_port int
The from port to match.
protocol str
The protocol to match. If using the -1 ‘all’ protocol, you must specify a from and to port of 0.
rule_no int
The rule number. Used for ordering.
to_port int
The to port to match.
cidr_block str
The CIDR block to match. This must be a valid network mask.
icmp_code int
The ICMP type code to be used. Default 0.
icmp_type int
The ICMP type to be used. Default 0.
ipv6_cidr_block str
The IPv6 CIDR block.

Import

Network ACLs can be imported using the id, e.g.

 $ pulumi import aws:ec2/networkAcl:NetworkAcl main acl-7aaabd18

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.