1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. cen
  5. InstanceAttachment
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.cen.InstanceAttachment

Explore with Pulumi AI

Provides a CEN child instance attachment resource that associate the network(VPC, CCN, VBR) with the CEN instance.

NOTE: Available since v1.42.0.

Example Usage

Basic Usage

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

const _default = alicloud.getRegions({
    current: true,
});
const example = new alicloud.vpc.Network("example", {
    vpcName: "tf_example",
    cidrBlock: "172.17.3.0/24",
});
const exampleInstance = new alicloud.cen.Instance("example", {
    cenInstanceName: "tf_example",
    description: "an example for cen",
});
const exampleInstanceAttachment = new alicloud.cen.InstanceAttachment("example", {
    instanceId: exampleInstance.id,
    childInstanceId: example.id,
    childInstanceType: "VPC",
    childInstanceRegionId: _default.then(_default => _default.regions?.[0]?.id),
});
Copy
import pulumi
import pulumi_alicloud as alicloud

default = alicloud.get_regions(current=True)
example = alicloud.vpc.Network("example",
    vpc_name="tf_example",
    cidr_block="172.17.3.0/24")
example_instance = alicloud.cen.Instance("example",
    cen_instance_name="tf_example",
    description="an example for cen")
example_instance_attachment = alicloud.cen.InstanceAttachment("example",
    instance_id=example_instance.id,
    child_instance_id=example.id,
    child_instance_type="VPC",
    child_instance_region_id=default.regions[0].id)
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/cen"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_default, err := alicloud.GetRegions(ctx, &alicloud.GetRegionsArgs{
			Current: pulumi.BoolRef(true),
		}, nil)
		if err != nil {
			return err
		}
		example, err := vpc.NewNetwork(ctx, "example", &vpc.NetworkArgs{
			VpcName:   pulumi.String("tf_example"),
			CidrBlock: pulumi.String("172.17.3.0/24"),
		})
		if err != nil {
			return err
		}
		exampleInstance, err := cen.NewInstance(ctx, "example", &cen.InstanceArgs{
			CenInstanceName: pulumi.String("tf_example"),
			Description:     pulumi.String("an example for cen"),
		})
		if err != nil {
			return err
		}
		_, err = cen.NewInstanceAttachment(ctx, "example", &cen.InstanceAttachmentArgs{
			InstanceId:            exampleInstance.ID(),
			ChildInstanceId:       example.ID(),
			ChildInstanceType:     pulumi.String("VPC"),
			ChildInstanceRegionId: pulumi.String(_default.Regions[0].Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var @default = AliCloud.GetRegions.Invoke(new()
    {
        Current = true,
    });

    var example = new AliCloud.Vpc.Network("example", new()
    {
        VpcName = "tf_example",
        CidrBlock = "172.17.3.0/24",
    });

    var exampleInstance = new AliCloud.Cen.Instance("example", new()
    {
        CenInstanceName = "tf_example",
        Description = "an example for cen",
    });

    var exampleInstanceAttachment = new AliCloud.Cen.InstanceAttachment("example", new()
    {
        InstanceId = exampleInstance.Id,
        ChildInstanceId = example.Id,
        ChildInstanceType = "VPC",
        ChildInstanceRegionId = @default.Apply(@default => @default.Apply(getRegionsResult => getRegionsResult.Regions[0]?.Id)),
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.inputs.GetRegionsArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.cen.Instance;
import com.pulumi.alicloud.cen.InstanceArgs;
import com.pulumi.alicloud.cen.InstanceAttachment;
import com.pulumi.alicloud.cen.InstanceAttachmentArgs;
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 default = AlicloudFunctions.getRegions(GetRegionsArgs.builder()
            .current(true)
            .build());

        var example = new Network("example", NetworkArgs.builder()
            .vpcName("tf_example")
            .cidrBlock("172.17.3.0/24")
            .build());

        var exampleInstance = new Instance("exampleInstance", InstanceArgs.builder()
            .cenInstanceName("tf_example")
            .description("an example for cen")
            .build());

        var exampleInstanceAttachment = new InstanceAttachment("exampleInstanceAttachment", InstanceAttachmentArgs.builder()
            .instanceId(exampleInstance.id())
            .childInstanceId(example.id())
            .childInstanceType("VPC")
            .childInstanceRegionId(default_.regions()[0].id())
            .build());

    }
}
Copy
resources:
  example:
    type: alicloud:vpc:Network
    properties:
      vpcName: tf_example
      cidrBlock: 172.17.3.0/24
  exampleInstance:
    type: alicloud:cen:Instance
    name: example
    properties:
      cenInstanceName: tf_example
      description: an example for cen
  exampleInstanceAttachment:
    type: alicloud:cen:InstanceAttachment
    name: example
    properties:
      instanceId: ${exampleInstance.id}
      childInstanceId: ${example.id}
      childInstanceType: VPC
      childInstanceRegionId: ${default.regions[0].id}
variables:
  default:
    fn::invoke:
      function: alicloud:getRegions
      arguments:
        current: true
Copy

Create InstanceAttachment Resource

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

Constructor syntax

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

@overload
def InstanceAttachment(resource_name: str,
                       opts: Optional[ResourceOptions] = None,
                       child_instance_id: Optional[str] = None,
                       child_instance_region_id: Optional[str] = None,
                       child_instance_type: Optional[str] = None,
                       instance_id: Optional[str] = None,
                       cen_owner_id: Optional[int] = None,
                       child_instance_owner_id: Optional[int] = None)
func NewInstanceAttachment(ctx *Context, name string, args InstanceAttachmentArgs, opts ...ResourceOption) (*InstanceAttachment, error)
public InstanceAttachment(string name, InstanceAttachmentArgs args, CustomResourceOptions? opts = null)
public InstanceAttachment(String name, InstanceAttachmentArgs args)
public InstanceAttachment(String name, InstanceAttachmentArgs args, CustomResourceOptions options)
type: alicloud:cen:InstanceAttachment
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. InstanceAttachmentArgs
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. InstanceAttachmentArgs
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. InstanceAttachmentArgs
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. InstanceAttachmentArgs
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. InstanceAttachmentArgs
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 instanceAttachmentResource = new AliCloud.Cen.InstanceAttachment("instanceAttachmentResource", new()
{
    ChildInstanceId = "string",
    ChildInstanceRegionId = "string",
    ChildInstanceType = "string",
    InstanceId = "string",
    CenOwnerId = 0,
    ChildInstanceOwnerId = 0,
});
Copy
example, err := cen.NewInstanceAttachment(ctx, "instanceAttachmentResource", &cen.InstanceAttachmentArgs{
	ChildInstanceId:       pulumi.String("string"),
	ChildInstanceRegionId: pulumi.String("string"),
	ChildInstanceType:     pulumi.String("string"),
	InstanceId:            pulumi.String("string"),
	CenOwnerId:            pulumi.Int(0),
	ChildInstanceOwnerId:  pulumi.Int(0),
})
Copy
var instanceAttachmentResource = new InstanceAttachment("instanceAttachmentResource", InstanceAttachmentArgs.builder()
    .childInstanceId("string")
    .childInstanceRegionId("string")
    .childInstanceType("string")
    .instanceId("string")
    .cenOwnerId(0)
    .childInstanceOwnerId(0)
    .build());
Copy
instance_attachment_resource = alicloud.cen.InstanceAttachment("instanceAttachmentResource",
    child_instance_id="string",
    child_instance_region_id="string",
    child_instance_type="string",
    instance_id="string",
    cen_owner_id=0,
    child_instance_owner_id=0)
Copy
const instanceAttachmentResource = new alicloud.cen.InstanceAttachment("instanceAttachmentResource", {
    childInstanceId: "string",
    childInstanceRegionId: "string",
    childInstanceType: "string",
    instanceId: "string",
    cenOwnerId: 0,
    childInstanceOwnerId: 0,
});
Copy
type: alicloud:cen:InstanceAttachment
properties:
    cenOwnerId: 0
    childInstanceId: string
    childInstanceOwnerId: 0
    childInstanceRegionId: string
    childInstanceType: string
    instanceId: string
Copy

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

ChildInstanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the child instance to attach.
ChildInstanceRegionId
This property is required.
Changes to this property will trigger replacement.
string
The region ID of the child instance to attach.
ChildInstanceType
This property is required.
Changes to this property will trigger replacement.
string
The type of the associated network. Valid values: VPC, VBR and CCN.
InstanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the CEN.
CenOwnerId int

The account ID to which the CEN instance belongs.

->NOTE: Ensure that the child instance is not used in Express Connect.

ChildInstanceOwnerId int
The uid of the child instance. Only used when attach a child instance of other account.
ChildInstanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the child instance to attach.
ChildInstanceRegionId
This property is required.
Changes to this property will trigger replacement.
string
The region ID of the child instance to attach.
ChildInstanceType
This property is required.
Changes to this property will trigger replacement.
string
The type of the associated network. Valid values: VPC, VBR and CCN.
InstanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the CEN.
CenOwnerId int

The account ID to which the CEN instance belongs.

->NOTE: Ensure that the child instance is not used in Express Connect.

ChildInstanceOwnerId int
The uid of the child instance. Only used when attach a child instance of other account.
childInstanceId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the child instance to attach.
childInstanceRegionId
This property is required.
Changes to this property will trigger replacement.
String
The region ID of the child instance to attach.
childInstanceType
This property is required.
Changes to this property will trigger replacement.
String
The type of the associated network. Valid values: VPC, VBR and CCN.
instanceId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the CEN.
cenOwnerId Integer

The account ID to which the CEN instance belongs.

->NOTE: Ensure that the child instance is not used in Express Connect.

childInstanceOwnerId Integer
The uid of the child instance. Only used when attach a child instance of other account.
childInstanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the child instance to attach.
childInstanceRegionId
This property is required.
Changes to this property will trigger replacement.
string
The region ID of the child instance to attach.
childInstanceType
This property is required.
Changes to this property will trigger replacement.
string
The type of the associated network. Valid values: VPC, VBR and CCN.
instanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the CEN.
cenOwnerId number

The account ID to which the CEN instance belongs.

->NOTE: Ensure that the child instance is not used in Express Connect.

childInstanceOwnerId number
The uid of the child instance. Only used when attach a child instance of other account.
child_instance_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the child instance to attach.
child_instance_region_id
This property is required.
Changes to this property will trigger replacement.
str
The region ID of the child instance to attach.
child_instance_type
This property is required.
Changes to this property will trigger replacement.
str
The type of the associated network. Valid values: VPC, VBR and CCN.
instance_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the CEN.
cen_owner_id int

The account ID to which the CEN instance belongs.

->NOTE: Ensure that the child instance is not used in Express Connect.

child_instance_owner_id int
The uid of the child instance. Only used when attach a child instance of other account.
childInstanceId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the child instance to attach.
childInstanceRegionId
This property is required.
Changes to this property will trigger replacement.
String
The region ID of the child instance to attach.
childInstanceType
This property is required.
Changes to this property will trigger replacement.
String
The type of the associated network. Valid values: VPC, VBR and CCN.
instanceId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the CEN.
cenOwnerId Number

The account ID to which the CEN instance belongs.

->NOTE: Ensure that the child instance is not used in Express Connect.

childInstanceOwnerId Number
The uid of the child instance. Only used when attach a child instance of other account.

Outputs

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

Id string
The provider-assigned unique ID for this managed resource.
Status string
The associating status of the network.
Id string
The provider-assigned unique ID for this managed resource.
Status string
The associating status of the network.
id String
The provider-assigned unique ID for this managed resource.
status String
The associating status of the network.
id string
The provider-assigned unique ID for this managed resource.
status string
The associating status of the network.
id str
The provider-assigned unique ID for this managed resource.
status str
The associating status of the network.
id String
The provider-assigned unique ID for this managed resource.
status String
The associating status of the network.

Look up Existing InstanceAttachment Resource

Get an existing InstanceAttachment 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?: InstanceAttachmentState, opts?: CustomResourceOptions): InstanceAttachment
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        cen_owner_id: Optional[int] = None,
        child_instance_id: Optional[str] = None,
        child_instance_owner_id: Optional[int] = None,
        child_instance_region_id: Optional[str] = None,
        child_instance_type: Optional[str] = None,
        instance_id: Optional[str] = None,
        status: Optional[str] = None) -> InstanceAttachment
func GetInstanceAttachment(ctx *Context, name string, id IDInput, state *InstanceAttachmentState, opts ...ResourceOption) (*InstanceAttachment, error)
public static InstanceAttachment Get(string name, Input<string> id, InstanceAttachmentState? state, CustomResourceOptions? opts = null)
public static InstanceAttachment get(String name, Output<String> id, InstanceAttachmentState state, CustomResourceOptions options)
resources:  _:    type: alicloud:cen:InstanceAttachment    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:
CenOwnerId int

The account ID to which the CEN instance belongs.

->NOTE: Ensure that the child instance is not used in Express Connect.

ChildInstanceId Changes to this property will trigger replacement. string
The ID of the child instance to attach.
ChildInstanceOwnerId int
The uid of the child instance. Only used when attach a child instance of other account.
ChildInstanceRegionId Changes to this property will trigger replacement. string
The region ID of the child instance to attach.
ChildInstanceType Changes to this property will trigger replacement. string
The type of the associated network. Valid values: VPC, VBR and CCN.
InstanceId Changes to this property will trigger replacement. string
The ID of the CEN.
Status string
The associating status of the network.
CenOwnerId int

The account ID to which the CEN instance belongs.

->NOTE: Ensure that the child instance is not used in Express Connect.

ChildInstanceId Changes to this property will trigger replacement. string
The ID of the child instance to attach.
ChildInstanceOwnerId int
The uid of the child instance. Only used when attach a child instance of other account.
ChildInstanceRegionId Changes to this property will trigger replacement. string
The region ID of the child instance to attach.
ChildInstanceType Changes to this property will trigger replacement. string
The type of the associated network. Valid values: VPC, VBR and CCN.
InstanceId Changes to this property will trigger replacement. string
The ID of the CEN.
Status string
The associating status of the network.
cenOwnerId Integer

The account ID to which the CEN instance belongs.

->NOTE: Ensure that the child instance is not used in Express Connect.

childInstanceId Changes to this property will trigger replacement. String
The ID of the child instance to attach.
childInstanceOwnerId Integer
The uid of the child instance. Only used when attach a child instance of other account.
childInstanceRegionId Changes to this property will trigger replacement. String
The region ID of the child instance to attach.
childInstanceType Changes to this property will trigger replacement. String
The type of the associated network. Valid values: VPC, VBR and CCN.
instanceId Changes to this property will trigger replacement. String
The ID of the CEN.
status String
The associating status of the network.
cenOwnerId number

The account ID to which the CEN instance belongs.

->NOTE: Ensure that the child instance is not used in Express Connect.

childInstanceId Changes to this property will trigger replacement. string
The ID of the child instance to attach.
childInstanceOwnerId number
The uid of the child instance. Only used when attach a child instance of other account.
childInstanceRegionId Changes to this property will trigger replacement. string
The region ID of the child instance to attach.
childInstanceType Changes to this property will trigger replacement. string
The type of the associated network. Valid values: VPC, VBR and CCN.
instanceId Changes to this property will trigger replacement. string
The ID of the CEN.
status string
The associating status of the network.
cen_owner_id int

The account ID to which the CEN instance belongs.

->NOTE: Ensure that the child instance is not used in Express Connect.

child_instance_id Changes to this property will trigger replacement. str
The ID of the child instance to attach.
child_instance_owner_id int
The uid of the child instance. Only used when attach a child instance of other account.
child_instance_region_id Changes to this property will trigger replacement. str
The region ID of the child instance to attach.
child_instance_type Changes to this property will trigger replacement. str
The type of the associated network. Valid values: VPC, VBR and CCN.
instance_id Changes to this property will trigger replacement. str
The ID of the CEN.
status str
The associating status of the network.
cenOwnerId Number

The account ID to which the CEN instance belongs.

->NOTE: Ensure that the child instance is not used in Express Connect.

childInstanceId Changes to this property will trigger replacement. String
The ID of the child instance to attach.
childInstanceOwnerId Number
The uid of the child instance. Only used when attach a child instance of other account.
childInstanceRegionId Changes to this property will trigger replacement. String
The region ID of the child instance to attach.
childInstanceType Changes to this property will trigger replacement. String
The type of the associated network. Valid values: VPC, VBR and CCN.
instanceId Changes to this property will trigger replacement. String
The ID of the CEN.
status String
The associating status of the network.

Import

CEN instance can be imported using the id, e.g.

$ pulumi import alicloud:cen/instanceAttachment:InstanceAttachment example cen-m7i7pjmkon********:vpc-2ze2w07mcy9nz********:VPC:cn-beijing
Copy

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

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.