tencentcloud.CvmSecurityGroupAttachment
Explore with Pulumi AI
Provides a resource to create a cvm security_group_attachment
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as tencentcloud from "@pulumi/tencentcloud";
// create vpc
const vpc = new tencentcloud.Vpc("vpc", {cidrBlock: "10.0.0.0/16"});
// create vpc subnet
const subnet = new tencentcloud.Subnet("subnet", {
vpcId: vpc.vpcId,
availabilityZone: "ap-guangzhou-6",
cidrBlock: "10.0.20.0/28",
isMulticast: false,
});
// create security group
const exampleSecurityGroup = new tencentcloud.SecurityGroup("exampleSecurityGroup", {
description: "sg desc.",
projectId: 0,
tags: {
example: "test",
},
});
// create cvm
const exampleInstance = new tencentcloud.Instance("exampleInstance", {
instanceName: "tf_example",
availabilityZone: "ap-guangzhou-6",
imageId: "img-9qrfy1xt",
instanceType: "SA3.MEDIUM4",
systemDiskType: "CLOUD_HSSD",
systemDiskSize: 100,
hostname: "example",
projectId: 0,
vpcId: vpc.vpcId,
subnetId: subnet.subnetId,
dataDisks: [{
dataDiskType: "CLOUD_HSSD",
dataDiskSize: 50,
encrypt: false,
}],
tags: {
tagKey: "tagValue",
},
});
// attachment security group
const exampleCvmSecurityGroupAttachment = new tencentcloud.CvmSecurityGroupAttachment("exampleCvmSecurityGroupAttachment", {
instanceId: exampleInstance.instanceId,
securityGroupId: exampleSecurityGroup.securityGroupId,
});
import pulumi
import pulumi_tencentcloud as tencentcloud
# create vpc
vpc = tencentcloud.Vpc("vpc", cidr_block="10.0.0.0/16")
# create vpc subnet
subnet = tencentcloud.Subnet("subnet",
vpc_id=vpc.vpc_id,
availability_zone="ap-guangzhou-6",
cidr_block="10.0.20.0/28",
is_multicast=False)
# create security group
example_security_group = tencentcloud.SecurityGroup("exampleSecurityGroup",
description="sg desc.",
project_id=0,
tags={
"example": "test",
})
# create cvm
example_instance = tencentcloud.Instance("exampleInstance",
instance_name="tf_example",
availability_zone="ap-guangzhou-6",
image_id="img-9qrfy1xt",
instance_type="SA3.MEDIUM4",
system_disk_type="CLOUD_HSSD",
system_disk_size=100,
hostname="example",
project_id=0,
vpc_id=vpc.vpc_id,
subnet_id=subnet.subnet_id,
data_disks=[{
"data_disk_type": "CLOUD_HSSD",
"data_disk_size": 50,
"encrypt": False,
}],
tags={
"tagKey": "tagValue",
})
# attachment security group
example_cvm_security_group_attachment = tencentcloud.CvmSecurityGroupAttachment("exampleCvmSecurityGroupAttachment",
instance_id=example_instance.instance_id,
security_group_id=example_security_group.security_group_id)
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 {
// create vpc
vpc, err := tencentcloud.NewVpc(ctx, "vpc", &tencentcloud.VpcArgs{
CidrBlock: pulumi.String("10.0.0.0/16"),
})
if err != nil {
return err
}
// create vpc subnet
subnet, err := tencentcloud.NewSubnet(ctx, "subnet", &tencentcloud.SubnetArgs{
VpcId: vpc.VpcId,
AvailabilityZone: pulumi.String("ap-guangzhou-6"),
CidrBlock: pulumi.String("10.0.20.0/28"),
IsMulticast: pulumi.Bool(false),
})
if err != nil {
return err
}
// create security group
exampleSecurityGroup, err := tencentcloud.NewSecurityGroup(ctx, "exampleSecurityGroup", &tencentcloud.SecurityGroupArgs{
Description: pulumi.String("sg desc."),
ProjectId: pulumi.Float64(0),
Tags: pulumi.StringMap{
"example": pulumi.String("test"),
},
})
if err != nil {
return err
}
// create cvm
exampleInstance, err := tencentcloud.NewInstance(ctx, "exampleInstance", &tencentcloud.InstanceArgs{
InstanceName: pulumi.String("tf_example"),
AvailabilityZone: pulumi.String("ap-guangzhou-6"),
ImageId: pulumi.String("img-9qrfy1xt"),
InstanceType: pulumi.String("SA3.MEDIUM4"),
SystemDiskType: pulumi.String("CLOUD_HSSD"),
SystemDiskSize: pulumi.Float64(100),
Hostname: pulumi.String("example"),
ProjectId: pulumi.Float64(0),
VpcId: vpc.VpcId,
SubnetId: subnet.SubnetId,
DataDisks: tencentcloud.InstanceDataDiskArray{
&tencentcloud.InstanceDataDiskArgs{
DataDiskType: pulumi.String("CLOUD_HSSD"),
DataDiskSize: pulumi.Float64(50),
Encrypt: pulumi.Bool(false),
},
},
Tags: pulumi.StringMap{
"tagKey": pulumi.String("tagValue"),
},
})
if err != nil {
return err
}
// attachment security group
_, err = tencentcloud.NewCvmSecurityGroupAttachment(ctx, "exampleCvmSecurityGroupAttachment", &tencentcloud.CvmSecurityGroupAttachmentArgs{
InstanceId: exampleInstance.InstanceId,
SecurityGroupId: exampleSecurityGroup.SecurityGroupId,
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Tencentcloud = Pulumi.Tencentcloud;
return await Deployment.RunAsync(() =>
{
// create vpc
var vpc = new Tencentcloud.Vpc("vpc", new()
{
CidrBlock = "10.0.0.0/16",
});
// create vpc subnet
var subnet = new Tencentcloud.Subnet("subnet", new()
{
VpcId = vpc.VpcId,
AvailabilityZone = "ap-guangzhou-6",
CidrBlock = "10.0.20.0/28",
IsMulticast = false,
});
// create security group
var exampleSecurityGroup = new Tencentcloud.SecurityGroup("exampleSecurityGroup", new()
{
Description = "sg desc.",
ProjectId = 0,
Tags =
{
{ "example", "test" },
},
});
// create cvm
var exampleInstance = new Tencentcloud.Instance("exampleInstance", new()
{
InstanceName = "tf_example",
AvailabilityZone = "ap-guangzhou-6",
ImageId = "img-9qrfy1xt",
InstanceType = "SA3.MEDIUM4",
SystemDiskType = "CLOUD_HSSD",
SystemDiskSize = 100,
Hostname = "example",
ProjectId = 0,
VpcId = vpc.VpcId,
SubnetId = subnet.SubnetId,
DataDisks = new[]
{
new Tencentcloud.Inputs.InstanceDataDiskArgs
{
DataDiskType = "CLOUD_HSSD",
DataDiskSize = 50,
Encrypt = false,
},
},
Tags =
{
{ "tagKey", "tagValue" },
},
});
// attachment security group
var exampleCvmSecurityGroupAttachment = new Tencentcloud.CvmSecurityGroupAttachment("exampleCvmSecurityGroupAttachment", new()
{
InstanceId = exampleInstance.InstanceId,
SecurityGroupId = exampleSecurityGroup.SecurityGroupId,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.tencentcloud.Vpc;
import com.pulumi.tencentcloud.VpcArgs;
import com.pulumi.tencentcloud.Subnet;
import com.pulumi.tencentcloud.SubnetArgs;
import com.pulumi.tencentcloud.SecurityGroup;
import com.pulumi.tencentcloud.SecurityGroupArgs;
import com.pulumi.tencentcloud.Instance;
import com.pulumi.tencentcloud.InstanceArgs;
import com.pulumi.tencentcloud.inputs.InstanceDataDiskArgs;
import com.pulumi.tencentcloud.CvmSecurityGroupAttachment;
import com.pulumi.tencentcloud.CvmSecurityGroupAttachmentArgs;
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) {
// create vpc
var vpc = new Vpc("vpc", VpcArgs.builder()
.cidrBlock("10.0.0.0/16")
.build());
// create vpc subnet
var subnet = new Subnet("subnet", SubnetArgs.builder()
.vpcId(vpc.vpcId())
.availabilityZone("ap-guangzhou-6")
.cidrBlock("10.0.20.0/28")
.isMulticast(false)
.build());
// create security group
var exampleSecurityGroup = new SecurityGroup("exampleSecurityGroup", SecurityGroupArgs.builder()
.description("sg desc.")
.projectId(0)
.tags(Map.of("example", "test"))
.build());
// create cvm
var exampleInstance = new Instance("exampleInstance", InstanceArgs.builder()
.instanceName("tf_example")
.availabilityZone("ap-guangzhou-6")
.imageId("img-9qrfy1xt")
.instanceType("SA3.MEDIUM4")
.systemDiskType("CLOUD_HSSD")
.systemDiskSize(100)
.hostname("example")
.projectId(0)
.vpcId(vpc.vpcId())
.subnetId(subnet.subnetId())
.dataDisks(InstanceDataDiskArgs.builder()
.dataDiskType("CLOUD_HSSD")
.dataDiskSize(50)
.encrypt(false)
.build())
.tags(Map.of("tagKey", "tagValue"))
.build());
// attachment security group
var exampleCvmSecurityGroupAttachment = new CvmSecurityGroupAttachment("exampleCvmSecurityGroupAttachment", CvmSecurityGroupAttachmentArgs.builder()
.instanceId(exampleInstance.instanceId())
.securityGroupId(exampleSecurityGroup.securityGroupId())
.build());
}
}
resources:
# create vpc
vpc:
type: tencentcloud:Vpc
properties:
cidrBlock: 10.0.0.0/16
# create vpc subnet
subnet:
type: tencentcloud:Subnet
properties:
vpcId: ${vpc.vpcId}
availabilityZone: ap-guangzhou-6
cidrBlock: 10.0.20.0/28
isMulticast: false
# create security group
exampleSecurityGroup:
type: tencentcloud:SecurityGroup
properties:
description: sg desc.
projectId: 0
tags:
example: test
# create cvm
exampleInstance:
type: tencentcloud:Instance
properties:
instanceName: tf_example
availabilityZone: ap-guangzhou-6
imageId: img-9qrfy1xt
instanceType: SA3.MEDIUM4
systemDiskType: CLOUD_HSSD
systemDiskSize: 100
hostname: example
projectId: 0
vpcId: ${vpc.vpcId}
subnetId: ${subnet.subnetId}
dataDisks:
- dataDiskType: CLOUD_HSSD
dataDiskSize: 50
encrypt: false
tags:
tagKey: tagValue
# attachment security group
exampleCvmSecurityGroupAttachment:
type: tencentcloud:CvmSecurityGroupAttachment
properties:
instanceId: ${exampleInstance.instanceId}
securityGroupId: ${exampleSecurityGroup.securityGroupId}
Create CvmSecurityGroupAttachment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new CvmSecurityGroupAttachment(name: string, args: CvmSecurityGroupAttachmentArgs, opts?: CustomResourceOptions);
@overload
def CvmSecurityGroupAttachment(resource_name: str,
args: CvmSecurityGroupAttachmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def CvmSecurityGroupAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
instance_id: Optional[str] = None,
security_group_id: Optional[str] = None,
cvm_security_group_attachment_id: Optional[str] = None)
func NewCvmSecurityGroupAttachment(ctx *Context, name string, args CvmSecurityGroupAttachmentArgs, opts ...ResourceOption) (*CvmSecurityGroupAttachment, error)
public CvmSecurityGroupAttachment(string name, CvmSecurityGroupAttachmentArgs args, CustomResourceOptions? opts = null)
public CvmSecurityGroupAttachment(String name, CvmSecurityGroupAttachmentArgs args)
public CvmSecurityGroupAttachment(String name, CvmSecurityGroupAttachmentArgs args, CustomResourceOptions options)
type: tencentcloud:CvmSecurityGroupAttachment
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 CvmSecurityGroupAttachmentArgs
- 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 CvmSecurityGroupAttachmentArgs
- 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 CvmSecurityGroupAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args CvmSecurityGroupAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args CvmSecurityGroupAttachmentArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
CvmSecurityGroupAttachment 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 CvmSecurityGroupAttachment resource accepts the following input properties:
- Instance
Id string - Instance id.
- Security
Group stringId - Security group id.
- Cvm
Security stringGroup Attachment Id - ID of the resource.
- Instance
Id string - Instance id.
- Security
Group stringId - Security group id.
- Cvm
Security stringGroup Attachment Id - ID of the resource.
- instance
Id String - Instance id.
- security
Group StringId - Security group id.
- cvm
Security StringGroup Attachment Id - ID of the resource.
- instance
Id string - Instance id.
- security
Group stringId - Security group id.
- cvm
Security stringGroup Attachment Id - ID of the resource.
- instance_
id str - Instance id.
- security_
group_ strid - Security group id.
- cvm_
security_ strgroup_ attachment_ id - ID of the resource.
- instance
Id String - Instance id.
- security
Group StringId - Security group id.
- cvm
Security StringGroup Attachment Id - ID of the resource.
Outputs
All input properties are implicitly available as output properties. Additionally, the CvmSecurityGroupAttachment 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 CvmSecurityGroupAttachment Resource
Get an existing CvmSecurityGroupAttachment 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?: CvmSecurityGroupAttachmentState, opts?: CustomResourceOptions): CvmSecurityGroupAttachment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
cvm_security_group_attachment_id: Optional[str] = None,
instance_id: Optional[str] = None,
security_group_id: Optional[str] = None) -> CvmSecurityGroupAttachment
func GetCvmSecurityGroupAttachment(ctx *Context, name string, id IDInput, state *CvmSecurityGroupAttachmentState, opts ...ResourceOption) (*CvmSecurityGroupAttachment, error)
public static CvmSecurityGroupAttachment Get(string name, Input<string> id, CvmSecurityGroupAttachmentState? state, CustomResourceOptions? opts = null)
public static CvmSecurityGroupAttachment get(String name, Output<String> id, CvmSecurityGroupAttachmentState state, CustomResourceOptions options)
resources: _: type: tencentcloud:CvmSecurityGroupAttachment 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.
- Cvm
Security stringGroup Attachment Id - ID of the resource.
- Instance
Id string - Instance id.
- Security
Group stringId - Security group id.
- Cvm
Security stringGroup Attachment Id - ID of the resource.
- Instance
Id string - Instance id.
- Security
Group stringId - Security group id.
- cvm
Security StringGroup Attachment Id - ID of the resource.
- instance
Id String - Instance id.
- security
Group StringId - Security group id.
- cvm
Security stringGroup Attachment Id - ID of the resource.
- instance
Id string - Instance id.
- security
Group stringId - Security group id.
- cvm_
security_ strgroup_ attachment_ id - ID of the resource.
- instance_
id str - Instance id.
- security_
group_ strid - Security group id.
- cvm
Security StringGroup Attachment Id - ID of the resource.
- instance
Id String - Instance id.
- security
Group StringId - Security group id.
Import
cvm security_group_attachment can be imported using the id, e.g.
$ pulumi import tencentcloud:index/cvmSecurityGroupAttachment:CvmSecurityGroupAttachment example ins-odl0lrcy#sg-5275dorp
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.