1. Packages
  2. Tencentcloud Provider
  3. API Docs
  4. TcrVpcAttachment
tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack

tencentcloud.TcrVpcAttachment

Explore with Pulumi AI

tencentcloud logo
tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack

    Use this resource to attach tcr instance with the vpc and subnet network.

    Example Usage

    Attach a tcr instance with vpc resource

    import * as pulumi from "@pulumi/pulumi";
    import * as tencentcloud from "@pulumi/tencentcloud";
    
    const vpc = tencentcloud.getVpcSubnets({
        isDefault: true,
        availabilityZone: _var.availability_zone,
    });
    const vpcId = vpc.then(vpc => vpc.instanceLists?.[0]?.vpcId);
    const subnetId = vpc.then(vpc => vpc.instanceLists?.[0]?.subnetId);
    const example = new tencentcloud.TcrInstance("example", {
        instanceType: "basic",
        deleteBucket: true,
        tags: {
            createdBy: "terraform",
        },
    });
    const tcrId = example.tcrInstanceId;
    const sg = tencentcloud.getSecurityGroups({
        name: "default",
    });
    const foo = new tencentcloud.TcrVpcAttachment("foo", {
        instanceId: tcrId,
        vpcId: vpcId,
        subnetId: subnetId,
    });
    
    import pulumi
    import pulumi_tencentcloud as tencentcloud
    
    vpc = tencentcloud.get_vpc_subnets(is_default=True,
        availability_zone=var["availability_zone"])
    vpc_id = vpc.instance_lists[0].vpc_id
    subnet_id = vpc.instance_lists[0].subnet_id
    example = tencentcloud.TcrInstance("example",
        instance_type="basic",
        delete_bucket=True,
        tags={
            "createdBy": "terraform",
        })
    tcr_id = example.tcr_instance_id
    sg = tencentcloud.get_security_groups(name="default")
    foo = tencentcloud.TcrVpcAttachment("foo",
        instance_id=tcr_id,
        vpc_id=vpc_id,
        subnet_id=subnet_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 {
    		vpc, err := tencentcloud.GetVpcSubnets(ctx, &tencentcloud.GetVpcSubnetsArgs{
    			IsDefault:        pulumi.BoolRef(true),
    			AvailabilityZone: pulumi.StringRef(_var.Availability_zone),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		vpcId := vpc.InstanceLists[0].VpcId
    		subnetId := vpc.InstanceLists[0].SubnetId
    		example, err := tencentcloud.NewTcrInstance(ctx, "example", &tencentcloud.TcrInstanceArgs{
    			InstanceType: pulumi.String("basic"),
    			DeleteBucket: pulumi.Bool(true),
    			Tags: pulumi.StringMap{
    				"createdBy": pulumi.String("terraform"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		tcrId := example.TcrInstanceId
    		_, err = tencentcloud.GetSecurityGroups(ctx, &tencentcloud.GetSecurityGroupsArgs{
    			Name: pulumi.StringRef("default"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = tencentcloud.NewTcrVpcAttachment(ctx, "foo", &tencentcloud.TcrVpcAttachmentArgs{
    			InstanceId: pulumi.String(tcrId),
    			VpcId:      pulumi.String(vpcId),
    			SubnetId:   pulumi.String(subnetId),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Tencentcloud = Pulumi.Tencentcloud;
    
    return await Deployment.RunAsync(() => 
    {
        var vpc = Tencentcloud.GetVpcSubnets.Invoke(new()
        {
            IsDefault = true,
            AvailabilityZone = @var.Availability_zone,
        });
    
        var vpcId = vpc.Apply(getVpcSubnetsResult => getVpcSubnetsResult.InstanceLists[0]?.VpcId);
    
        var subnetId = vpc.Apply(getVpcSubnetsResult => getVpcSubnetsResult.InstanceLists[0]?.SubnetId);
    
        var example = new Tencentcloud.TcrInstance("example", new()
        {
            InstanceType = "basic",
            DeleteBucket = true,
            Tags = 
            {
                { "createdBy", "terraform" },
            },
        });
    
        var tcrId = example.TcrInstanceId;
    
        var sg = Tencentcloud.GetSecurityGroups.Invoke(new()
        {
            Name = "default",
        });
    
        var foo = new Tencentcloud.TcrVpcAttachment("foo", new()
        {
            InstanceId = tcrId,
            VpcId = vpcId,
            SubnetId = subnetId,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.tencentcloud.TencentcloudFunctions;
    import com.pulumi.tencentcloud.inputs.GetVpcSubnetsArgs;
    import com.pulumi.tencentcloud.TcrInstance;
    import com.pulumi.tencentcloud.TcrInstanceArgs;
    import com.pulumi.tencentcloud.inputs.GetSecurityGroupsArgs;
    import com.pulumi.tencentcloud.TcrVpcAttachment;
    import com.pulumi.tencentcloud.TcrVpcAttachmentArgs;
    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) {
            final var vpc = TencentcloudFunctions.getVpcSubnets(GetVpcSubnetsArgs.builder()
                .isDefault(true)
                .availabilityZone(var_.availability_zone())
                .build());
    
            final var vpcId = vpc.applyValue(getVpcSubnetsResult -> getVpcSubnetsResult.instanceLists()[0].vpcId());
    
            final var subnetId = vpc.applyValue(getVpcSubnetsResult -> getVpcSubnetsResult.instanceLists()[0].subnetId());
    
            var example = new TcrInstance("example", TcrInstanceArgs.builder()
                .instanceType("basic")
                .deleteBucket(true)
                .tags(Map.of("createdBy", "terraform"))
                .build());
    
            final var tcrId = example.tcrInstanceId();
    
            final var sg = TencentcloudFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
                .name("default")
                .build());
    
            var foo = new TcrVpcAttachment("foo", TcrVpcAttachmentArgs.builder()
                .instanceId(tcrId)
                .vpcId(vpcId)
                .subnetId(subnetId)
                .build());
    
        }
    }
    
    resources:
      example:
        type: tencentcloud:TcrInstance
        properties:
          instanceType: basic
          deleteBucket: true
          tags:
            createdBy: terraform
      foo:
        type: tencentcloud:TcrVpcAttachment
        properties:
          instanceId: ${tcrId}
          vpcId: ${vpcId}
          subnetId: ${subnetId}
    variables:
      vpcId: ${vpc.instanceLists[0].vpcId}
      subnetId: ${vpc.instanceLists[0].subnetId}
      tcrId: ${example.tcrInstanceId}
      vpc:
        fn::invoke:
          function: tencentcloud:getVpcSubnets
          arguments:
            isDefault: true
            availabilityZone: ${var.availability_zone}
      sg:
        fn::invoke:
          function: tencentcloud:getSecurityGroups
          arguments:
            name: default
    

    Create TcrVpcAttachment Resource

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

    Constructor syntax

    new TcrVpcAttachment(name: string, args: TcrVpcAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def TcrVpcAttachment(resource_name: str,
                         args: TcrVpcAttachmentArgs,
                         opts: Optional[ResourceOptions] = None)
    
    @overload
    def TcrVpcAttachment(resource_name: str,
                         opts: Optional[ResourceOptions] = None,
                         instance_id: Optional[str] = None,
                         subnet_id: Optional[str] = None,
                         vpc_id: Optional[str] = None,
                         enable_public_domain_dns: Optional[bool] = None,
                         enable_vpc_domain_dns: Optional[bool] = None,
                         region_id: Optional[float] = None,
                         region_name: Optional[str] = None,
                         tcr_vpc_attachment_id: Optional[str] = None)
    func NewTcrVpcAttachment(ctx *Context, name string, args TcrVpcAttachmentArgs, opts ...ResourceOption) (*TcrVpcAttachment, error)
    public TcrVpcAttachment(string name, TcrVpcAttachmentArgs args, CustomResourceOptions? opts = null)
    public TcrVpcAttachment(String name, TcrVpcAttachmentArgs args)
    public TcrVpcAttachment(String name, TcrVpcAttachmentArgs args, CustomResourceOptions options)
    
    type: tencentcloud:TcrVpcAttachment
    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 TcrVpcAttachmentArgs
    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 TcrVpcAttachmentArgs
    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 TcrVpcAttachmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args TcrVpcAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args TcrVpcAttachmentArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

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

    InstanceId string
    ID of the TCR instance.
    SubnetId string
    ID of subnet.
    VpcId string
    ID of VPC.
    EnablePublicDomainDns bool
    Whether to enable public domain dns. Default value is false.
    EnableVpcDomainDns bool
    Whether to enable vpc domain dns. Default value is false.
    RegionId double
    this argument was deprecated, use region_name instead. ID of region. Conflict with region_name, can not be set at the same time.

    Deprecated: Deprecated

    RegionName string
    Name of region. Conflict with region_id, can not be set at the same time.
    TcrVpcAttachmentId string
    ID of the resource.
    InstanceId string
    ID of the TCR instance.
    SubnetId string
    ID of subnet.
    VpcId string
    ID of VPC.
    EnablePublicDomainDns bool
    Whether to enable public domain dns. Default value is false.
    EnableVpcDomainDns bool
    Whether to enable vpc domain dns. Default value is false.
    RegionId float64
    this argument was deprecated, use region_name instead. ID of region. Conflict with region_name, can not be set at the same time.

    Deprecated: Deprecated

    RegionName string
    Name of region. Conflict with region_id, can not be set at the same time.
    TcrVpcAttachmentId string
    ID of the resource.
    instanceId String
    ID of the TCR instance.
    subnetId String
    ID of subnet.
    vpcId String
    ID of VPC.
    enablePublicDomainDns Boolean
    Whether to enable public domain dns. Default value is false.
    enableVpcDomainDns Boolean
    Whether to enable vpc domain dns. Default value is false.
    regionId Double
    this argument was deprecated, use region_name instead. ID of region. Conflict with region_name, can not be set at the same time.

    Deprecated: Deprecated

    regionName String
    Name of region. Conflict with region_id, can not be set at the same time.
    tcrVpcAttachmentId String
    ID of the resource.
    instanceId string
    ID of the TCR instance.
    subnetId string
    ID of subnet.
    vpcId string
    ID of VPC.
    enablePublicDomainDns boolean
    Whether to enable public domain dns. Default value is false.
    enableVpcDomainDns boolean
    Whether to enable vpc domain dns. Default value is false.
    regionId number
    this argument was deprecated, use region_name instead. ID of region. Conflict with region_name, can not be set at the same time.

    Deprecated: Deprecated

    regionName string
    Name of region. Conflict with region_id, can not be set at the same time.
    tcrVpcAttachmentId string
    ID of the resource.
    instance_id str
    ID of the TCR instance.
    subnet_id str
    ID of subnet.
    vpc_id str
    ID of VPC.
    enable_public_domain_dns bool
    Whether to enable public domain dns. Default value is false.
    enable_vpc_domain_dns bool
    Whether to enable vpc domain dns. Default value is false.
    region_id float
    this argument was deprecated, use region_name instead. ID of region. Conflict with region_name, can not be set at the same time.

    Deprecated: Deprecated

    region_name str
    Name of region. Conflict with region_id, can not be set at the same time.
    tcr_vpc_attachment_id str
    ID of the resource.
    instanceId String
    ID of the TCR instance.
    subnetId String
    ID of subnet.
    vpcId String
    ID of VPC.
    enablePublicDomainDns Boolean
    Whether to enable public domain dns. Default value is false.
    enableVpcDomainDns Boolean
    Whether to enable vpc domain dns. Default value is false.
    regionId Number
    this argument was deprecated, use region_name instead. ID of region. Conflict with region_name, can not be set at the same time.

    Deprecated: Deprecated

    regionName String
    Name of region. Conflict with region_id, can not be set at the same time.
    tcrVpcAttachmentId String
    ID of the resource.

    Outputs

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

    AccessIp string
    IP address of the internal access.
    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    Status of the internal access.
    AccessIp string
    IP address of the internal access.
    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    Status of the internal access.
    accessIp String
    IP address of the internal access.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    Status of the internal access.
    accessIp string
    IP address of the internal access.
    id string
    The provider-assigned unique ID for this managed resource.
    status string
    Status of the internal access.
    access_ip str
    IP address of the internal access.
    id str
    The provider-assigned unique ID for this managed resource.
    status str
    Status of the internal access.
    accessIp String
    IP address of the internal access.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    Status of the internal access.

    Look up Existing TcrVpcAttachment Resource

    Get an existing TcrVpcAttachment 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?: TcrVpcAttachmentState, opts?: CustomResourceOptions): TcrVpcAttachment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            access_ip: Optional[str] = None,
            enable_public_domain_dns: Optional[bool] = None,
            enable_vpc_domain_dns: Optional[bool] = None,
            instance_id: Optional[str] = None,
            region_id: Optional[float] = None,
            region_name: Optional[str] = None,
            status: Optional[str] = None,
            subnet_id: Optional[str] = None,
            tcr_vpc_attachment_id: Optional[str] = None,
            vpc_id: Optional[str] = None) -> TcrVpcAttachment
    func GetTcrVpcAttachment(ctx *Context, name string, id IDInput, state *TcrVpcAttachmentState, opts ...ResourceOption) (*TcrVpcAttachment, error)
    public static TcrVpcAttachment Get(string name, Input<string> id, TcrVpcAttachmentState? state, CustomResourceOptions? opts = null)
    public static TcrVpcAttachment get(String name, Output<String> id, TcrVpcAttachmentState state, CustomResourceOptions options)
    resources:  _:    type: tencentcloud:TcrVpcAttachment    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.
    The following state arguments are supported:
    AccessIp string
    IP address of the internal access.
    EnablePublicDomainDns bool
    Whether to enable public domain dns. Default value is false.
    EnableVpcDomainDns bool
    Whether to enable vpc domain dns. Default value is false.
    InstanceId string
    ID of the TCR instance.
    RegionId double
    this argument was deprecated, use region_name instead. ID of region. Conflict with region_name, can not be set at the same time.

    Deprecated: Deprecated

    RegionName string
    Name of region. Conflict with region_id, can not be set at the same time.
    Status string
    Status of the internal access.
    SubnetId string
    ID of subnet.
    TcrVpcAttachmentId string
    ID of the resource.
    VpcId string
    ID of VPC.
    AccessIp string
    IP address of the internal access.
    EnablePublicDomainDns bool
    Whether to enable public domain dns. Default value is false.
    EnableVpcDomainDns bool
    Whether to enable vpc domain dns. Default value is false.
    InstanceId string
    ID of the TCR instance.
    RegionId float64
    this argument was deprecated, use region_name instead. ID of region. Conflict with region_name, can not be set at the same time.

    Deprecated: Deprecated

    RegionName string
    Name of region. Conflict with region_id, can not be set at the same time.
    Status string
    Status of the internal access.
    SubnetId string
    ID of subnet.
    TcrVpcAttachmentId string
    ID of the resource.
    VpcId string
    ID of VPC.
    accessIp String
    IP address of the internal access.
    enablePublicDomainDns Boolean
    Whether to enable public domain dns. Default value is false.
    enableVpcDomainDns Boolean
    Whether to enable vpc domain dns. Default value is false.
    instanceId String
    ID of the TCR instance.
    regionId Double
    this argument was deprecated, use region_name instead. ID of region. Conflict with region_name, can not be set at the same time.

    Deprecated: Deprecated

    regionName String
    Name of region. Conflict with region_id, can not be set at the same time.
    status String
    Status of the internal access.
    subnetId String
    ID of subnet.
    tcrVpcAttachmentId String
    ID of the resource.
    vpcId String
    ID of VPC.
    accessIp string
    IP address of the internal access.
    enablePublicDomainDns boolean
    Whether to enable public domain dns. Default value is false.
    enableVpcDomainDns boolean
    Whether to enable vpc domain dns. Default value is false.
    instanceId string
    ID of the TCR instance.
    regionId number
    this argument was deprecated, use region_name instead. ID of region. Conflict with region_name, can not be set at the same time.

    Deprecated: Deprecated

    regionName string
    Name of region. Conflict with region_id, can not be set at the same time.
    status string
    Status of the internal access.
    subnetId string
    ID of subnet.
    tcrVpcAttachmentId string
    ID of the resource.
    vpcId string
    ID of VPC.
    access_ip str
    IP address of the internal access.
    enable_public_domain_dns bool
    Whether to enable public domain dns. Default value is false.
    enable_vpc_domain_dns bool
    Whether to enable vpc domain dns. Default value is false.
    instance_id str
    ID of the TCR instance.
    region_id float
    this argument was deprecated, use region_name instead. ID of region. Conflict with region_name, can not be set at the same time.

    Deprecated: Deprecated

    region_name str
    Name of region. Conflict with region_id, can not be set at the same time.
    status str
    Status of the internal access.
    subnet_id str
    ID of subnet.
    tcr_vpc_attachment_id str
    ID of the resource.
    vpc_id str
    ID of VPC.
    accessIp String
    IP address of the internal access.
    enablePublicDomainDns Boolean
    Whether to enable public domain dns. Default value is false.
    enableVpcDomainDns Boolean
    Whether to enable vpc domain dns. Default value is false.
    instanceId String
    ID of the TCR instance.
    regionId Number
    this argument was deprecated, use region_name instead. ID of region. Conflict with region_name, can not be set at the same time.

    Deprecated: Deprecated

    regionName String
    Name of region. Conflict with region_id, can not be set at the same time.
    status String
    Status of the internal access.
    subnetId String
    ID of subnet.
    tcrVpcAttachmentId String
    ID of the resource.
    vpcId String
    ID of VPC.

    Import

    tcr vpc attachment can be imported using the id, e.g.

    $ pulumi import tencentcloud:index/tcrVpcAttachment:TcrVpcAttachment foo instance_id#vpc_id#subnet_id
    

    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.
    tencentcloud logo
    tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack