1. Registry
  2. Packages
  3. Ucloud Provider
  4. API Docs
  5. SecGroup
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 Security Group resource, which belongs to a VPC.

    Note This resource manages the VPC SecGroup API, not the Firewall API behind ucloud.SecurityGroup. The two are different objects with different IDs and different rule models, and they are not interchangeable.

    Note Rules are not part of this resource. Each one is managed by ucloud.SecGroupRule, so that a rule can be changed in place, imported and destroyed on its own.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as ucloud from "@pulumi/ucloud";
    
    const example = new ucloud.Vpc("example", {
        name: "tf-example-vpc",
        tag: "tf-example",
        cidrBlocks: ["192.168.0.0/16"],
    });
    const exampleSecGroup = new ucloud.SecGroup("example", {
        name: "tf-example-sec-group",
        vpcId: example.vpcId,
        remark: "managed by terraform",
    });
    const exampleSecGroupRule = new ucloud.SecGroupRule("example", {
        secGroupId: exampleSecGroup.secGroupId,
        direction: "Ingress",
        protocolType: "TCP",
        dstPort: "22",
        ipRange: "10.0.0.0/8",
        ruleAction: "Accept",
        priority: 50,
        remark: "ssh",
    });
    
    import pulumi
    import pulumi_ucloud as ucloud
    
    example = ucloud.Vpc("example",
        name="tf-example-vpc",
        tag="tf-example",
        cidr_blocks=["192.168.0.0/16"])
    example_sec_group = ucloud.SecGroup("example",
        name="tf-example-sec-group",
        vpc_id=example.vpc_id,
        remark="managed by terraform")
    example_sec_group_rule = ucloud.SecGroupRule("example",
        sec_group_id=example_sec_group.sec_group_id,
        direction="Ingress",
        protocol_type="TCP",
        dst_port="22",
        ip_range="10.0.0.0/8",
        rule_action="Accept",
        priority=50,
        remark="ssh")
    
    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 {
    		example, err := ucloud.NewVpc(ctx, "example", &ucloud.VpcArgs{
    			Name: pulumi.String("tf-example-vpc"),
    			Tag:  pulumi.String("tf-example"),
    			CidrBlocks: pulumi.StringArray{
    				pulumi.String("192.168.0.0/16"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		exampleSecGroup, err := ucloud.NewSecGroup(ctx, "example", &ucloud.SecGroupArgs{
    			Name:   pulumi.String("tf-example-sec-group"),
    			VpcId:  example.VpcId,
    			Remark: pulumi.String("managed by terraform"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = ucloud.NewSecGroupRule(ctx, "example", &ucloud.SecGroupRuleArgs{
    			SecGroupId:   exampleSecGroup.SecGroupId,
    			Direction:    pulumi.String("Ingress"),
    			ProtocolType: pulumi.String("TCP"),
    			DstPort:      pulumi.String("22"),
    			IpRange:      pulumi.String("10.0.0.0/8"),
    			RuleAction:   pulumi.String("Accept"),
    			Priority:     pulumi.Float64(50),
    			Remark:       pulumi.String("ssh"),
    		})
    		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.Vpc("example", new()
        {
            Name = "tf-example-vpc",
            Tag = "tf-example",
            CidrBlocks = new[]
            {
                "192.168.0.0/16",
            },
        });
    
        var exampleSecGroup = new Ucloud.SecGroup("example", new()
        {
            Name = "tf-example-sec-group",
            VpcId = example.VpcId,
            Remark = "managed by terraform",
        });
    
        var exampleSecGroupRule = new Ucloud.SecGroupRule("example", new()
        {
            SecGroupId = exampleSecGroup.SecGroupId,
            Direction = "Ingress",
            ProtocolType = "TCP",
            DstPort = "22",
            IpRange = "10.0.0.0/8",
            RuleAction = "Accept",
            Priority = 50,
            Remark = "ssh",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ucloud.Vpc;
    import com.pulumi.ucloud.VpcArgs;
    import com.pulumi.ucloud.SecGroup;
    import com.pulumi.ucloud.SecGroupArgs;
    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 Vpc("example", VpcArgs.builder()
                .name("tf-example-vpc")
                .tag("tf-example")
                .cidrBlocks("192.168.0.0/16")
                .build());
    
            var exampleSecGroup = new SecGroup("exampleSecGroup", SecGroupArgs.builder()
                .name("tf-example-sec-group")
                .vpcId(example.vpcId())
                .remark("managed by terraform")
                .build());
    
            var exampleSecGroupRule = new SecGroupRule("exampleSecGroupRule", SecGroupRuleArgs.builder()
                .secGroupId(exampleSecGroup.secGroupId())
                .direction("Ingress")
                .protocolType("TCP")
                .dstPort("22")
                .ipRange("10.0.0.0/8")
                .ruleAction("Accept")
                .priority(50.0)
                .remark("ssh")
                .build());
    
        }
    }
    
    resources:
      example:
        type: ucloud:Vpc
        properties:
          name: tf-example-vpc
          tag: tf-example
          cidrBlocks:
            - 192.168.0.0/16
      exampleSecGroup:
        type: ucloud:SecGroup
        name: example
        properties:
          name: tf-example-sec-group
          vpcId: ${example.vpcId}
          remark: managed by terraform
      exampleSecGroupRule:
        type: ucloud:SecGroupRule
        name: example
        properties:
          secGroupId: ${exampleSecGroup.secGroupId}
          direction: Ingress
          protocolType: TCP
          dstPort: '22'
          ipRange: 10.0.0.0/8
          ruleAction: Accept
          priority: 50
          remark: ssh
    
    Example coming soon!
    

    Create SecGroup Resource

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

    Constructor syntax

    new SecGroup(name: string, args: SecGroupArgs, opts?: CustomResourceOptions);
    @overload
    def SecGroup(resource_name: str,
                 args: SecGroupArgs,
                 opts: Optional[ResourceOptions] = None)
    
    @overload
    def SecGroup(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 vpc_id: Optional[str] = None,
                 name: Optional[str] = None,
                 remark: Optional[str] = None,
                 sec_group_id: Optional[str] = None)
    func NewSecGroup(ctx *Context, name string, args SecGroupArgs, opts ...ResourceOption) (*SecGroup, error)
    public SecGroup(string name, SecGroupArgs args, CustomResourceOptions? opts = null)
    public SecGroup(String name, SecGroupArgs args)
    public SecGroup(String name, SecGroupArgs args, CustomResourceOptions options)
    
    type: ucloud:SecGroup
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    resource "ucloud_sec_group" "name" {
        # resource properties
    }

    Parameters

    name string
    The unique name of the resource.
    args SecGroupArgs
    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 SecGroupArgs
    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 SecGroupArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SecGroupArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SecGroupArgs
    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 secGroupResource = new Ucloud.SecGroup("secGroupResource", new()
    {
        VpcId = "string",
        Name = "string",
        Remark = "string",
        SecGroupId = "string",
    });
    
    example, err := ucloud.NewSecGroup(ctx, "secGroupResource", &ucloud.SecGroupArgs{
    	VpcId:      pulumi.String("string"),
    	Name:       pulumi.String("string"),
    	Remark:     pulumi.String("string"),
    	SecGroupId: pulumi.String("string"),
    })
    
    resource "ucloud_sec_group" "secGroupResource" {
      lifecycle {
        create_before_destroy = true
      }
      vpc_id       = "string"
      name         = "string"
      remark       = "string"
      sec_group_id = "string"
    }
    
    var secGroupResource = new SecGroup("secGroupResource", SecGroupArgs.builder()
        .vpcId("string")
        .name("string")
        .remark("string")
        .secGroupId("string")
        .build());
    
    sec_group_resource = ucloud.SecGroup("secGroupResource",
        vpc_id="string",
        name="string",
        remark="string",
        sec_group_id="string")
    
    const secGroupResource = new ucloud.SecGroup("secGroupResource", {
        vpcId: "string",
        name: "string",
        remark: "string",
        secGroupId: "string",
    });
    
    type: ucloud:SecGroup
    properties:
        name: string
        remark: string
        secGroupId: string
        vpcId: string
    

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

    VpcId string
    The ID of the VPC the security group belongs to.


    Name string
    Remark string
    The remarks of the security group. (Default: "").
    SecGroupId string
    The ID of the security group.
    VpcId string
    The ID of the VPC the security group belongs to.


    Name string
    Remark string
    The remarks of the security group. (Default: "").
    SecGroupId string
    The ID of the security group.
    vpc_id string
    The ID of the VPC the security group belongs to.


    name string
    remark string
    The remarks of the security group. (Default: "").
    sec_group_id string
    The ID of the security group.
    vpcId String
    The ID of the VPC the security group belongs to.


    name String
    remark String
    The remarks of the security group. (Default: "").
    secGroupId String
    The ID of the security group.
    vpcId string
    The ID of the VPC the security group belongs to.


    name string
    remark string
    The remarks of the security group. (Default: "").
    secGroupId string
    The ID of the security group.
    vpc_id str
    The ID of the VPC the security group belongs to.


    name str
    remark str
    The remarks of the security group. (Default: "").
    sec_group_id str
    The ID of the security group.
    vpcId String
    The ID of the VPC the security group belongs to.


    name String
    remark String
    The remarks of the security group. (Default: "").
    secGroupId String
    The ID of the security group.

    Outputs

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

    CreateTime string
    The time of creation for the security group, formatted in RFC3339 time string.
    Id string
    The provider-assigned unique ID for this managed resource.
    Tag string
    A tag assigned to the security group.
    Type string
    The type of the security group.
    CreateTime string
    The time of creation for the security group, formatted in RFC3339 time string.
    Id string
    The provider-assigned unique ID for this managed resource.
    Tag string
    A tag assigned to the security group.
    Type string
    The type of the security group.
    create_time string
    The time of creation for the security group, formatted in RFC3339 time string.
    id string
    The provider-assigned unique ID for this managed resource.
    tag string
    A tag assigned to the security group.
    type string
    The type of the security group.
    createTime String
    The time of creation for the security group, formatted in RFC3339 time string.
    id String
    The provider-assigned unique ID for this managed resource.
    tag String
    A tag assigned to the security group.
    type String
    The type of the security group.
    createTime string
    The time of creation for the security group, formatted in RFC3339 time string.
    id string
    The provider-assigned unique ID for this managed resource.
    tag string
    A tag assigned to the security group.
    type string
    The type of the security group.
    create_time str
    The time of creation for the security group, formatted in RFC3339 time string.
    id str
    The provider-assigned unique ID for this managed resource.
    tag str
    A tag assigned to the security group.
    type str
    The type of the security group.
    createTime String
    The time of creation for the security group, formatted in RFC3339 time string.
    id String
    The provider-assigned unique ID for this managed resource.
    tag String
    A tag assigned to the security group.
    type String
    The type of the security group.

    Look up Existing SecGroup Resource

    Get an existing SecGroup 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?: SecGroupState, opts?: CustomResourceOptions): SecGroup
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            create_time: Optional[str] = None,
            name: Optional[str] = None,
            remark: Optional[str] = None,
            sec_group_id: Optional[str] = None,
            tag: Optional[str] = None,
            type: Optional[str] = None,
            vpc_id: Optional[str] = None) -> SecGroup
    func GetSecGroup(ctx *Context, name string, id IDInput, state *SecGroupState, opts ...ResourceOption) (*SecGroup, error)
    public static SecGroup Get(string name, Input<string> id, SecGroupState? state, CustomResourceOptions? opts = null)
    public static SecGroup get(String name, Output<String> id, SecGroupState state, CustomResourceOptions options)
    resources:  _:    type: ucloud:SecGroup    get:      id: ${id}
    import {
      to = ucloud_sec_group.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:
    CreateTime string
    The time of creation for the security group, formatted in RFC3339 time string.
    Name string
    Remark string
    The remarks of the security group. (Default: "").
    SecGroupId string
    The ID of the security group.
    Tag string
    A tag assigned to the security group.
    Type string
    The type of the security group.
    VpcId string
    The ID of the VPC the security group belongs to.


    CreateTime string
    The time of creation for the security group, formatted in RFC3339 time string.
    Name string
    Remark string
    The remarks of the security group. (Default: "").
    SecGroupId string
    The ID of the security group.
    Tag string
    A tag assigned to the security group.
    Type string
    The type of the security group.
    VpcId string
    The ID of the VPC the security group belongs to.


    create_time string
    The time of creation for the security group, formatted in RFC3339 time string.
    name string
    remark string
    The remarks of the security group. (Default: "").
    sec_group_id string
    The ID of the security group.
    tag string
    A tag assigned to the security group.
    type string
    The type of the security group.
    vpc_id string
    The ID of the VPC the security group belongs to.


    createTime String
    The time of creation for the security group, formatted in RFC3339 time string.
    name String
    remark String
    The remarks of the security group. (Default: "").
    secGroupId String
    The ID of the security group.
    tag String
    A tag assigned to the security group.
    type String
    The type of the security group.
    vpcId String
    The ID of the VPC the security group belongs to.


    createTime string
    The time of creation for the security group, formatted in RFC3339 time string.
    name string
    remark string
    The remarks of the security group. (Default: "").
    secGroupId string
    The ID of the security group.
    tag string
    A tag assigned to the security group.
    type string
    The type of the security group.
    vpcId string
    The ID of the VPC the security group belongs to.


    create_time str
    The time of creation for the security group, formatted in RFC3339 time string.
    name str
    remark str
    The remarks of the security group. (Default: "").
    sec_group_id str
    The ID of the security group.
    tag str
    A tag assigned to the security group.
    type str
    The type of the security group.
    vpc_id str
    The ID of the VPC the security group belongs to.


    createTime String
    The time of creation for the security group, formatted in RFC3339 time string.
    name String
    remark String
    The remarks of the security group. (Default: "").
    secGroupId String
    The ID of the security group.
    tag String
    A tag assigned to the security group.
    type String
    The type of the security group.
    vpcId String
    The ID of the VPC the security group belongs to.


    Import

    Security Group can be imported using the id, e.g.

    $ pulumi import ucloud:index/secGroup:SecGroup example secgroup-abc123456
    

    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