NetworkAclRule class
Creates an entry (a rule) in a network ACL with the specified rule number.
> 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
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const bar = new aws.ec2.NetworkAcl("bar", {vpcId: foo.id});
const barNetworkAclRule = new aws.ec2.NetworkAclRule("bar", {
networkAclId: bar.id,
ruleNumber: 200,
egress: false,
protocol: "tcp",
ruleAction: "allow",
cidrBlock: foo.cidrBlock,
fromPort: 22,
toPort: 22,
});
import pulumi
import pulumi_aws as aws
bar = aws.ec2.NetworkAcl("bar", vpc_id=foo["id"])
bar_network_acl_rule = aws.ec2.NetworkAclRule("bar",
network_acl_id=bar.id,
rule_number=200,
egress=False,
protocol="tcp",
rule_action="allow",
cidr_block=foo["cidrBlock"],
from_port=22,
to_port=22)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var bar = new Aws.Ec2.NetworkAcl("bar", new()
{
VpcId = foo.Id,
});
var barNetworkAclRule = new Aws.Ec2.NetworkAclRule("bar", new()
{
NetworkAclId = bar.Id,
RuleNumber = 200,
Egress = false,
Protocol = "tcp",
RuleAction = "allow",
CidrBlock = foo.CidrBlock,
FromPort = 22,
ToPort = 22,
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ec2"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
bar, err := ec2.NewNetworkAcl(ctx, "bar", &ec2.NetworkAclArgs{
VpcId: pulumi.Any(foo.Id),
})
if err != nil {
return err
}
_, err = ec2.NewNetworkAclRule(ctx, "bar", &ec2.NetworkAclRuleArgs{
NetworkAclId: bar.ID().ToIDOutput().ToStringOutput(),
RuleNumber: pulumi.Int(200),
Egress: pulumi.Bool(false),
Protocol: pulumi.String("tcp"),
RuleAction: pulumi.String("allow"),
CidrBlock: pulumi.Any(foo.CidrBlock),
FromPort: pulumi.Int(22),
ToPort: pulumi.Int(22),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_ec2_networkacl" "bar" {
vpc_id = foo.id
}
resource "aws_ec2_networkaclrule" "bar" {
network_acl_id = aws_ec2_networkacl.bar.id
rule_number = 200
egress = false
protocol = "tcp"
rule_action = "allow"
cidr_block = foo.cidrBlock
from_port = 22
to_port = 22
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.NetworkAcl;
import com.pulumi.aws.ec2.NetworkAclArgs;
import com.pulumi.aws.ec2.NetworkAclRule;
import com.pulumi.aws.ec2.NetworkAclRuleArgs;
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 bar = new NetworkAcl("bar", NetworkAclArgs.builder()
.vpcId(foo.id())
.build());
var barNetworkAclRule = new NetworkAclRule("barNetworkAclRule", NetworkAclRuleArgs.builder()
.networkAclId(bar.id())
.ruleNumber(200)
.egress(false)
.protocol("tcp")
.ruleAction("allow")
.cidrBlock(foo.cidrBlock())
.fromPort(22)
.toPort(22)
.build());
}
}
resources:
bar:
type: aws:ec2:NetworkAcl
properties:
vpcId: ${foo.id}
barNetworkAclRule:
type: aws:ec2:NetworkAclRule
name: bar
properties:
networkAclId: ${bar.id}
ruleNumber: 200
egress: false
protocol: tcp
ruleAction: allow
cidrBlock: ${foo.cidrBlock}
fromPort: 22
toPort: 22
> Note: One of either cidrBlock or ipv6CidrBlock is required.
Import
Identity Schema
Required
egress(Boolean) Indicates whether this is an egress rule.networkAclId(String) The ID of the network ACL.protocol(String) The protocol. This can be a decimal value such as6or a keyword such astcp.ruleNumber(Number) The rule number for the entry.
Optional
accountId(String) AWS account where this resource is managed.region(String) Region where this resource is managed.
Using the protocol's decimal value:
Using pulumi import, import individual rules using NETWORK_ACL_ID:RULE_NUMBER:PROTOCOL:EGRESS, where PROTOCOL can be a decimal (such as "6") or string (such as "tcp") value. For example:
Using the protocol's string value:
$ pulumi import aws:ec2/networkAclRule:NetworkAclRule my_rule acl-7aaabd18:100:tcp:false
Using the protocol's decimal value:
$ pulumi import aws:ec2/networkAclRule:NetworkAclRule my_rule acl-7aaabd18:100:6:false
Constructors
- NetworkAclRule(String name, {NetworkAclRuleArgs? args, CustomResourceOptions? options})
-
Creates a new NetworkAclRule.
nameThe Pulumi resource name.argsArguments used to configure this NetworkAclRule. The set of arguments for NetworkAclRule.optionsResource options controlling this resource's behavior. - NetworkAclRule.reference(String urn)
- Creates a typed reference to an existing NetworkAclRule resource.
Properties
-
childResources
→ Set<
Resource> -
finalinherited
-
cidrBlock
↔ Output<
String?> -
The network range to allow or deny, in CIDR notation (for example 172.16.0.0/24 ).
latefinal
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
egress
↔ Output<
bool?> -
Indicates whether this is an egress rule (rule is applied to traffic leaving the subnet). Default
false.latefinal -
fromPort
↔ Output<
int?> -
The from port to match.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
icmpCode
↔ Output<
int?> -
ICMP protocol: The ICMP code. Required if specifying ICMP for the protocolE.g., -1
latefinal
-
icmpType
↔ Output<
int?> -
ICMP protocol: The ICMP type. Required if specifying ICMP for the protocolE.g., -1
latefinal
-
id
↔ Output<
String> -
getter/setter pairinherited
-
ipv6CidrBlock
↔ Output<
String?> -
The IPv6 CIDR block to allow or deny.
latefinal
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
networkAclId
↔ Output<
String> -
The ID of the network ACL.
latefinal
-
protocol
↔ Output<
String> -
The protocol. A value of -1 means all protocols.
latefinal
-
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
-
ruleAction
↔ Output<
String> -
Indicates whether to allow or deny the traffic that matches the rule. Accepted values:
allow|denylatefinal -
ruleNumber
↔ Output<
int> -
The rule number for the entry (for example, 100). ACL entries are processed in ascending order by rule number.
latefinal
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
toPort
↔ Output<
int?> -
The to port to match.
latefinal
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {NetworkAclRuleState? state, CustomResourceOptions? options}) → NetworkAclRule -
Gets an existing NetworkAclRule resource's state with the given
nameandid.