ucloud.SecurityGroup
Explore with Pulumi AI
Provides a Security Group resource.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as ucloud from "@pulumi/ucloud";
const example = new ucloud.SecurityGroup("example", {
rules: [
{
cidrBlock: "192.168.0.0/16",
policy: "accept",
portRange: "80",
protocol: "tcp",
},
{
cidrBlock: "192.168.0.0/16",
policy: "accept",
portRange: "443",
protocol: "tcp",
},
],
tag: "tf-example",
});
import pulumi
import pulumi_ucloud as ucloud
example = ucloud.SecurityGroup("example",
rules=[
{
"cidr_block": "192.168.0.0/16",
"policy": "accept",
"port_range": "80",
"protocol": "tcp",
},
{
"cidr_block": "192.168.0.0/16",
"policy": "accept",
"port_range": "443",
"protocol": "tcp",
},
],
tag="tf-example")
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.NewSecurityGroup(ctx, "example", &ucloud.SecurityGroupArgs{
Rules: ucloud.SecurityGroupRuleArray{
&ucloud.SecurityGroupRuleArgs{
CidrBlock: pulumi.String("192.168.0.0/16"),
Policy: pulumi.String("accept"),
PortRange: pulumi.String("80"),
Protocol: pulumi.String("tcp"),
},
&ucloud.SecurityGroupRuleArgs{
CidrBlock: pulumi.String("192.168.0.0/16"),
Policy: pulumi.String("accept"),
PortRange: pulumi.String("443"),
Protocol: pulumi.String("tcp"),
},
},
Tag: pulumi.String("tf-example"),
})
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.SecurityGroup("example", new()
{
Rules = new[]
{
new Ucloud.Inputs.SecurityGroupRuleArgs
{
CidrBlock = "192.168.0.0/16",
Policy = "accept",
PortRange = "80",
Protocol = "tcp",
},
new Ucloud.Inputs.SecurityGroupRuleArgs
{
CidrBlock = "192.168.0.0/16",
Policy = "accept",
PortRange = "443",
Protocol = "tcp",
},
},
Tag = "tf-example",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.ucloud.SecurityGroup;
import com.pulumi.ucloud.SecurityGroupArgs;
import com.pulumi.ucloud.inputs.SecurityGroupRuleArgs;
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 SecurityGroup("example", SecurityGroupArgs.builder()
.rules(
SecurityGroupRuleArgs.builder()
.cidrBlock("192.168.0.0/16")
.policy("accept")
.portRange("80")
.protocol("tcp")
.build(),
SecurityGroupRuleArgs.builder()
.cidrBlock("192.168.0.0/16")
.policy("accept")
.portRange("443")
.protocol("tcp")
.build())
.tag("tf-example")
.build());
}
}
resources:
example:
type: ucloud:SecurityGroup
properties:
rules:
- cidrBlock: 192.168.0.0/16
policy: accept
portRange: '80'
protocol: tcp
- cidrBlock: 192.168.0.0/16
policy: accept
portRange: '443'
protocol: tcp
tag: tf-example
Create SecurityGroup Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new SecurityGroup(name: string, args: SecurityGroupArgs, opts?: CustomResourceOptions);
@overload
def SecurityGroup(resource_name: str,
args: SecurityGroupArgs,
opts: Optional[ResourceOptions] = None)
@overload
def SecurityGroup(resource_name: str,
opts: Optional[ResourceOptions] = None,
rules: Optional[Sequence[SecurityGroupRuleArgs]] = None,
name: Optional[str] = None,
remark: Optional[str] = None,
security_group_id: Optional[str] = None,
tag: Optional[str] = None)
func NewSecurityGroup(ctx *Context, name string, args SecurityGroupArgs, opts ...ResourceOption) (*SecurityGroup, error)
public SecurityGroup(string name, SecurityGroupArgs args, CustomResourceOptions? opts = null)
public SecurityGroup(String name, SecurityGroupArgs args)
public SecurityGroup(String name, SecurityGroupArgs args, CustomResourceOptions options)
type: ucloud:SecurityGroup
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args SecurityGroupArgs
- 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 SecurityGroupArgs
- 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 SecurityGroupArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SecurityGroupArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SecurityGroupArgs
- 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 securityGroupResource = new Ucloud.SecurityGroup("securityGroupResource", new()
{
Rules = new[]
{
new Ucloud.Inputs.SecurityGroupRuleArgs
{
CidrBlock = "string",
Policy = "string",
PortRange = "string",
Priority = "string",
Protocol = "string",
},
},
Name = "string",
Remark = "string",
SecurityGroupId = "string",
Tag = "string",
});
example, err := ucloud.NewSecurityGroup(ctx, "securityGroupResource", &ucloud.SecurityGroupArgs{
Rules: ucloud.SecurityGroupRuleArray{
&ucloud.SecurityGroupRuleArgs{
CidrBlock: pulumi.String("string"),
Policy: pulumi.String("string"),
PortRange: pulumi.String("string"),
Priority: pulumi.String("string"),
Protocol: pulumi.String("string"),
},
},
Name: pulumi.String("string"),
Remark: pulumi.String("string"),
SecurityGroupId: pulumi.String("string"),
Tag: pulumi.String("string"),
})
var securityGroupResource = new SecurityGroup("securityGroupResource", SecurityGroupArgs.builder()
.rules(SecurityGroupRuleArgs.builder()
.cidrBlock("string")
.policy("string")
.portRange("string")
.priority("string")
.protocol("string")
.build())
.name("string")
.remark("string")
.securityGroupId("string")
.tag("string")
.build());
security_group_resource = ucloud.SecurityGroup("securityGroupResource",
rules=[{
"cidr_block": "string",
"policy": "string",
"port_range": "string",
"priority": "string",
"protocol": "string",
}],
name="string",
remark="string",
security_group_id="string",
tag="string")
const securityGroupResource = new ucloud.SecurityGroup("securityGroupResource", {
rules: [{
cidrBlock: "string",
policy: "string",
portRange: "string",
priority: "string",
protocol: "string",
}],
name: "string",
remark: "string",
securityGroupId: "string",
tag: "string",
});
type: ucloud:SecurityGroup
properties:
name: string
remark: string
rules:
- cidrBlock: string
policy: string
portRange: string
priority: string
protocol: string
securityGroupId: string
tag: string
SecurityGroup 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 SecurityGroup resource accepts the following input properties:
- Rules
List<Security
Group Rule> - A list of security group rules. Can be specified multiple times for each rules. See rules below for details on attributes.
- Name string
- Remark string
- The remarks of the security group. (Default:
""
). - Security
Group stringId - The ID of the resource security group.
- Tag string
- A tag assigned to security group, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- Rules
[]Security
Group Rule Args - A list of security group rules. Can be specified multiple times for each rules. See rules below for details on attributes.
- Name string
- Remark string
- The remarks of the security group. (Default:
""
). - Security
Group stringId - The ID of the resource security group.
- Tag string
- A tag assigned to security group, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- rules
List<Security
Group Rule> - A list of security group rules. Can be specified multiple times for each rules. See rules below for details on attributes.
- name String
- remark String
- The remarks of the security group. (Default:
""
). - security
Group StringId - The ID of the resource security group.
- tag String
- A tag assigned to security group, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- rules
Security
Group Rule[] - A list of security group rules. Can be specified multiple times for each rules. See rules below for details on attributes.
- name string
- remark string
- The remarks of the security group. (Default:
""
). - security
Group stringId - The ID of the resource security group.
- tag string
- A tag assigned to security group, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- rules
Sequence[Security
Group Rule Args] - A list of security group rules. Can be specified multiple times for each rules. See rules below for details on attributes.
- name str
- remark str
- The remarks of the security group. (Default:
""
). - security_
group_ strid - The ID of the resource security group.
- tag str
- A tag assigned to security group, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- rules List<Property Map>
- A list of security group rules. Can be specified multiple times for each rules. See rules below for details on attributes.
- name String
- remark String
- The remarks of the security group. (Default:
""
). - security
Group StringId - The ID of the resource security group.
- tag String
- A tag assigned to security group, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
Outputs
All input properties are implicitly available as output properties. Additionally, the SecurityGroup resource produces the following output properties:
- Create
Time string - The time of creation of security group, formatted in RFC3339 time string.
- Id string
- The provider-assigned unique ID for this managed resource.
- Create
Time string - The time of creation of security group, formatted in RFC3339 time string.
- Id string
- The provider-assigned unique ID for this managed resource.
- create
Time String - The time of creation of security group, formatted in RFC3339 time string.
- id String
- The provider-assigned unique ID for this managed resource.
- create
Time string - The time of creation of security group, formatted in RFC3339 time string.
- id string
- The provider-assigned unique ID for this managed resource.
- create_
time str - The time of creation of security group, formatted in RFC3339 time string.
- id str
- The provider-assigned unique ID for this managed resource.
- create
Time String - The time of creation of security group, formatted in RFC3339 time string.
- id String
- The provider-assigned unique ID for this managed resource.
Look up Existing SecurityGroup Resource
Get an existing SecurityGroup 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?: SecurityGroupState, opts?: CustomResourceOptions): SecurityGroup
@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,
rules: Optional[Sequence[SecurityGroupRuleArgs]] = None,
security_group_id: Optional[str] = None,
tag: Optional[str] = None) -> SecurityGroup
func GetSecurityGroup(ctx *Context, name string, id IDInput, state *SecurityGroupState, opts ...ResourceOption) (*SecurityGroup, error)
public static SecurityGroup Get(string name, Input<string> id, SecurityGroupState? state, CustomResourceOptions? opts = null)
public static SecurityGroup get(String name, Output<String> id, SecurityGroupState state, CustomResourceOptions options)
resources: _: type: ucloud:SecurityGroup get: 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.
- Create
Time string - The time of creation of security group, formatted in RFC3339 time string.
- Name string
- Remark string
- The remarks of the security group. (Default:
""
). - Rules
List<Security
Group Rule> - A list of security group rules. Can be specified multiple times for each rules. See rules below for details on attributes.
- Security
Group stringId - The ID of the resource security group.
- Tag string
- A tag assigned to security group, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- Create
Time string - The time of creation of security group, formatted in RFC3339 time string.
- Name string
- Remark string
- The remarks of the security group. (Default:
""
). - Rules
[]Security
Group Rule Args - A list of security group rules. Can be specified multiple times for each rules. See rules below for details on attributes.
- Security
Group stringId - The ID of the resource security group.
- Tag string
- A tag assigned to security group, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- create
Time String - The time of creation of security group, formatted in RFC3339 time string.
- name String
- remark String
- The remarks of the security group. (Default:
""
). - rules
List<Security
Group Rule> - A list of security group rules. Can be specified multiple times for each rules. See rules below for details on attributes.
- security
Group StringId - The ID of the resource security group.
- tag String
- A tag assigned to security group, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- create
Time string - The time of creation of security group, formatted in RFC3339 time string.
- name string
- remark string
- The remarks of the security group. (Default:
""
). - rules
Security
Group Rule[] - A list of security group rules. Can be specified multiple times for each rules. See rules below for details on attributes.
- security
Group stringId - The ID of the resource security group.
- tag string
- A tag assigned to security group, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- create_
time str - The time of creation of security group, formatted in RFC3339 time string.
- name str
- remark str
- The remarks of the security group. (Default:
""
). - rules
Sequence[Security
Group Rule Args] - A list of security group rules. Can be specified multiple times for each rules. See rules below for details on attributes.
- security_
group_ strid - The ID of the resource security group.
- tag str
- A tag assigned to security group, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
- create
Time String - The time of creation of security group, formatted in RFC3339 time string.
- name String
- remark String
- The remarks of the security group. (Default:
""
). - rules List<Property Map>
- A list of security group rules. Can be specified multiple times for each rules. See rules below for details on attributes.
- security
Group StringId - The ID of the resource security group.
- tag String
- A tag assigned to security group, which contains at most 63 characters and only support Chinese, English, numbers, '-', '_', and '.'. If it is not filled in or a empty string is filled in, then default tag will be assigned. (Default:
Default
).
Supporting Types
SecurityGroupRule, SecurityGroupRuleArgs
- Cidr
Block string - The cidr block of source.
- Policy string
- Authorization policy. Possible values are:
accept
,drop
. - Port
Range string - The range of port numbers, range: 1-65535. (eg:
port
orport1-port2
). - Priority string
- Rule priority. Possible values are:
high
,medium
,low
. - Protocol string
- The protocol. Possible values are:
tcp
,udp
,icmp
,gre
.
- Cidr
Block string - The cidr block of source.
- Policy string
- Authorization policy. Possible values are:
accept
,drop
. - Port
Range string - The range of port numbers, range: 1-65535. (eg:
port
orport1-port2
). - Priority string
- Rule priority. Possible values are:
high
,medium
,low
. - Protocol string
- The protocol. Possible values are:
tcp
,udp
,icmp
,gre
.
- cidr
Block String - The cidr block of source.
- policy String
- Authorization policy. Possible values are:
accept
,drop
. - port
Range String - The range of port numbers, range: 1-65535. (eg:
port
orport1-port2
). - priority String
- Rule priority. Possible values are:
high
,medium
,low
. - protocol String
- The protocol. Possible values are:
tcp
,udp
,icmp
,gre
.
- cidr
Block string - The cidr block of source.
- policy string
- Authorization policy. Possible values are:
accept
,drop
. - port
Range string - The range of port numbers, range: 1-65535. (eg:
port
orport1-port2
). - priority string
- Rule priority. Possible values are:
high
,medium
,low
. - protocol string
- The protocol. Possible values are:
tcp
,udp
,icmp
,gre
.
- cidr_
block str - The cidr block of source.
- policy str
- Authorization policy. Possible values are:
accept
,drop
. - port_
range str - The range of port numbers, range: 1-65535. (eg:
port
orport1-port2
). - priority str
- Rule priority. Possible values are:
high
,medium
,low
. - protocol str
- The protocol. Possible values are:
tcp
,udp
,icmp
,gre
.
- cidr
Block String - The cidr block of source.
- policy String
- Authorization policy. Possible values are:
accept
,drop
. - port
Range String - The range of port numbers, range: 1-65535. (eg:
port
orport1-port2
). - priority String
- Rule priority. Possible values are:
high
,medium
,low
. - protocol String
- The protocol. Possible values are:
tcp
,udp
,icmp
,gre
.
Import
Security Group can be imported using the id
, e.g.
$ pulumi import ucloud:index/securityGroup:SecurityGroup example firewall-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.