Package com.pulumi.aws.ec2
Class DefaultNetworkAcl
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.aws.ec2.DefaultNetworkAcl
-
public class DefaultNetworkAcl extends com.pulumi.resources.CustomResourceProvides a resource to manage a VPC's default network ACL. This resource can manage the default network ACL of the default or a non-default VPC. > **NOTE:** This is an advanced resource with special caveats. Please read this document in its entirety before using this resource. The `aws.ec2.DefaultNetworkAcl` behaves differently from normal resources. This provider does not _create_ this resource but instead attempts to "adopt" it into management. Every VPC has a default network ACL that can be managed but not destroyed. When the provider first adopts the Default Network ACL, it **immediately removes all rules in the ACL**. It then proceeds to create any rules specified in the configuration. This step is required so that only the rules specified in the configuration are created. This resource treats its inline rules as absolute; only the rules defined inline are created, and any additions/removals external to this resource will result in diffs being shown. For these reasons, this resource is incompatible with the `aws.ec2.NetworkAclRule` resource. For more information about Network ACLs, see the AWS Documentation on [Network ACLs](http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_ACLs.html). ## Example Usage ### Basic Example The following config gives the Default Network ACL the same rules that AWS includes but pulls the resource under management by this provider. This means that any ACL rules added or changed will be detected as drift.
### Example: Deny All Egress Traffic, Allow Ingress The following denies all Egress traffic by omitting any `egress` rules, while including the default `ingress` rule to allow all traffic.package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.ec2.Vpc; import com.pulumi.aws.ec2.VpcArgs; import com.pulumi.aws.ec2.DefaultNetworkAcl; import com.pulumi.aws.ec2.DefaultNetworkAclArgs; import com.pulumi.aws.ec2.inputs.DefaultNetworkAclEgressArgs; import com.pulumi.aws.ec2.inputs.DefaultNetworkAclIngressArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var mainvpc = new Vpc("mainvpc", VpcArgs.builder() .cidrBlock("10.1.0.0/16") .build()); var default_ = new DefaultNetworkAcl("default", DefaultNetworkAclArgs.builder() .egress(DefaultNetworkAclEgressArgs.builder() .protocol("-1") .ruleNo(100) .action("allow") .cidrBlock("0.0.0.0/0") .fromPort(0) .toPort(0) .build()) .ingress(DefaultNetworkAclIngressArgs.builder() .protocol("-1") .ruleNo(100) .action("allow") .cidrBlock("0.0.0.0/0") .fromPort(0) .toPort(0) .build()) .defaultNetworkAclId(mainvpc.defaultNetworkAclId()) .build()); } }
### Example: Deny All Traffic To Any Subnet In The Default Network ACL This config denies all traffic in the Default ACL. This can be useful if you want to lock down the VPC to force all resources to assign a non-default ACL.package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.ec2.Vpc; import com.pulumi.aws.ec2.VpcArgs; import com.pulumi.aws.ec2.DefaultNetworkAcl; import com.pulumi.aws.ec2.DefaultNetworkAclArgs; import com.pulumi.aws.ec2.inputs.DefaultNetworkAclIngressArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var mainvpc = new Vpc("mainvpc", VpcArgs.builder() .cidrBlock("10.1.0.0/16") .build()); var default_ = new DefaultNetworkAcl("default", DefaultNetworkAclArgs.builder() .ingress(DefaultNetworkAclIngressArgs.builder() .protocol("-1") .ruleNo(100) .action("allow") .cidrBlock(mainvpcAwsDefaultVpc.cidrBlock()) .fromPort(0) .toPort(0) .build()) .defaultNetworkAclId(mainvpc.defaultNetworkAclId()) .build()); } }
### Managing Subnets In A Default Network ACL Within a VPC, all Subnets must be associated with a Network ACL. In order to "delete" the association between a Subnet and a non-default Network ACL, the association is destroyed by replacing it with an association between the Subnet and the Default ACL instead. When managing the Default Network ACL, you cannot "remove" Subnets. Instead, they must be reassigned to another Network ACL, or the Subnet itself must be destroyed. Because of these requirements, removing the `subnetIds` attribute from the configuration of a `aws.ec2.DefaultNetworkAcl` resource may result in a reoccurring plan, until the Subnets are reassigned to another Network ACL or are destroyed. Because Subnets are by default associated with the Default Network ACL, any non-explicit association will show up as a plan to remove the Subnet. For example: if you have a custom `aws.ec2.NetworkAcl` with two subnets attached, and you remove the `aws.ec2.NetworkAcl` resource, after successfully destroying this resource future plans will show a diff on the managed `aws.ec2.DefaultNetworkAcl`, as those two Subnets have been orphaned by the now destroyed network ACL and thus adopted by the Default Network ACL. In order to avoid a reoccurring plan, they will need to be reassigned, destroyed, or added to the `subnetIds` attribute of the `aws.ec2.DefaultNetworkAcl` entry. As an alternative to the above, you can also specify the following lifecycle configuration in your `aws.ec2.DefaultNetworkAcl` resource:package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.ec2.Vpc; import com.pulumi.aws.ec2.VpcArgs; import com.pulumi.aws.ec2.DefaultNetworkAcl; import com.pulumi.aws.ec2.DefaultNetworkAclArgs; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var mainvpc = new Vpc("mainvpc", VpcArgs.builder() .cidrBlock("10.1.0.0/16") .build()); var default_ = new DefaultNetworkAcl("default", DefaultNetworkAclArgs.builder() .defaultNetworkAclId(mainvpc.defaultNetworkAclId()) .build()); } }
### Removing `aws.ec2.DefaultNetworkAcl` From Your Configuration Each AWS VPC comes with a Default Network ACL that cannot be deleted. The `aws.ec2.DefaultNetworkAcl` allows you to manage this Network ACL, but the provider cannot destroy it. Removing this resource from your configuration will remove it from your statefile and management, **but will not destroy the Network ACL.** All Subnets associations and ingress or egress rules will be left as they are at the time of removal. You can resume managing them via the AWS Console. ## Import Using `pulumi import`, import Default Network ACLs using the `id`. For example: ```sh $ pulumi import aws:ec2/defaultNetworkAcl:DefaultNetworkAcl sample acl-7aaabd18 ```package generated_program; import com.pulumi.Context; import com.pulumi.Pulumi; import com.pulumi.core.Output; import com.pulumi.aws.ec2.DefaultNetworkAcl; import com.pulumi.aws.ec2.DefaultNetworkAclArgs; import com.pulumi.resources.CustomResourceOptions; import java.util.ArrayList; import java.util.Arrays; import java.util.Map; import java.io.File; import java.nio.file.Files; import java.nio.file.Paths; public class App { public static void main(String[] args) { Pulumi.run(App::stack); } public static void stack(Context ctx) { var default_ = new DefaultNetworkAcl("default", DefaultNetworkAclArgs.Empty, CustomResourceOptions.builder() .ignoreChanges("subnetIds") .build()); } }
-
-
Constructor Summary
Constructors Constructor Description DefaultNetworkAcl(java.lang.String name)DefaultNetworkAcl(java.lang.String name, DefaultNetworkAclArgs args)DefaultNetworkAcl(java.lang.String name, DefaultNetworkAclArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.lang.String>arn()com.pulumi.core.Output<java.lang.String>defaultNetworkAclId()com.pulumi.core.Output<java.util.Optional<java.util.List<DefaultNetworkAclEgress>>>egress()static DefaultNetworkAclget(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, DefaultNetworkAclState state, com.pulumi.resources.CustomResourceOptions options)Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.util.Optional<java.util.List<DefaultNetworkAclIngress>>>ingress()com.pulumi.core.Output<java.lang.String>ownerId()com.pulumi.core.Output<java.lang.String>region()com.pulumi.core.Output<java.util.Optional<java.util.List<java.lang.String>>>subnetIds()com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>>tags()com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>>tagsAll()com.pulumi.core.Output<java.lang.String>vpcId()
-
-
-
Constructor Detail
-
DefaultNetworkAcl
public DefaultNetworkAcl(java.lang.String name)
- Parameters:
name- The _unique_ name of the resulting resource.
-
DefaultNetworkAcl
public DefaultNetworkAcl(java.lang.String name, DefaultNetworkAclArgs args)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.
-
DefaultNetworkAcl
public DefaultNetworkAcl(java.lang.String name, DefaultNetworkAclArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)- Parameters:
name- The _unique_ name of the resulting resource.args- The arguments to use to populate this resource's properties.options- A bag of options that control this resource's behavior.
-
-
Method Detail
-
arn
public com.pulumi.core.Output<java.lang.String> arn()
- Returns:
- ARN of the Default Network ACL
-
defaultNetworkAclId
public com.pulumi.core.Output<java.lang.String> defaultNetworkAclId()
- Returns:
- Network ACL ID to manage. This attribute is exported from `aws.ec2.Vpc`, or manually found via the AWS Console. The following arguments are optional:
-
egress
public com.pulumi.core.Output<java.util.Optional<java.util.List<DefaultNetworkAclEgress>>> egress()
- Returns:
- Configuration block for an egress rule. Detailed below.
-
ingress
public com.pulumi.core.Output<java.util.Optional<java.util.List<DefaultNetworkAclIngress>>> ingress()
- Returns:
- Configuration block for an ingress rule. Detailed below.
-
ownerId
public com.pulumi.core.Output<java.lang.String> ownerId()
- Returns:
- ID of the AWS account that owns the Default Network ACL
-
region
public com.pulumi.core.Output<java.lang.String> region()
- Returns:
- Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
-
subnetIds
public com.pulumi.core.Output<java.util.Optional<java.util.List<java.lang.String>>> subnetIds()
- Returns:
- List of Subnet IDs to apply the ACL to. See the notes above on Managing Subnets in the Default Network ACL
-
tags
public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>> tags()
- Returns:
- Map of tags to assign to the resource. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
-
tagsAll
public com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>> tagsAll()
- Returns:
- A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
-
vpcId
public com.pulumi.core.Output<java.lang.String> vpcId()
- Returns:
- ID of the associated VPC
-
get
public static DefaultNetworkAcl get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable DefaultNetworkAclState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name- The _unique_ name of the resulting resource.id- The _unique_ provider ID of the resource to lookup.state-options- Optional settings to control the behavior of the CustomResource.
-
-