1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. cen
  5. InstanceGrant
Alibaba Cloud v3.55.0 published on Tuesday, Apr 30, 2024 by Pulumi

alicloud.cen.InstanceGrant

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.55.0 published on Tuesday, Apr 30, 2024 by Pulumi

    Provides a CEN child instance grant resource, which allow you to authorize a VPC or VBR to a CEN of a different account.

    For more information about how to use it, see Attach a network in a different account.

    NOTE: Available since v1.37.0.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const anotherUid = config.get("anotherUid") || "xxxx";
    const yourAccount = alicloud.getAccount({});
    const childAccount = alicloud.getAccount({});
    const default = alicloud.getRegions({
        current: true,
    });
    const example = new alicloud.cen.Instance("example", {
        cenInstanceName: "tf_example",
        description: "an example for cen",
    });
    const childAccountNetwork = new alicloud.vpc.Network("child_account", {
        vpcName: "terraform-example",
        cidrBlock: "172.17.3.0/24",
    });
    const childAccountInstanceGrant = new alicloud.cen.InstanceGrant("child_account", {
        cenId: example.id,
        childInstanceId: childAccountNetwork.id,
        cenOwnerId: yourAccount.then(yourAccount => yourAccount.id),
    });
    const exampleInstanceAttachment = new alicloud.cen.InstanceAttachment("example", {
        instanceId: example.id,
        childInstanceId: childAccountInstanceGrant.childInstanceId,
        childInstanceType: "VPC",
        childInstanceRegionId: _default.then(_default => _default.regions?.[0]?.id),
        childInstanceOwnerId: childAccount.then(childAccount => childAccount.id),
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    another_uid = config.get("anotherUid")
    if another_uid is None:
        another_uid = "xxxx"
    your_account = alicloud.get_account()
    child_account = alicloud.get_account()
    default = alicloud.get_regions(current=True)
    example = alicloud.cen.Instance("example",
        cen_instance_name="tf_example",
        description="an example for cen")
    child_account_network = alicloud.vpc.Network("child_account",
        vpc_name="terraform-example",
        cidr_block="172.17.3.0/24")
    child_account_instance_grant = alicloud.cen.InstanceGrant("child_account",
        cen_id=example.id,
        child_instance_id=child_account_network.id,
        cen_owner_id=your_account.id)
    example_instance_attachment = alicloud.cen.InstanceAttachment("example",
        instance_id=example.id,
        child_instance_id=child_account_instance_grant.child_instance_id,
        child_instance_type="VPC",
        child_instance_region_id=default.regions[0].id,
        child_instance_owner_id=child_account.id)
    
    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"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		cfg := config.New(ctx, "")
    		anotherUid := "xxxx"
    		if param := cfg.Get("anotherUid"); param != "" {
    			anotherUid = param
    		}
    		yourAccount, err := alicloud.GetAccount(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		childAccount, err := alicloud.GetAccount(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		_default, err := alicloud.GetRegions(ctx, &alicloud.GetRegionsArgs{
    			Current: pulumi.BoolRef(true),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		example, err := cen.NewInstance(ctx, "example", &cen.InstanceArgs{
    			CenInstanceName: pulumi.String("tf_example"),
    			Description:     pulumi.String("an example for cen"),
    		})
    		if err != nil {
    			return err
    		}
    		childAccountNetwork, err := vpc.NewNetwork(ctx, "child_account", &vpc.NetworkArgs{
    			VpcName:   pulumi.String("terraform-example"),
    			CidrBlock: pulumi.String("172.17.3.0/24"),
    		})
    		if err != nil {
    			return err
    		}
    		childAccountInstanceGrant, err := cen.NewInstanceGrant(ctx, "child_account", &cen.InstanceGrantArgs{
    			CenId:           example.ID(),
    			ChildInstanceId: childAccountNetwork.ID(),
    			CenOwnerId:      pulumi.String(yourAccount.Id),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = cen.NewInstanceAttachment(ctx, "example", &cen.InstanceAttachmentArgs{
    			InstanceId:            example.ID(),
    			ChildInstanceId:       childAccountInstanceGrant.ChildInstanceId,
    			ChildInstanceType:     pulumi.String("VPC"),
    			ChildInstanceRegionId: pulumi.String(_default.Regions[0].Id),
    			ChildInstanceOwnerId:  pulumi.String(childAccount.Id),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var anotherUid = config.Get("anotherUid") ?? "xxxx";
        var yourAccount = AliCloud.GetAccount.Invoke();
    
        var childAccount = AliCloud.GetAccount.Invoke();
    
        var @default = AliCloud.GetRegions.Invoke(new()
        {
            Current = true,
        });
    
        var example = new AliCloud.Cen.Instance("example", new()
        {
            CenInstanceName = "tf_example",
            Description = "an example for cen",
        });
    
        var childAccountNetwork = new AliCloud.Vpc.Network("child_account", new()
        {
            VpcName = "terraform-example",
            CidrBlock = "172.17.3.0/24",
        });
    
        var childAccountInstanceGrant = new AliCloud.Cen.InstanceGrant("child_account", new()
        {
            CenId = example.Id,
            ChildInstanceId = childAccountNetwork.Id,
            CenOwnerId = yourAccount.Apply(getAccountResult => getAccountResult.Id),
        });
    
        var exampleInstanceAttachment = new AliCloud.Cen.InstanceAttachment("example", new()
        {
            InstanceId = example.Id,
            ChildInstanceId = childAccountInstanceGrant.ChildInstanceId,
            ChildInstanceType = "VPC",
            ChildInstanceRegionId = @default.Apply(@default => @default.Apply(getRegionsResult => getRegionsResult.Regions[0]?.Id)),
            ChildInstanceOwnerId = childAccount.Apply(getAccountResult => getAccountResult.Id),
        });
    
    });
    
    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.cen.Instance;
    import com.pulumi.alicloud.cen.InstanceArgs;
    import com.pulumi.alicloud.vpc.Network;
    import com.pulumi.alicloud.vpc.NetworkArgs;
    import com.pulumi.alicloud.cen.InstanceGrant;
    import com.pulumi.alicloud.cen.InstanceGrantArgs;
    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 config = ctx.config();
            final var anotherUid = config.get("anotherUid").orElse("xxxx");
            final var yourAccount = AlicloudFunctions.getAccount();
    
            final var childAccount = AlicloudFunctions.getAccount();
    
            final var default = AlicloudFunctions.getRegions(GetRegionsArgs.builder()
                .current(true)
                .build());
    
            var example = new Instance("example", InstanceArgs.builder()        
                .cenInstanceName("tf_example")
                .description("an example for cen")
                .build());
    
            var childAccountNetwork = new Network("childAccountNetwork", NetworkArgs.builder()        
                .vpcName("terraform-example")
                .cidrBlock("172.17.3.0/24")
                .build());
    
            var childAccountInstanceGrant = new InstanceGrant("childAccountInstanceGrant", InstanceGrantArgs.builder()        
                .cenId(example.id())
                .childInstanceId(childAccountNetwork.id())
                .cenOwnerId(yourAccount.applyValue(getAccountResult -> getAccountResult.id()))
                .build());
    
            var exampleInstanceAttachment = new InstanceAttachment("exampleInstanceAttachment", InstanceAttachmentArgs.builder()        
                .instanceId(example.id())
                .childInstanceId(childAccountInstanceGrant.childInstanceId())
                .childInstanceType("VPC")
                .childInstanceRegionId(default_.regions()[0].id())
                .childInstanceOwnerId(childAccount.applyValue(getAccountResult -> getAccountResult.id()))
                .build());
    
        }
    }
    
    configuration:
      anotherUid:
        type: string
        default: xxxx
    resources:
      example:
        type: alicloud:cen:Instance
        properties:
          cenInstanceName: tf_example
          description: an example for cen
      childAccountNetwork:
        type: alicloud:vpc:Network
        name: child_account
        properties:
          vpcName: terraform-example
          cidrBlock: 172.17.3.0/24
      childAccountInstanceGrant:
        type: alicloud:cen:InstanceGrant
        name: child_account
        properties:
          cenId: ${example.id}
          childInstanceId: ${childAccountNetwork.id}
          cenOwnerId: ${yourAccount.id}
      exampleInstanceAttachment:
        type: alicloud:cen:InstanceAttachment
        name: example
        properties:
          instanceId: ${example.id}
          childInstanceId: ${childAccountInstanceGrant.childInstanceId}
          childInstanceType: VPC
          childInstanceRegionId: ${default.regions[0].id}
          childInstanceOwnerId: ${childAccount.id}
    variables:
      yourAccount:
        fn::invoke:
          Function: alicloud:getAccount
          Arguments: {}
      childAccount:
        fn::invoke:
          Function: alicloud:getAccount
          Arguments: {}
      default:
        fn::invoke:
          Function: alicloud:getRegions
          Arguments:
            current: true
    

    Create InstanceGrant Resource

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

    Constructor syntax

    new InstanceGrant(name: string, args: InstanceGrantArgs, opts?: CustomResourceOptions);
    @overload
    def InstanceGrant(resource_name: str,
                      args: InstanceGrantArgs,
                      opts: Optional[ResourceOptions] = None)
    
    @overload
    def InstanceGrant(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      cen_id: Optional[str] = None,
                      cen_owner_id: Optional[str] = None,
                      child_instance_id: Optional[str] = None)
    func NewInstanceGrant(ctx *Context, name string, args InstanceGrantArgs, opts ...ResourceOption) (*InstanceGrant, error)
    public InstanceGrant(string name, InstanceGrantArgs args, CustomResourceOptions? opts = null)
    public InstanceGrant(String name, InstanceGrantArgs args)
    public InstanceGrant(String name, InstanceGrantArgs args, CustomResourceOptions options)
    
    type: alicloud:cen:InstanceGrant
    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 InstanceGrantArgs
    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 InstanceGrantArgs
    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 InstanceGrantArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args InstanceGrantArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args InstanceGrantArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    var instanceGrantResource = new AliCloud.Cen.InstanceGrant("instanceGrantResource", new()
    {
        CenId = "string",
        CenOwnerId = "string",
        ChildInstanceId = "string",
    });
    
    example, err := cen.NewInstanceGrant(ctx, "instanceGrantResource", &cen.InstanceGrantArgs{
    	CenId:           pulumi.String("string"),
    	CenOwnerId:      pulumi.String("string"),
    	ChildInstanceId: pulumi.String("string"),
    })
    
    var instanceGrantResource = new InstanceGrant("instanceGrantResource", InstanceGrantArgs.builder()        
        .cenId("string")
        .cenOwnerId("string")
        .childInstanceId("string")
        .build());
    
    instance_grant_resource = alicloud.cen.InstanceGrant("instanceGrantResource",
        cen_id="string",
        cen_owner_id="string",
        child_instance_id="string")
    
    const instanceGrantResource = new alicloud.cen.InstanceGrant("instanceGrantResource", {
        cenId: "string",
        cenOwnerId: "string",
        childInstanceId: "string",
    });
    
    type: alicloud:cen:InstanceGrant
    properties:
        cenId: string
        cenOwnerId: string
        childInstanceId: string
    

    InstanceGrant Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The InstanceGrant resource accepts the following input properties:

    CenId string
    The ID of the CEN.
    CenOwnerId string
    The owner UID of the CEN which the child instance granted to.
    ChildInstanceId string
    The ID of the child instance to grant.
    CenId string
    The ID of the CEN.
    CenOwnerId string
    The owner UID of the CEN which the child instance granted to.
    ChildInstanceId string
    The ID of the child instance to grant.
    cenId String
    The ID of the CEN.
    cenOwnerId String
    The owner UID of the CEN which the child instance granted to.
    childInstanceId String
    The ID of the child instance to grant.
    cenId string
    The ID of the CEN.
    cenOwnerId string
    The owner UID of the CEN which the child instance granted to.
    childInstanceId string
    The ID of the child instance to grant.
    cen_id str
    The ID of the CEN.
    cen_owner_id str
    The owner UID of the CEN which the child instance granted to.
    child_instance_id str
    The ID of the child instance to grant.
    cenId String
    The ID of the CEN.
    cenOwnerId String
    The owner UID of the CEN which the child instance granted to.
    childInstanceId String
    The ID of the child instance to grant.

    Outputs

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

    Get an existing InstanceGrant 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?: InstanceGrantState, opts?: CustomResourceOptions): InstanceGrant
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            cen_id: Optional[str] = None,
            cen_owner_id: Optional[str] = None,
            child_instance_id: Optional[str] = None) -> InstanceGrant
    func GetInstanceGrant(ctx *Context, name string, id IDInput, state *InstanceGrantState, opts ...ResourceOption) (*InstanceGrant, error)
    public static InstanceGrant Get(string name, Input<string> id, InstanceGrantState? state, CustomResourceOptions? opts = null)
    public static InstanceGrant get(String name, Output<String> id, InstanceGrantState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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:
    CenId string
    The ID of the CEN.
    CenOwnerId string
    The owner UID of the CEN which the child instance granted to.
    ChildInstanceId string
    The ID of the child instance to grant.
    CenId string
    The ID of the CEN.
    CenOwnerId string
    The owner UID of the CEN which the child instance granted to.
    ChildInstanceId string
    The ID of the child instance to grant.
    cenId String
    The ID of the CEN.
    cenOwnerId String
    The owner UID of the CEN which the child instance granted to.
    childInstanceId String
    The ID of the child instance to grant.
    cenId string
    The ID of the CEN.
    cenOwnerId string
    The owner UID of the CEN which the child instance granted to.
    childInstanceId string
    The ID of the child instance to grant.
    cen_id str
    The ID of the CEN.
    cen_owner_id str
    The owner UID of the CEN which the child instance granted to.
    child_instance_id str
    The ID of the child instance to grant.
    cenId String
    The ID of the CEN.
    cenOwnerId String
    The owner UID of the CEN which the child instance granted to.
    childInstanceId String
    The ID of the child instance to grant.

    Import

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

    $ pulumi import alicloud:cen/instanceGrant:InstanceGrant example cen-abc123456:vpc-abc123456:uid123456
    

    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.
    alicloud logo
    Alibaba Cloud v3.55.0 published on Tuesday, Apr 30, 2024 by Pulumi