Skip to content
v2.273.0

NetworkAclEntry L2 construct ​

Define an entry in a Network ACL table.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ec2 as ec2 } from 'aws-cdk-lib';

declare const aclCidr: ec2.AclCidr;
declare const aclTraffic: ec2.AclTraffic;
declare const networkAcl: ec2.NetworkAcl;
const networkAclEntry = new ec2.NetworkAclEntry(this, 'MyNetworkAclEntry', {
  cidr: aclCidr,
  networkAcl: networkAcl,
  ruleNumber: 123,
  traffic: aclTraffic,

  // the properties below are optional
  direction: ec2.TrafficDirection.EGRESS,
  networkAclEntryName: 'networkAclEntryName',
  ruleAction: ec2.Action.ALLOW,
});
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ec2 as ec2

# acl_cidr: ec2.AclCidr
# acl_traffic: ec2.AclTraffic
# network_acl: ec2.NetworkAcl

network_acl_entry = ec2.NetworkAclEntry(self, "MyNetworkAclEntry",
    cidr=acl_cidr,
    network_acl=network_acl,
    rule_number=123,
    traffic=acl_traffic,

    # the properties below are optional
    direction=ec2.TrafficDirection.EGRESS,
    network_acl_entry_name="networkAclEntryName",
    rule_action=ec2.Action.ALLOW
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ec2.*;

AclCidr aclCidr;
AclTraffic aclTraffic;
NetworkAcl networkAcl;

NetworkAclEntry networkAclEntry = NetworkAclEntry.Builder.create(this, "MyNetworkAclEntry")
        .cidr(aclCidr)
        .networkAcl(networkAcl)
        .ruleNumber(123)
        .traffic(aclTraffic)

        // the properties below are optional
        .direction(TrafficDirection.EGRESS)
        .networkAclEntryName("networkAclEntryName")
        .ruleAction(Action.ALLOW)
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.EC2;

AclCidr aclCidr;
AclTraffic aclTraffic;
NetworkAcl networkAcl;

var networkAclEntry = new NetworkAclEntry(this, "MyNetworkAclEntry", new NetworkAclEntryProps {
    Cidr = aclCidr,
    NetworkAcl = networkAcl,
    RuleNumber = 123,
    Traffic = aclTraffic,

    // the properties below are optional
    Direction = TrafficDirection.EGRESS,
    NetworkAclEntryName = "networkAclEntryName",
    RuleAction = Action.ALLOW
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

var aclCidr AclCidr
var aclTraffic AclTraffic
var networkAcl NetworkAcl

networkAclEntry := awscdk.Aws_ec2.NewNetworkAclEntry(this, jsii.String("MyNetworkAclEntry"), &NetworkAclEntryProps{
	Cidr: aclCidr,
	NetworkAcl: networkAcl,
	RuleNumber: jsii.Number(123),
	Traffic: aclTraffic,

	// the properties below are optional
	Direction: awscdk.*Aws_ec2.TrafficDirection_EGRESS,
	NetworkAclEntryName: jsii.String("networkAclEntryName"),
	RuleAction: awscdk.*Aws_ec2.Action_ALLOW,
})

Initializer ​

ts
new NetworkAclEntry(scope: Construct, id: string, props: NetworkAclEntryProps)
python
NetworkAclEntry(scope: Construct, id: str, props: NetworkAclEntryProps)
java
new NetworkAclEntry(Construct scope, String id, NetworkAclEntryProps props)
csharp
new NetworkAclEntry(Construct scope, string id, NetworkAclEntryProps props)
go
NewNetworkAclEntry(Scope Construct, Id *string, Props NetworkAclEntryProps)

Construct Props ​

cidrAclCidrcidrAclCidrcidrAclCidrCidrAclCidrCidrAclCidrrequired#
The CIDR range to allow or deny.
directionTrafficDirectiondirectionTrafficDirectiondirectionTrafficDirectionDirectionTrafficDirectionDirectionTrafficDirection= TrafficDirection.INGRESS#
Traffic direction, with respect to the subnet, this rule applies to.
networkAclINetworkAclnetwork_aclINetworkAclnetworkAclINetworkAclNetworkAclINetworkAclNetworkAclINetworkAclrequired#
The network ACL this entry applies to.
networkAclEntryNamestringnetwork_acl_entry_namestrnetworkAclEntryNameStringNetworkAclEntryNamestringNetworkAclEntryName*string= If you don't specify a NetworkAc…#
The name of the NetworkAclEntry.

It is not recommended to use an explicit group name.

default

Default: If you don't specify a NetworkAclName, AWS CloudFormation generates a unique physical ID and uses that ID for the group name.

ruleActionActionrule_actionActionruleActionActionRuleActionActionRuleActionAction= ALLOW#
Whether to allow or deny traffic that matches the rule; valid values are "allow" or "deny".

Any traffic that is not explicitly allowed is automatically denied in a custom ACL, all traffic is automatically allowed in a default ACL.

ruleNumbernumberrule_numberint | floatruleNumberNumberRuleNumberdoubleRuleNumber*float64required#
Rule number to assign to the entry, such as 100.

ACL entries are processed in ascending order by rule number. Entries can't use the same rule number unless one is an egress rule and the other is an ingress rule.

trafficAclTraffictrafficAclTraffictrafficAclTrafficTrafficAclTrafficTrafficAclTrafficrequired#
What kind of traffic this ACL rule applies to.

Properties ​

The environment this resource belongs to.
notes

For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.

For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.

networkAclINetworkAclnetwork_aclINetworkAclnetworkAclINetworkAclNetworkAclINetworkAclNetworkAclINetworkAclrequired#
The network ACL.
networkAclEntryRefNetworkAclEntryReferencenetwork_acl_entry_refNetworkAclEntryReferencenetworkAclEntryRefNetworkAclEntryReferenceNetworkAclEntryRefNetworkAclEntryReferenceNetworkAclEntryRefNetworkAclEntryReferencerequired#
A reference to a NetworkAclEntry resource.
nodeNodenodeNodenodeNodeNodeNodeNodeNoderequired#
The tree node.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#
Uniquely identifies this class.
stackStackstackStackstackStackStackStackStackStackrequired#
The stack in which this resource is defined.

Methods ​

applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#
Override the cross-stack reference strength for this resource.
notes · 1 parameter

When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.

Parameters

  • strengthstrengthstrengthstrengthStrength — - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#
Apply the given removal policy to this resource.
notes

The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.

The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).

isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#
Checks if `x` is a construct.
notes · 1 parameter · returns

Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.

Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.

Parameters

  • xxxxX — Any object.

Returns: true if x is an object created from a class which extends Construct.

isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#
Returns true if the construct was created by CDK, and false otherwise.
isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#
Check whether the given construct is a Resource.
toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#
Returns a string representation of this construct.
with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#
Applies one or more mixins to this construct.

Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.