1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. sag
  5. AclRule
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.sag.AclRule

Explore with Pulumi AI

Provides a Sag Acl Rule resource. This topic describes how to configure an access control list (ACL) rule for a target Smart Access Gateway instance to permit or deny access to or from specified IP addresses in the ACL rule.

For information about Sag Acl Rule and how to use it, see What is access control list (ACL) rule.

NOTE: Available since v1.60.0.

NOTE: Only the following regions support create Cloud Connect Network. [cn-shanghai, cn-shanghai-finance-1, cn-hongkong, ap-southeast-1, ap-southeast-3, ap-southeast-5, ap-northeast-1, eu-central-1]

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const config = new pulumi.Config();
const name = config.get("name") || "tf_example";
const _default = new alicloud.sag.Acl("default", {name: name});
const defaultAclRule = new alicloud.sag.AclRule("default", {
    aclId: _default.id,
    description: name,
    policy: "accept",
    ipProtocol: "ALL",
    direction: "in",
    sourceCidr: "10.10.1.0/24",
    sourcePortRange: "-1/-1",
    destCidr: "192.168.1.0/24",
    destPortRange: "-1/-1",
    priority: 1,
});
Copy
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "tf_example"
default = alicloud.sag.Acl("default", name=name)
default_acl_rule = alicloud.sag.AclRule("default",
    acl_id=default.id,
    description=name,
    policy="accept",
    ip_protocol="ALL",
    direction="in",
    source_cidr="10.10.1.0/24",
    source_port_range="-1/-1",
    dest_cidr="192.168.1.0/24",
    dest_port_range="-1/-1",
    priority=1)
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/sag"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		cfg := config.New(ctx, "")
		name := "tf_example"
		if param := cfg.Get("name"); param != "" {
			name = param
		}
		_default, err := sag.NewAcl(ctx, "default", &sag.AclArgs{
			Name: pulumi.String(name),
		})
		if err != nil {
			return err
		}
		_, err = sag.NewAclRule(ctx, "default", &sag.AclRuleArgs{
			AclId:           _default.ID(),
			Description:     pulumi.String(name),
			Policy:          pulumi.String("accept"),
			IpProtocol:      pulumi.String("ALL"),
			Direction:       pulumi.String("in"),
			SourceCidr:      pulumi.String("10.10.1.0/24"),
			SourcePortRange: pulumi.String("-1/-1"),
			DestCidr:        pulumi.String("192.168.1.0/24"),
			DestPortRange:   pulumi.String("-1/-1"),
			Priority:        pulumi.Int(1),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var config = new Config();
    var name = config.Get("name") ?? "tf_example";
    var @default = new AliCloud.Sag.Acl("default", new()
    {
        Name = name,
    });

    var defaultAclRule = new AliCloud.Sag.AclRule("default", new()
    {
        AclId = @default.Id,
        Description = name,
        Policy = "accept",
        IpProtocol = "ALL",
        Direction = "in",
        SourceCidr = "10.10.1.0/24",
        SourcePortRange = "-1/-1",
        DestCidr = "192.168.1.0/24",
        DestPortRange = "-1/-1",
        Priority = 1,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.sag.Acl;
import com.pulumi.alicloud.sag.AclArgs;
import com.pulumi.alicloud.sag.AclRule;
import com.pulumi.alicloud.sag.AclRuleArgs;
import java.util.List;
import java.util.ArrayList;
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) {
        final var config = ctx.config();
        final var name = config.get("name").orElse("tf_example");
        var default_ = new Acl("default", AclArgs.builder()
            .name(name)
            .build());

        var defaultAclRule = new AclRule("defaultAclRule", AclRuleArgs.builder()
            .aclId(default_.id())
            .description(name)
            .policy("accept")
            .ipProtocol("ALL")
            .direction("in")
            .sourceCidr("10.10.1.0/24")
            .sourcePortRange("-1/-1")
            .destCidr("192.168.1.0/24")
            .destPortRange("-1/-1")
            .priority("1")
            .build());

    }
}
Copy
configuration:
  name:
    type: string
    default: tf_example
resources:
  default:
    type: alicloud:sag:Acl
    properties:
      name: ${name}
  defaultAclRule:
    type: alicloud:sag:AclRule
    name: default
    properties:
      aclId: ${default.id}
      description: ${name}
      policy: accept
      ipProtocol: ALL
      direction: in
      sourceCidr: 10.10.1.0/24
      sourcePortRange: -1/-1
      destCidr: 192.168.1.0/24
      destPortRange: -1/-1
      priority: '1'
Copy

Create AclRule Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new AclRule(name: string, args: AclRuleArgs, opts?: CustomResourceOptions);
@overload
def AclRule(resource_name: str,
            args: AclRuleArgs,
            opts: Optional[ResourceOptions] = None)

@overload
def AclRule(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            acl_id: Optional[str] = None,
            dest_cidr: Optional[str] = None,
            dest_port_range: Optional[str] = None,
            direction: Optional[str] = None,
            ip_protocol: Optional[str] = None,
            policy: Optional[str] = None,
            source_cidr: Optional[str] = None,
            source_port_range: Optional[str] = None,
            description: Optional[str] = None,
            priority: Optional[int] = None)
func NewAclRule(ctx *Context, name string, args AclRuleArgs, opts ...ResourceOption) (*AclRule, error)
public AclRule(string name, AclRuleArgs args, CustomResourceOptions? opts = null)
public AclRule(String name, AclRuleArgs args)
public AclRule(String name, AclRuleArgs args, CustomResourceOptions options)
type: alicloud:sag:AclRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. AclRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. AclRuleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. AclRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. AclRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. AclRuleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var aclRuleResource = new AliCloud.Sag.AclRule("aclRuleResource", new()
{
    AclId = "string",
    DestCidr = "string",
    DestPortRange = "string",
    Direction = "string",
    IpProtocol = "string",
    Policy = "string",
    SourceCidr = "string",
    SourcePortRange = "string",
    Description = "string",
    Priority = 0,
});
Copy
example, err := sag.NewAclRule(ctx, "aclRuleResource", &sag.AclRuleArgs{
	AclId:           pulumi.String("string"),
	DestCidr:        pulumi.String("string"),
	DestPortRange:   pulumi.String("string"),
	Direction:       pulumi.String("string"),
	IpProtocol:      pulumi.String("string"),
	Policy:          pulumi.String("string"),
	SourceCidr:      pulumi.String("string"),
	SourcePortRange: pulumi.String("string"),
	Description:     pulumi.String("string"),
	Priority:        pulumi.Int(0),
})
Copy
var aclRuleResource = new AclRule("aclRuleResource", AclRuleArgs.builder()
    .aclId("string")
    .destCidr("string")
    .destPortRange("string")
    .direction("string")
    .ipProtocol("string")
    .policy("string")
    .sourceCidr("string")
    .sourcePortRange("string")
    .description("string")
    .priority(0)
    .build());
Copy
acl_rule_resource = alicloud.sag.AclRule("aclRuleResource",
    acl_id="string",
    dest_cidr="string",
    dest_port_range="string",
    direction="string",
    ip_protocol="string",
    policy="string",
    source_cidr="string",
    source_port_range="string",
    description="string",
    priority=0)
Copy
const aclRuleResource = new alicloud.sag.AclRule("aclRuleResource", {
    aclId: "string",
    destCidr: "string",
    destPortRange: "string",
    direction: "string",
    ipProtocol: "string",
    policy: "string",
    sourceCidr: "string",
    sourcePortRange: "string",
    description: "string",
    priority: 0,
});
Copy
type: alicloud:sag:AclRule
properties:
    aclId: string
    description: string
    destCidr: string
    destPortRange: string
    direction: string
    ipProtocol: string
    policy: string
    priority: 0
    sourceCidr: string
    sourcePortRange: string
Copy

AclRule Resource Properties

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

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The AclRule resource accepts the following input properties:

AclId This property is required. string
The ID of the ACL.
DestCidr This property is required. string
The destination address. It is an IPv4 address range in CIDR format. Default value: 0.0.0.0/0.
DestPortRange This property is required. string
The range of the destination port. Valid value: 80/80.
Direction This property is required. string
The direction of the ACL rule. Valid values: in|out.
IpProtocol This property is required. string
The protocol used by the ACL rule. The value is not case sensitive.
Policy This property is required. string
The policy used by the ACL rule. Valid values: accept|drop.
SourceCidr This property is required. string
The source address. It is an IPv4 address range in the CIDR format. Default value: 0.0.0.0/0.
SourcePortRange This property is required. string
The range of the source port. Valid value: 80/80.
Description string
The description of the ACL rule. It must be 1 to 512 characters in length.
Priority int
The priority of the ACL rule. Value range: 1 to 100.
AclId This property is required. string
The ID of the ACL.
DestCidr This property is required. string
The destination address. It is an IPv4 address range in CIDR format. Default value: 0.0.0.0/0.
DestPortRange This property is required. string
The range of the destination port. Valid value: 80/80.
Direction This property is required. string
The direction of the ACL rule. Valid values: in|out.
IpProtocol This property is required. string
The protocol used by the ACL rule. The value is not case sensitive.
Policy This property is required. string
The policy used by the ACL rule. Valid values: accept|drop.
SourceCidr This property is required. string
The source address. It is an IPv4 address range in the CIDR format. Default value: 0.0.0.0/0.
SourcePortRange This property is required. string
The range of the source port. Valid value: 80/80.
Description string
The description of the ACL rule. It must be 1 to 512 characters in length.
Priority int
The priority of the ACL rule. Value range: 1 to 100.
aclId This property is required. String
The ID of the ACL.
destCidr This property is required. String
The destination address. It is an IPv4 address range in CIDR format. Default value: 0.0.0.0/0.
destPortRange This property is required. String
The range of the destination port. Valid value: 80/80.
direction This property is required. String
The direction of the ACL rule. Valid values: in|out.
ipProtocol This property is required. String
The protocol used by the ACL rule. The value is not case sensitive.
policy This property is required. String
The policy used by the ACL rule. Valid values: accept|drop.
sourceCidr This property is required. String
The source address. It is an IPv4 address range in the CIDR format. Default value: 0.0.0.0/0.
sourcePortRange This property is required. String
The range of the source port. Valid value: 80/80.
description String
The description of the ACL rule. It must be 1 to 512 characters in length.
priority Integer
The priority of the ACL rule. Value range: 1 to 100.
aclId This property is required. string
The ID of the ACL.
destCidr This property is required. string
The destination address. It is an IPv4 address range in CIDR format. Default value: 0.0.0.0/0.
destPortRange This property is required. string
The range of the destination port. Valid value: 80/80.
direction This property is required. string
The direction of the ACL rule. Valid values: in|out.
ipProtocol This property is required. string
The protocol used by the ACL rule. The value is not case sensitive.
policy This property is required. string
The policy used by the ACL rule. Valid values: accept|drop.
sourceCidr This property is required. string
The source address. It is an IPv4 address range in the CIDR format. Default value: 0.0.0.0/0.
sourcePortRange This property is required. string
The range of the source port. Valid value: 80/80.
description string
The description of the ACL rule. It must be 1 to 512 characters in length.
priority number
The priority of the ACL rule. Value range: 1 to 100.
acl_id This property is required. str
The ID of the ACL.
dest_cidr This property is required. str
The destination address. It is an IPv4 address range in CIDR format. Default value: 0.0.0.0/0.
dest_port_range This property is required. str
The range of the destination port. Valid value: 80/80.
direction This property is required. str
The direction of the ACL rule. Valid values: in|out.
ip_protocol This property is required. str
The protocol used by the ACL rule. The value is not case sensitive.
policy This property is required. str
The policy used by the ACL rule. Valid values: accept|drop.
source_cidr This property is required. str
The source address. It is an IPv4 address range in the CIDR format. Default value: 0.0.0.0/0.
source_port_range This property is required. str
The range of the source port. Valid value: 80/80.
description str
The description of the ACL rule. It must be 1 to 512 characters in length.
priority int
The priority of the ACL rule. Value range: 1 to 100.
aclId This property is required. String
The ID of the ACL.
destCidr This property is required. String
The destination address. It is an IPv4 address range in CIDR format. Default value: 0.0.0.0/0.
destPortRange This property is required. String
The range of the destination port. Valid value: 80/80.
direction This property is required. String
The direction of the ACL rule. Valid values: in|out.
ipProtocol This property is required. String
The protocol used by the ACL rule. The value is not case sensitive.
policy This property is required. String
The policy used by the ACL rule. Valid values: accept|drop.
sourceCidr This property is required. String
The source address. It is an IPv4 address range in the CIDR format. Default value: 0.0.0.0/0.
sourcePortRange This property is required. String
The range of the source port. Valid value: 80/80.
description String
The description of the ACL rule. It must be 1 to 512 characters in length.
priority Number
The priority of the ACL rule. Value range: 1 to 100.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing AclRule Resource

Get an existing AclRule 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?: AclRuleState, opts?: CustomResourceOptions): AclRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        acl_id: Optional[str] = None,
        description: Optional[str] = None,
        dest_cidr: Optional[str] = None,
        dest_port_range: Optional[str] = None,
        direction: Optional[str] = None,
        ip_protocol: Optional[str] = None,
        policy: Optional[str] = None,
        priority: Optional[int] = None,
        source_cidr: Optional[str] = None,
        source_port_range: Optional[str] = None) -> AclRule
func GetAclRule(ctx *Context, name string, id IDInput, state *AclRuleState, opts ...ResourceOption) (*AclRule, error)
public static AclRule Get(string name, Input<string> id, AclRuleState? state, CustomResourceOptions? opts = null)
public static AclRule get(String name, Output<String> id, AclRuleState state, CustomResourceOptions options)
resources:  _:    type: alicloud:sag:AclRule    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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:
AclId string
The ID of the ACL.
Description string
The description of the ACL rule. It must be 1 to 512 characters in length.
DestCidr string
The destination address. It is an IPv4 address range in CIDR format. Default value: 0.0.0.0/0.
DestPortRange string
The range of the destination port. Valid value: 80/80.
Direction string
The direction of the ACL rule. Valid values: in|out.
IpProtocol string
The protocol used by the ACL rule. The value is not case sensitive.
Policy string
The policy used by the ACL rule. Valid values: accept|drop.
Priority int
The priority of the ACL rule. Value range: 1 to 100.
SourceCidr string
The source address. It is an IPv4 address range in the CIDR format. Default value: 0.0.0.0/0.
SourcePortRange string
The range of the source port. Valid value: 80/80.
AclId string
The ID of the ACL.
Description string
The description of the ACL rule. It must be 1 to 512 characters in length.
DestCidr string
The destination address. It is an IPv4 address range in CIDR format. Default value: 0.0.0.0/0.
DestPortRange string
The range of the destination port. Valid value: 80/80.
Direction string
The direction of the ACL rule. Valid values: in|out.
IpProtocol string
The protocol used by the ACL rule. The value is not case sensitive.
Policy string
The policy used by the ACL rule. Valid values: accept|drop.
Priority int
The priority of the ACL rule. Value range: 1 to 100.
SourceCidr string
The source address. It is an IPv4 address range in the CIDR format. Default value: 0.0.0.0/0.
SourcePortRange string
The range of the source port. Valid value: 80/80.
aclId String
The ID of the ACL.
description String
The description of the ACL rule. It must be 1 to 512 characters in length.
destCidr String
The destination address. It is an IPv4 address range in CIDR format. Default value: 0.0.0.0/0.
destPortRange String
The range of the destination port. Valid value: 80/80.
direction String
The direction of the ACL rule. Valid values: in|out.
ipProtocol String
The protocol used by the ACL rule. The value is not case sensitive.
policy String
The policy used by the ACL rule. Valid values: accept|drop.
priority Integer
The priority of the ACL rule. Value range: 1 to 100.
sourceCidr String
The source address. It is an IPv4 address range in the CIDR format. Default value: 0.0.0.0/0.
sourcePortRange String
The range of the source port. Valid value: 80/80.
aclId string
The ID of the ACL.
description string
The description of the ACL rule. It must be 1 to 512 characters in length.
destCidr string
The destination address. It is an IPv4 address range in CIDR format. Default value: 0.0.0.0/0.
destPortRange string
The range of the destination port. Valid value: 80/80.
direction string
The direction of the ACL rule. Valid values: in|out.
ipProtocol string
The protocol used by the ACL rule. The value is not case sensitive.
policy string
The policy used by the ACL rule. Valid values: accept|drop.
priority number
The priority of the ACL rule. Value range: 1 to 100.
sourceCidr string
The source address. It is an IPv4 address range in the CIDR format. Default value: 0.0.0.0/0.
sourcePortRange string
The range of the source port. Valid value: 80/80.
acl_id str
The ID of the ACL.
description str
The description of the ACL rule. It must be 1 to 512 characters in length.
dest_cidr str
The destination address. It is an IPv4 address range in CIDR format. Default value: 0.0.0.0/0.
dest_port_range str
The range of the destination port. Valid value: 80/80.
direction str
The direction of the ACL rule. Valid values: in|out.
ip_protocol str
The protocol used by the ACL rule. The value is not case sensitive.
policy str
The policy used by the ACL rule. Valid values: accept|drop.
priority int
The priority of the ACL rule. Value range: 1 to 100.
source_cidr str
The source address. It is an IPv4 address range in the CIDR format. Default value: 0.0.0.0/0.
source_port_range str
The range of the source port. Valid value: 80/80.
aclId String
The ID of the ACL.
description String
The description of the ACL rule. It must be 1 to 512 characters in length.
destCidr String
The destination address. It is an IPv4 address range in CIDR format. Default value: 0.0.0.0/0.
destPortRange String
The range of the destination port. Valid value: 80/80.
direction String
The direction of the ACL rule. Valid values: in|out.
ipProtocol String
The protocol used by the ACL rule. The value is not case sensitive.
policy String
The policy used by the ACL rule. Valid values: accept|drop.
priority Number
The priority of the ACL rule. Value range: 1 to 100.
sourceCidr String
The source address. It is an IPv4 address range in the CIDR format. Default value: 0.0.0.0/0.
sourcePortRange String
The range of the source port. Valid value: 80/80.

Import

The Sag Acl Rule can be imported using the id, e.g.

$ pulumi import alicloud:sag/aclRule:AclRule example acr-abc123456
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.