1. Registry
  2. Packages
  3. Ucloud Provider
  4. API Docs
  5. SecGroupRule
Viewing docs for ucloud 1.49.0
published on Tuesday, Oct 27, 2026 by ucloud
ucloud
Viewing docs for ucloud 1.49.0
published on Tuesday, Oct 27, 2026 by ucloud

    Provides a rule of a security group. One resource manages exactly one rule, which is what lets a rule be changed in place, imported and destroyed without touching the rest of the group.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as ucloud from "@pulumi/ucloud";
    
    const example = new ucloud.SecGroupRule("example", {
        secGroupId: exampleUcloudSecGroup.id,
        direction: "Ingress",
        protocolType: "TCP",
        dstPort: "80,443",
        ipRange: "0.0.0.0/0",
        ruleAction: "Accept",
        priority: 60,
        remark: "web",
    });
    
    import pulumi
    import pulumi_ucloud as ucloud
    
    example = ucloud.SecGroupRule("example",
        sec_group_id=example_ucloud_sec_group["id"],
        direction="Ingress",
        protocol_type="TCP",
        dst_port="80,443",
        ip_range="0.0.0.0/0",
        rule_action="Accept",
        priority=60,
        remark="web")
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ucloud/ucloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := ucloud.NewSecGroupRule(ctx, "example", &ucloud.SecGroupRuleArgs{
    			SecGroupId:   pulumi.Any(exampleUcloudSecGroup.Id),
    			Direction:    pulumi.String("Ingress"),
    			ProtocolType: pulumi.String("TCP"),
    			DstPort:      pulumi.String("80,443"),
    			IpRange:      pulumi.String("0.0.0.0/0"),
    			RuleAction:   pulumi.String("Accept"),
    			Priority:     pulumi.Float64(60),
    			Remark:       pulumi.String("web"),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ucloud = Pulumi.Ucloud;
    
    return await Deployment.RunAsync(() => 
    {
        var example = new Ucloud.SecGroupRule("example", new()
        {
            SecGroupId = exampleUcloudSecGroup.Id,
            Direction = "Ingress",
            ProtocolType = "TCP",
            DstPort = "80,443",
            IpRange = "0.0.0.0/0",
            RuleAction = "Accept",
            Priority = 60,
            Remark = "web",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ucloud.SecGroupRule;
    import com.pulumi.ucloud.SecGroupRuleArgs;
    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) {
            var example = new SecGroupRule("example", SecGroupRuleArgs.builder()
                .secGroupId(exampleUcloudSecGroup.id())
                .direction("Ingress")
                .protocolType("TCP")
                .dstPort("80,443")
                .ipRange("0.0.0.0/0")
                .ruleAction("Accept")
                .priority(60.0)
                .remark("web")
                .build());
    
        }
    }
    
    resources:
      example:
        type: ucloud:SecGroupRule
        properties:
          secGroupId: ${exampleUcloudSecGroup.id}
          direction: Ingress
          protocolType: TCP
          dstPort: 80,443
          ipRange: 0.0.0.0/0
          ruleAction: Accept
          priority: 60
          remark: web
    
    Example coming soon!
    

    Create SecGroupRule Resource

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

    Constructor syntax

    new SecGroupRule(name: string, args: SecGroupRuleArgs, opts?: CustomResourceOptions);
    @overload
    def SecGroupRule(resource_name: str,
                     args: SecGroupRuleArgs,
                     opts: Optional[ResourceOptions] = None)
    
    @overload
    def SecGroupRule(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     direction: Optional[str] = None,
                     ip_range: Optional[str] = None,
                     priority: Optional[float] = None,
                     protocol_type: Optional[str] = None,
                     rule_action: Optional[str] = None,
                     sec_group_id: Optional[str] = None,
                     dst_port: Optional[str] = None,
                     remark: Optional[str] = None,
                     sec_group_rule_id: Optional[str] = None)
    func NewSecGroupRule(ctx *Context, name string, args SecGroupRuleArgs, opts ...ResourceOption) (*SecGroupRule, error)
    public SecGroupRule(string name, SecGroupRuleArgs args, CustomResourceOptions? opts = null)
    public SecGroupRule(String name, SecGroupRuleArgs args)
    public SecGroupRule(String name, SecGroupRuleArgs args, CustomResourceOptions options)
    
    type: ucloud:SecGroupRule
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "ucloud_sec_group_rule" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args SecGroupRuleArgs
    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 SecGroupRuleArgs
    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 SecGroupRuleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SecGroupRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SecGroupRuleArgs
    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 secGroupRuleResource = new Ucloud.SecGroupRule("secGroupRuleResource", new()
    {
        Direction = "string",
        IpRange = "string",
        Priority = 0.0,
        ProtocolType = "string",
        RuleAction = "string",
        SecGroupId = "string",
        DstPort = "string",
        Remark = "string",
        SecGroupRuleId = "string",
    });
    
    example, err := ucloud.NewSecGroupRule(ctx, "secGroupRuleResource", &ucloud.SecGroupRuleArgs{
    	Direction:      pulumi.String("string"),
    	IpRange:        pulumi.String("string"),
    	Priority:       pulumi.Float64(0),
    	ProtocolType:   pulumi.String("string"),
    	RuleAction:     pulumi.String("string"),
    	SecGroupId:     pulumi.String("string"),
    	DstPort:        pulumi.String("string"),
    	Remark:         pulumi.String("string"),
    	SecGroupRuleId: pulumi.String("string"),
    })
    
    resource "ucloud_sec_group_rule" "secGroupRuleResource" {
      lifecycle {
        create_before_destroy = true
      }
      direction         = "string"
      ip_range          = "string"
      priority          = 0
      protocol_type     = "string"
      rule_action       = "string"
      sec_group_id      = "string"
      dst_port          = "string"
      remark            = "string"
      sec_group_rule_id = "string"
    }
    
    var secGroupRuleResource = new SecGroupRule("secGroupRuleResource", SecGroupRuleArgs.builder()
        .direction("string")
        .ipRange("string")
        .priority(0.0)
        .protocolType("string")
        .ruleAction("string")
        .secGroupId("string")
        .dstPort("string")
        .remark("string")
        .secGroupRuleId("string")
        .build());
    
    sec_group_rule_resource = ucloud.SecGroupRule("secGroupRuleResource",
        direction="string",
        ip_range="string",
        priority=float(0),
        protocol_type="string",
        rule_action="string",
        sec_group_id="string",
        dst_port="string",
        remark="string",
        sec_group_rule_id="string")
    
    const secGroupRuleResource = new ucloud.SecGroupRule("secGroupRuleResource", {
        direction: "string",
        ipRange: "string",
        priority: 0,
        protocolType: "string",
        ruleAction: "string",
        secGroupId: "string",
        dstPort: "string",
        remark: "string",
        secGroupRuleId: "string",
    });
    
    type: ucloud:SecGroupRule
    properties:
        direction: string
        dstPort: string
        ipRange: string
        priority: 0
        protocolType: string
        remark: string
        ruleAction: string
        secGroupId: string
        secGroupRuleId: string
    

    SecGroupRule 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 SecGroupRule resource accepts the following input properties:

    Direction string
    The direction of the rule. Possible values are: Ingress, Egress.
    IpRange string
    The source the rule applies to, in one of three mutually exclusive forms: a comma separated list of CIDR blocks (e.g. 10.0.0.0/8 or 10.0.0.0/8,192.168.0.0/16), a single security group ID (e.g. secgroup-abc123), or a comma separated list of prefix list IDs (e.g. pl-abc123,pl-def456). The forms cannot be mixed. Whatever the form carries, it is one value of a single rule rather than a way to add several: exactly one rule is created.
    Priority double
    The priority of the rule, between 1 and 200. A smaller value means a higher priority.


    ProtocolType string
    The protocol type. Possible values are: TCP, UDP, ICMP, ICMPv6, ALL.
    RuleAction string
    The action of the rule. Possible values are: Accept, Drop.
    SecGroupId string
    The ID of the security group the rule belongs to, e.g. secgroup-abc123. The group is the rule's parent rather than one of its attributes, so changing it rebuilds the rule.
    DstPort string
    The destination port, a comma separated list where each item is a single port or a from-to range, e.g. 80,443 or 443,2000-10000. Required when protocol_type is TCP or UDP, and must be omitted when it is ICMP, ICMPv6 or ALL, where a port carries no meaning.
    Remark string
    The remarks of the rule. (Default: "").
    SecGroupRuleId string
    The ID of the rule, assigned by the API.
    Direction string
    The direction of the rule. Possible values are: Ingress, Egress.
    IpRange string
    The source the rule applies to, in one of three mutually exclusive forms: a comma separated list of CIDR blocks (e.g. 10.0.0.0/8 or 10.0.0.0/8,192.168.0.0/16), a single security group ID (e.g. secgroup-abc123), or a comma separated list of prefix list IDs (e.g. pl-abc123,pl-def456). The forms cannot be mixed. Whatever the form carries, it is one value of a single rule rather than a way to add several: exactly one rule is created.
    Priority float64
    The priority of the rule, between 1 and 200. A smaller value means a higher priority.


    ProtocolType string
    The protocol type. Possible values are: TCP, UDP, ICMP, ICMPv6, ALL.
    RuleAction string
    The action of the rule. Possible values are: Accept, Drop.
    SecGroupId string
    The ID of the security group the rule belongs to, e.g. secgroup-abc123. The group is the rule's parent rather than one of its attributes, so changing it rebuilds the rule.
    DstPort string
    The destination port, a comma separated list where each item is a single port or a from-to range, e.g. 80,443 or 443,2000-10000. Required when protocol_type is TCP or UDP, and must be omitted when it is ICMP, ICMPv6 or ALL, where a port carries no meaning.
    Remark string
    The remarks of the rule. (Default: "").
    SecGroupRuleId string
    The ID of the rule, assigned by the API.
    direction string
    The direction of the rule. Possible values are: Ingress, Egress.
    ip_range string
    The source the rule applies to, in one of three mutually exclusive forms: a comma separated list of CIDR blocks (e.g. 10.0.0.0/8 or 10.0.0.0/8,192.168.0.0/16), a single security group ID (e.g. secgroup-abc123), or a comma separated list of prefix list IDs (e.g. pl-abc123,pl-def456). The forms cannot be mixed. Whatever the form carries, it is one value of a single rule rather than a way to add several: exactly one rule is created.
    priority number
    The priority of the rule, between 1 and 200. A smaller value means a higher priority.


    protocol_type string
    The protocol type. Possible values are: TCP, UDP, ICMP, ICMPv6, ALL.
    rule_action string
    The action of the rule. Possible values are: Accept, Drop.
    sec_group_id string
    The ID of the security group the rule belongs to, e.g. secgroup-abc123. The group is the rule's parent rather than one of its attributes, so changing it rebuilds the rule.
    dst_port string
    The destination port, a comma separated list where each item is a single port or a from-to range, e.g. 80,443 or 443,2000-10000. Required when protocol_type is TCP or UDP, and must be omitted when it is ICMP, ICMPv6 or ALL, where a port carries no meaning.
    remark string
    The remarks of the rule. (Default: "").
    sec_group_rule_id string
    The ID of the rule, assigned by the API.
    direction String
    The direction of the rule. Possible values are: Ingress, Egress.
    ipRange String
    The source the rule applies to, in one of three mutually exclusive forms: a comma separated list of CIDR blocks (e.g. 10.0.0.0/8 or 10.0.0.0/8,192.168.0.0/16), a single security group ID (e.g. secgroup-abc123), or a comma separated list of prefix list IDs (e.g. pl-abc123,pl-def456). The forms cannot be mixed. Whatever the form carries, it is one value of a single rule rather than a way to add several: exactly one rule is created.
    priority Double
    The priority of the rule, between 1 and 200. A smaller value means a higher priority.


    protocolType String
    The protocol type. Possible values are: TCP, UDP, ICMP, ICMPv6, ALL.
    ruleAction String
    The action of the rule. Possible values are: Accept, Drop.
    secGroupId String
    The ID of the security group the rule belongs to, e.g. secgroup-abc123. The group is the rule's parent rather than one of its attributes, so changing it rebuilds the rule.
    dstPort String
    The destination port, a comma separated list where each item is a single port or a from-to range, e.g. 80,443 or 443,2000-10000. Required when protocol_type is TCP or UDP, and must be omitted when it is ICMP, ICMPv6 or ALL, where a port carries no meaning.
    remark String
    The remarks of the rule. (Default: "").
    secGroupRuleId String
    The ID of the rule, assigned by the API.
    direction string
    The direction of the rule. Possible values are: Ingress, Egress.
    ipRange string
    The source the rule applies to, in one of three mutually exclusive forms: a comma separated list of CIDR blocks (e.g. 10.0.0.0/8 or 10.0.0.0/8,192.168.0.0/16), a single security group ID (e.g. secgroup-abc123), or a comma separated list of prefix list IDs (e.g. pl-abc123,pl-def456). The forms cannot be mixed. Whatever the form carries, it is one value of a single rule rather than a way to add several: exactly one rule is created.
    priority number
    The priority of the rule, between 1 and 200. A smaller value means a higher priority.


    protocolType string
    The protocol type. Possible values are: TCP, UDP, ICMP, ICMPv6, ALL.
    ruleAction string
    The action of the rule. Possible values are: Accept, Drop.
    secGroupId string
    The ID of the security group the rule belongs to, e.g. secgroup-abc123. The group is the rule's parent rather than one of its attributes, so changing it rebuilds the rule.
    dstPort string
    The destination port, a comma separated list where each item is a single port or a from-to range, e.g. 80,443 or 443,2000-10000. Required when protocol_type is TCP or UDP, and must be omitted when it is ICMP, ICMPv6 or ALL, where a port carries no meaning.
    remark string
    The remarks of the rule. (Default: "").
    secGroupRuleId string
    The ID of the rule, assigned by the API.
    direction str
    The direction of the rule. Possible values are: Ingress, Egress.
    ip_range str
    The source the rule applies to, in one of three mutually exclusive forms: a comma separated list of CIDR blocks (e.g. 10.0.0.0/8 or 10.0.0.0/8,192.168.0.0/16), a single security group ID (e.g. secgroup-abc123), or a comma separated list of prefix list IDs (e.g. pl-abc123,pl-def456). The forms cannot be mixed. Whatever the form carries, it is one value of a single rule rather than a way to add several: exactly one rule is created.
    priority float
    The priority of the rule, between 1 and 200. A smaller value means a higher priority.


    protocol_type str
    The protocol type. Possible values are: TCP, UDP, ICMP, ICMPv6, ALL.
    rule_action str
    The action of the rule. Possible values are: Accept, Drop.
    sec_group_id str
    The ID of the security group the rule belongs to, e.g. secgroup-abc123. The group is the rule's parent rather than one of its attributes, so changing it rebuilds the rule.
    dst_port str
    The destination port, a comma separated list where each item is a single port or a from-to range, e.g. 80,443 or 443,2000-10000. Required when protocol_type is TCP or UDP, and must be omitted when it is ICMP, ICMPv6 or ALL, where a port carries no meaning.
    remark str
    The remarks of the rule. (Default: "").
    sec_group_rule_id str
    The ID of the rule, assigned by the API.
    direction String
    The direction of the rule. Possible values are: Ingress, Egress.
    ipRange String
    The source the rule applies to, in one of three mutually exclusive forms: a comma separated list of CIDR blocks (e.g. 10.0.0.0/8 or 10.0.0.0/8,192.168.0.0/16), a single security group ID (e.g. secgroup-abc123), or a comma separated list of prefix list IDs (e.g. pl-abc123,pl-def456). The forms cannot be mixed. Whatever the form carries, it is one value of a single rule rather than a way to add several: exactly one rule is created.
    priority Number
    The priority of the rule, between 1 and 200. A smaller value means a higher priority.


    protocolType String
    The protocol type. Possible values are: TCP, UDP, ICMP, ICMPv6, ALL.
    ruleAction String
    The action of the rule. Possible values are: Accept, Drop.
    secGroupId String
    The ID of the security group the rule belongs to, e.g. secgroup-abc123. The group is the rule's parent rather than one of its attributes, so changing it rebuilds the rule.
    dstPort String
    The destination port, a comma separated list where each item is a single port or a from-to range, e.g. 80,443 or 443,2000-10000. Required when protocol_type is TCP or UDP, and must be omitted when it is ICMP, ICMPv6 or ALL, where a port carries no meaning.
    remark String
    The remarks of the rule. (Default: "").
    secGroupRuleId String
    The ID of the rule, assigned by the API.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the SecGroupRule 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 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 SecGroupRule Resource

    Get an existing SecGroupRule 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?: SecGroupRuleState, opts?: CustomResourceOptions): SecGroupRule
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            direction: Optional[str] = None,
            dst_port: Optional[str] = None,
            ip_range: Optional[str] = None,
            priority: Optional[float] = None,
            protocol_type: Optional[str] = None,
            remark: Optional[str] = None,
            rule_action: Optional[str] = None,
            sec_group_id: Optional[str] = None,
            sec_group_rule_id: Optional[str] = None) -> SecGroupRule
    func GetSecGroupRule(ctx *Context, name string, id IDInput, state *SecGroupRuleState, opts ...ResourceOption) (*SecGroupRule, error)
    public static SecGroupRule Get(string name, Input<string> id, SecGroupRuleState? state, CustomResourceOptions? opts = null)
    public static SecGroupRule get(String name, Output<String> id, SecGroupRuleState state, CustomResourceOptions options)
    resources:  _:    type: ucloud:SecGroupRule    get:      id: ${id}
    import {
      to = ucloud_sec_group_rule.example
      id = "${id}"
    }
    
    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.
    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:
    Direction string
    The direction of the rule. Possible values are: Ingress, Egress.
    DstPort string
    The destination port, a comma separated list where each item is a single port or a from-to range, e.g. 80,443 or 443,2000-10000. Required when protocol_type is TCP or UDP, and must be omitted when it is ICMP, ICMPv6 or ALL, where a port carries no meaning.
    IpRange string
    The source the rule applies to, in one of three mutually exclusive forms: a comma separated list of CIDR blocks (e.g. 10.0.0.0/8 or 10.0.0.0/8,192.168.0.0/16), a single security group ID (e.g. secgroup-abc123), or a comma separated list of prefix list IDs (e.g. pl-abc123,pl-def456). The forms cannot be mixed. Whatever the form carries, it is one value of a single rule rather than a way to add several: exactly one rule is created.
    Priority double
    The priority of the rule, between 1 and 200. A smaller value means a higher priority.


    ProtocolType string
    The protocol type. Possible values are: TCP, UDP, ICMP, ICMPv6, ALL.
    Remark string
    The remarks of the rule. (Default: "").
    RuleAction string
    The action of the rule. Possible values are: Accept, Drop.
    SecGroupId string
    The ID of the security group the rule belongs to, e.g. secgroup-abc123. The group is the rule's parent rather than one of its attributes, so changing it rebuilds the rule.
    SecGroupRuleId string
    The ID of the rule, assigned by the API.
    Direction string
    The direction of the rule. Possible values are: Ingress, Egress.
    DstPort string
    The destination port, a comma separated list where each item is a single port or a from-to range, e.g. 80,443 or 443,2000-10000. Required when protocol_type is TCP or UDP, and must be omitted when it is ICMP, ICMPv6 or ALL, where a port carries no meaning.
    IpRange string
    The source the rule applies to, in one of three mutually exclusive forms: a comma separated list of CIDR blocks (e.g. 10.0.0.0/8 or 10.0.0.0/8,192.168.0.0/16), a single security group ID (e.g. secgroup-abc123), or a comma separated list of prefix list IDs (e.g. pl-abc123,pl-def456). The forms cannot be mixed. Whatever the form carries, it is one value of a single rule rather than a way to add several: exactly one rule is created.
    Priority float64
    The priority of the rule, between 1 and 200. A smaller value means a higher priority.


    ProtocolType string
    The protocol type. Possible values are: TCP, UDP, ICMP, ICMPv6, ALL.
    Remark string
    The remarks of the rule. (Default: "").
    RuleAction string
    The action of the rule. Possible values are: Accept, Drop.
    SecGroupId string
    The ID of the security group the rule belongs to, e.g. secgroup-abc123. The group is the rule's parent rather than one of its attributes, so changing it rebuilds the rule.
    SecGroupRuleId string
    The ID of the rule, assigned by the API.
    direction string
    The direction of the rule. Possible values are: Ingress, Egress.
    dst_port string
    The destination port, a comma separated list where each item is a single port or a from-to range, e.g. 80,443 or 443,2000-10000. Required when protocol_type is TCP or UDP, and must be omitted when it is ICMP, ICMPv6 or ALL, where a port carries no meaning.
    ip_range string
    The source the rule applies to, in one of three mutually exclusive forms: a comma separated list of CIDR blocks (e.g. 10.0.0.0/8 or 10.0.0.0/8,192.168.0.0/16), a single security group ID (e.g. secgroup-abc123), or a comma separated list of prefix list IDs (e.g. pl-abc123,pl-def456). The forms cannot be mixed. Whatever the form carries, it is one value of a single rule rather than a way to add several: exactly one rule is created.
    priority number
    The priority of the rule, between 1 and 200. A smaller value means a higher priority.


    protocol_type string
    The protocol type. Possible values are: TCP, UDP, ICMP, ICMPv6, ALL.
    remark string
    The remarks of the rule. (Default: "").
    rule_action string
    The action of the rule. Possible values are: Accept, Drop.
    sec_group_id string
    The ID of the security group the rule belongs to, e.g. secgroup-abc123. The group is the rule's parent rather than one of its attributes, so changing it rebuilds the rule.
    sec_group_rule_id string
    The ID of the rule, assigned by the API.
    direction String
    The direction of the rule. Possible values are: Ingress, Egress.
    dstPort String
    The destination port, a comma separated list where each item is a single port or a from-to range, e.g. 80,443 or 443,2000-10000. Required when protocol_type is TCP or UDP, and must be omitted when it is ICMP, ICMPv6 or ALL, where a port carries no meaning.
    ipRange String
    The source the rule applies to, in one of three mutually exclusive forms: a comma separated list of CIDR blocks (e.g. 10.0.0.0/8 or 10.0.0.0/8,192.168.0.0/16), a single security group ID (e.g. secgroup-abc123), or a comma separated list of prefix list IDs (e.g. pl-abc123,pl-def456). The forms cannot be mixed. Whatever the form carries, it is one value of a single rule rather than a way to add several: exactly one rule is created.
    priority Double
    The priority of the rule, between 1 and 200. A smaller value means a higher priority.


    protocolType String
    The protocol type. Possible values are: TCP, UDP, ICMP, ICMPv6, ALL.
    remark String
    The remarks of the rule. (Default: "").
    ruleAction String
    The action of the rule. Possible values are: Accept, Drop.
    secGroupId String
    The ID of the security group the rule belongs to, e.g. secgroup-abc123. The group is the rule's parent rather than one of its attributes, so changing it rebuilds the rule.
    secGroupRuleId String
    The ID of the rule, assigned by the API.
    direction string
    The direction of the rule. Possible values are: Ingress, Egress.
    dstPort string
    The destination port, a comma separated list where each item is a single port or a from-to range, e.g. 80,443 or 443,2000-10000. Required when protocol_type is TCP or UDP, and must be omitted when it is ICMP, ICMPv6 or ALL, where a port carries no meaning.
    ipRange string
    The source the rule applies to, in one of three mutually exclusive forms: a comma separated list of CIDR blocks (e.g. 10.0.0.0/8 or 10.0.0.0/8,192.168.0.0/16), a single security group ID (e.g. secgroup-abc123), or a comma separated list of prefix list IDs (e.g. pl-abc123,pl-def456). The forms cannot be mixed. Whatever the form carries, it is one value of a single rule rather than a way to add several: exactly one rule is created.
    priority number
    The priority of the rule, between 1 and 200. A smaller value means a higher priority.


    protocolType string
    The protocol type. Possible values are: TCP, UDP, ICMP, ICMPv6, ALL.
    remark string
    The remarks of the rule. (Default: "").
    ruleAction string
    The action of the rule. Possible values are: Accept, Drop.
    secGroupId string
    The ID of the security group the rule belongs to, e.g. secgroup-abc123. The group is the rule's parent rather than one of its attributes, so changing it rebuilds the rule.
    secGroupRuleId string
    The ID of the rule, assigned by the API.
    direction str
    The direction of the rule. Possible values are: Ingress, Egress.
    dst_port str
    The destination port, a comma separated list where each item is a single port or a from-to range, e.g. 80,443 or 443,2000-10000. Required when protocol_type is TCP or UDP, and must be omitted when it is ICMP, ICMPv6 or ALL, where a port carries no meaning.
    ip_range str
    The source the rule applies to, in one of three mutually exclusive forms: a comma separated list of CIDR blocks (e.g. 10.0.0.0/8 or 10.0.0.0/8,192.168.0.0/16), a single security group ID (e.g. secgroup-abc123), or a comma separated list of prefix list IDs (e.g. pl-abc123,pl-def456). The forms cannot be mixed. Whatever the form carries, it is one value of a single rule rather than a way to add several: exactly one rule is created.
    priority float
    The priority of the rule, between 1 and 200. A smaller value means a higher priority.


    protocol_type str
    The protocol type. Possible values are: TCP, UDP, ICMP, ICMPv6, ALL.
    remark str
    The remarks of the rule. (Default: "").
    rule_action str
    The action of the rule. Possible values are: Accept, Drop.
    sec_group_id str
    The ID of the security group the rule belongs to, e.g. secgroup-abc123. The group is the rule's parent rather than one of its attributes, so changing it rebuilds the rule.
    sec_group_rule_id str
    The ID of the rule, assigned by the API.
    direction String
    The direction of the rule. Possible values are: Ingress, Egress.
    dstPort String
    The destination port, a comma separated list where each item is a single port or a from-to range, e.g. 80,443 or 443,2000-10000. Required when protocol_type is TCP or UDP, and must be omitted when it is ICMP, ICMPv6 or ALL, where a port carries no meaning.
    ipRange String
    The source the rule applies to, in one of three mutually exclusive forms: a comma separated list of CIDR blocks (e.g. 10.0.0.0/8 or 10.0.0.0/8,192.168.0.0/16), a single security group ID (e.g. secgroup-abc123), or a comma separated list of prefix list IDs (e.g. pl-abc123,pl-def456). The forms cannot be mixed. Whatever the form carries, it is one value of a single rule rather than a way to add several: exactly one rule is created.
    priority Number
    The priority of the rule, between 1 and 200. A smaller value means a higher priority.


    protocolType String
    The protocol type. Possible values are: TCP, UDP, ICMP, ICMPv6, ALL.
    remark String
    The remarks of the rule. (Default: "").
    ruleAction String
    The action of the rule. Possible values are: Accept, Drop.
    secGroupId String
    The ID of the security group the rule belongs to, e.g. secgroup-abc123. The group is the rule's parent rather than one of its attributes, so changing it rebuilds the rule.
    secGroupRuleId String
    The ID of the rule, assigned by the API.

    Import

    Security Group Rule can be imported using the ID of its group and the ID of the rule, separated by a slash, e.g.

    $ pulumi import ucloud:index/secGroupRule:SecGroupRule example secgroup-abc123456/rule-def789012
    

    ~> Note The group has to be part of the import ID because the API cannot look a rule up from its own ID alone.

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

    Package Details

    Repository
    ucloud ucloud/terraform-provider-ucloud
    License
    Notes
    This Pulumi package is based on the ucloud Terraform Provider.
    ucloud
    Viewing docs for ucloud 1.49.0
    published on Tuesday, Oct 27, 2026 by ucloud

      Try Pulumi Cloud free.
      Your team will thank you.

      Start free trial