1. Packages
  2. Tencentcloud Provider
  3. API Docs
  4. SgRule
tencentcloud 1.81.187 published on Monday, Apr 28, 2025 by tencentcloudstack

tencentcloud.SgRule

Explore with Pulumi AI

Provides a resource to create a cfw sg_rule

Example Usage

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

const sgRule = new tencentcloud.SgRule("sgRule", {
    data: {
        description: "1111112",
        destContent: "0.0.0.0/0",
        destType: "net",
        port: "-1/-1",
        protocol: "ANY",
        ruleAction: "accept",
        serviceTemplateId: "ppm-l9u5pf1y",
        sourceContent: "0.0.0.0/0",
        sourceType: "net",
    },
    enable: 1,
});
Copy
import pulumi
import pulumi_tencentcloud as tencentcloud

sg_rule = tencentcloud.SgRule("sgRule",
    data={
        "description": "1111112",
        "dest_content": "0.0.0.0/0",
        "dest_type": "net",
        "port": "-1/-1",
        "protocol": "ANY",
        "rule_action": "accept",
        "service_template_id": "ppm-l9u5pf1y",
        "source_content": "0.0.0.0/0",
        "source_type": "net",
    },
    enable=1)
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/tencentcloud/tencentcloud"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := tencentcloud.NewSgRule(ctx, "sgRule", &tencentcloud.SgRuleArgs{
			Data: &tencentcloud.SgRuleDataArgs{
				Description:       pulumi.String("1111112"),
				DestContent:       pulumi.String("0.0.0.0/0"),
				DestType:          pulumi.String("net"),
				Port:              pulumi.String("-1/-1"),
				Protocol:          pulumi.String("ANY"),
				RuleAction:        pulumi.String("accept"),
				ServiceTemplateId: pulumi.String("ppm-l9u5pf1y"),
				SourceContent:     pulumi.String("0.0.0.0/0"),
				SourceType:        pulumi.String("net"),
			},
			Enable: pulumi.Float64(1),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Tencentcloud = Pulumi.Tencentcloud;

return await Deployment.RunAsync(() => 
{
    var sgRule = new Tencentcloud.SgRule("sgRule", new()
    {
        Data = new Tencentcloud.Inputs.SgRuleDataArgs
        {
            Description = "1111112",
            DestContent = "0.0.0.0/0",
            DestType = "net",
            Port = "-1/-1",
            Protocol = "ANY",
            RuleAction = "accept",
            ServiceTemplateId = "ppm-l9u5pf1y",
            SourceContent = "0.0.0.0/0",
            SourceType = "net",
        },
        Enable = 1,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.tencentcloud.SgRule;
import com.pulumi.tencentcloud.SgRuleArgs;
import com.pulumi.tencentcloud.inputs.SgRuleDataArgs;
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 sgRule = new SgRule("sgRule", SgRuleArgs.builder()
            .data(SgRuleDataArgs.builder()
                .description("1111112")
                .destContent("0.0.0.0/0")
                .destType("net")
                .port("-1/-1")
                .protocol("ANY")
                .ruleAction("accept")
                .serviceTemplateId("ppm-l9u5pf1y")
                .sourceContent("0.0.0.0/0")
                .sourceType("net")
                .build())
            .enable(1)
            .build());

    }
}
Copy
resources:
  sgRule:
    type: tencentcloud:SgRule
    properties:
      data:
        description: '1111112'
        destContent: 0.0.0.0/0
        destType: net
        port: -1/-1
        protocol: ANY
        ruleAction: accept
        serviceTemplateId: ppm-l9u5pf1y
        sourceContent: 0.0.0.0/0
        sourceType: net
      enable: 1
Copy

Create SgRule Resource

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

Constructor syntax

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

@overload
def SgRule(resource_name: str,
           opts: Optional[ResourceOptions] = None,
           data: Optional[SgRuleDataArgs] = None,
           enable: Optional[float] = None,
           sg_rule_id: Optional[str] = None)
func NewSgRule(ctx *Context, name string, args SgRuleArgs, opts ...ResourceOption) (*SgRule, error)
public SgRule(string name, SgRuleArgs args, CustomResourceOptions? opts = null)
public SgRule(String name, SgRuleArgs args)
public SgRule(String name, SgRuleArgs args, CustomResourceOptions options)
type: tencentcloud:SgRule
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. SgRuleArgs
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. SgRuleArgs
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. SgRuleArgs
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. SgRuleArgs
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. SgRuleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

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

Data This property is required. SgRuleData
Creates rule data.
Enable double
Rule status. 0 is off, 1 is on. This parameter is not required or is 1 when creating.
SgRuleId string
ID of the resource.
Data This property is required. SgRuleDataArgs
Creates rule data.
Enable float64
Rule status. 0 is off, 1 is on. This parameter is not required or is 1 when creating.
SgRuleId string
ID of the resource.
data This property is required. SgRuleData
Creates rule data.
enable Double
Rule status. 0 is off, 1 is on. This parameter is not required or is 1 when creating.
sgRuleId String
ID of the resource.
data This property is required. SgRuleData
Creates rule data.
enable number
Rule status. 0 is off, 1 is on. This parameter is not required or is 1 when creating.
sgRuleId string
ID of the resource.
data This property is required. SgRuleDataArgs
Creates rule data.
enable float
Rule status. 0 is off, 1 is on. This parameter is not required or is 1 when creating.
sg_rule_id str
ID of the resource.
data This property is required. Property Map
Creates rule data.
enable Number
Rule status. 0 is off, 1 is on. This parameter is not required or is 1 when creating.
sgRuleId String
ID of the resource.

Outputs

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

Get an existing SgRule 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?: SgRuleState, opts?: CustomResourceOptions): SgRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        data: Optional[SgRuleDataArgs] = None,
        enable: Optional[float] = None,
        sg_rule_id: Optional[str] = None) -> SgRule
func GetSgRule(ctx *Context, name string, id IDInput, state *SgRuleState, opts ...ResourceOption) (*SgRule, error)
public static SgRule Get(string name, Input<string> id, SgRuleState? state, CustomResourceOptions? opts = null)
public static SgRule get(String name, Output<String> id, SgRuleState state, CustomResourceOptions options)
resources:  _:    type: tencentcloud:SgRule    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:
Data SgRuleData
Creates rule data.
Enable double
Rule status. 0 is off, 1 is on. This parameter is not required or is 1 when creating.
SgRuleId string
ID of the resource.
Data SgRuleDataArgs
Creates rule data.
Enable float64
Rule status. 0 is off, 1 is on. This parameter is not required or is 1 when creating.
SgRuleId string
ID of the resource.
data SgRuleData
Creates rule data.
enable Double
Rule status. 0 is off, 1 is on. This parameter is not required or is 1 when creating.
sgRuleId String
ID of the resource.
data SgRuleData
Creates rule data.
enable number
Rule status. 0 is off, 1 is on. This parameter is not required or is 1 when creating.
sgRuleId string
ID of the resource.
data SgRuleDataArgs
Creates rule data.
enable float
Rule status. 0 is off, 1 is on. This parameter is not required or is 1 when creating.
sg_rule_id str
ID of the resource.
data Property Map
Creates rule data.
enable Number
Rule status. 0 is off, 1 is on. This parameter is not required or is 1 when creating.
sgRuleId String
ID of the resource.

Supporting Types

SgRuleData
, SgRuleDataArgs

Description This property is required. string
Description.
DestContent This property is required. string
Destination example: net: IP/CIDR (192.168.0.2); template: parameter template (ipm-dyodhpby); instance: asset instance (ins-123456); resourcegroup: asset group (/all groups/group 1/subgroup 1); tag: resource tag ({"Key":"tag key","Value":"tag value"}); region: region (ap-gaungzhou).
DestType This property is required. string
Access destination type. Valid values: net|template|instance|resourcegroup|tag|region.
RuleAction This property is required. string
The action that Cloud Firewall performs on the traffic. Valid values: accept: allow, drop: deny.
SourceContent This property is required. string
Source example: net: IP/CIDR (192.168.0.2); template: parameter template (ipm-dyodhpby); instance: asset instance (ins-123456); resourcegroup: asset group (/all groups/group 1/subgroup 1); tag: resource tag ({"Key":"tag key","Value":"tag value"}); region: region (ap-gaungzhou).
SourceType This property is required. string
Access source type. Valid values: net|template|instance|resourcegroup|tag|region.
OrderIndex string
Rule priority.
Port string
The port to apply access control rules. Valid values: -1/-1: all ports, 80: port 80.
Protocol string
Protocol. TCP/UDP/ICMP/ANY.
ServiceTemplateId string
Parameter template ID of port and protocol type; mutually exclusive with Protocol and Port.
Description This property is required. string
Description.
DestContent This property is required. string
Destination example: net: IP/CIDR (192.168.0.2); template: parameter template (ipm-dyodhpby); instance: asset instance (ins-123456); resourcegroup: asset group (/all groups/group 1/subgroup 1); tag: resource tag ({"Key":"tag key","Value":"tag value"}); region: region (ap-gaungzhou).
DestType This property is required. string
Access destination type. Valid values: net|template|instance|resourcegroup|tag|region.
RuleAction This property is required. string
The action that Cloud Firewall performs on the traffic. Valid values: accept: allow, drop: deny.
SourceContent This property is required. string
Source example: net: IP/CIDR (192.168.0.2); template: parameter template (ipm-dyodhpby); instance: asset instance (ins-123456); resourcegroup: asset group (/all groups/group 1/subgroup 1); tag: resource tag ({"Key":"tag key","Value":"tag value"}); region: region (ap-gaungzhou).
SourceType This property is required. string
Access source type. Valid values: net|template|instance|resourcegroup|tag|region.
OrderIndex string
Rule priority.
Port string
The port to apply access control rules. Valid values: -1/-1: all ports, 80: port 80.
Protocol string
Protocol. TCP/UDP/ICMP/ANY.
ServiceTemplateId string
Parameter template ID of port and protocol type; mutually exclusive with Protocol and Port.
description This property is required. String
Description.
destContent This property is required. String
Destination example: net: IP/CIDR (192.168.0.2); template: parameter template (ipm-dyodhpby); instance: asset instance (ins-123456); resourcegroup: asset group (/all groups/group 1/subgroup 1); tag: resource tag ({"Key":"tag key","Value":"tag value"}); region: region (ap-gaungzhou).
destType This property is required. String
Access destination type. Valid values: net|template|instance|resourcegroup|tag|region.
ruleAction This property is required. String
The action that Cloud Firewall performs on the traffic. Valid values: accept: allow, drop: deny.
sourceContent This property is required. String
Source example: net: IP/CIDR (192.168.0.2); template: parameter template (ipm-dyodhpby); instance: asset instance (ins-123456); resourcegroup: asset group (/all groups/group 1/subgroup 1); tag: resource tag ({"Key":"tag key","Value":"tag value"}); region: region (ap-gaungzhou).
sourceType This property is required. String
Access source type. Valid values: net|template|instance|resourcegroup|tag|region.
orderIndex String
Rule priority.
port String
The port to apply access control rules. Valid values: -1/-1: all ports, 80: port 80.
protocol String
Protocol. TCP/UDP/ICMP/ANY.
serviceTemplateId String
Parameter template ID of port and protocol type; mutually exclusive with Protocol and Port.
description This property is required. string
Description.
destContent This property is required. string
Destination example: net: IP/CIDR (192.168.0.2); template: parameter template (ipm-dyodhpby); instance: asset instance (ins-123456); resourcegroup: asset group (/all groups/group 1/subgroup 1); tag: resource tag ({"Key":"tag key","Value":"tag value"}); region: region (ap-gaungzhou).
destType This property is required. string
Access destination type. Valid values: net|template|instance|resourcegroup|tag|region.
ruleAction This property is required. string
The action that Cloud Firewall performs on the traffic. Valid values: accept: allow, drop: deny.
sourceContent This property is required. string
Source example: net: IP/CIDR (192.168.0.2); template: parameter template (ipm-dyodhpby); instance: asset instance (ins-123456); resourcegroup: asset group (/all groups/group 1/subgroup 1); tag: resource tag ({"Key":"tag key","Value":"tag value"}); region: region (ap-gaungzhou).
sourceType This property is required. string
Access source type. Valid values: net|template|instance|resourcegroup|tag|region.
orderIndex string
Rule priority.
port string
The port to apply access control rules. Valid values: -1/-1: all ports, 80: port 80.
protocol string
Protocol. TCP/UDP/ICMP/ANY.
serviceTemplateId string
Parameter template ID of port and protocol type; mutually exclusive with Protocol and Port.
description This property is required. str
Description.
dest_content This property is required. str
Destination example: net: IP/CIDR (192.168.0.2); template: parameter template (ipm-dyodhpby); instance: asset instance (ins-123456); resourcegroup: asset group (/all groups/group 1/subgroup 1); tag: resource tag ({"Key":"tag key","Value":"tag value"}); region: region (ap-gaungzhou).
dest_type This property is required. str
Access destination type. Valid values: net|template|instance|resourcegroup|tag|region.
rule_action This property is required. str
The action that Cloud Firewall performs on the traffic. Valid values: accept: allow, drop: deny.
source_content This property is required. str
Source example: net: IP/CIDR (192.168.0.2); template: parameter template (ipm-dyodhpby); instance: asset instance (ins-123456); resourcegroup: asset group (/all groups/group 1/subgroup 1); tag: resource tag ({"Key":"tag key","Value":"tag value"}); region: region (ap-gaungzhou).
source_type This property is required. str
Access source type. Valid values: net|template|instance|resourcegroup|tag|region.
order_index str
Rule priority.
port str
The port to apply access control rules. Valid values: -1/-1: all ports, 80: port 80.
protocol str
Protocol. TCP/UDP/ICMP/ANY.
service_template_id str
Parameter template ID of port and protocol type; mutually exclusive with Protocol and Port.
description This property is required. String
Description.
destContent This property is required. String
Destination example: net: IP/CIDR (192.168.0.2); template: parameter template (ipm-dyodhpby); instance: asset instance (ins-123456); resourcegroup: asset group (/all groups/group 1/subgroup 1); tag: resource tag ({"Key":"tag key","Value":"tag value"}); region: region (ap-gaungzhou).
destType This property is required. String
Access destination type. Valid values: net|template|instance|resourcegroup|tag|region.
ruleAction This property is required. String
The action that Cloud Firewall performs on the traffic. Valid values: accept: allow, drop: deny.
sourceContent This property is required. String
Source example: net: IP/CIDR (192.168.0.2); template: parameter template (ipm-dyodhpby); instance: asset instance (ins-123456); resourcegroup: asset group (/all groups/group 1/subgroup 1); tag: resource tag ({"Key":"tag key","Value":"tag value"}); region: region (ap-gaungzhou).
sourceType This property is required. String
Access source type. Valid values: net|template|instance|resourcegroup|tag|region.
orderIndex String
Rule priority.
port String
The port to apply access control rules. Valid values: -1/-1: all ports, 80: port 80.
protocol String
Protocol. TCP/UDP/ICMP/ANY.
serviceTemplateId String
Parameter template ID of port and protocol type; mutually exclusive with Protocol and Port.

Import

cfw sg_rule can be imported using the id, e.g.

$ pulumi import tencentcloud:index/sgRule:SgRule sg_rule rule_id
Copy

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

Package Details

Repository
tencentcloud tencentcloudstack/terraform-provider-tencentcloud
License
Notes
This Pulumi package is based on the tencentcloud Terraform Provider.