alicloud.cen.InstanceGrant
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.
Example Usage
Basic Usage
using System.Collections.Generic;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
// Create a new instance-grant and use it to grant one child instance of account1 to a new CEN of account 2.
var account1 = new AliCloud.Provider("account1", new()
{
AccessKey = "access123",
SecretKey = "secret123",
});
var account2 = new AliCloud.Provider("account2", new()
{
AccessKey = "access456",
SecretKey = "secret456",
});
var config = new Config();
var name = config.Get("name") ?? "tf-testAccCenInstanceGrantBasic";
var cen = new AliCloud.Cen.Instance("cen", new()
{
}, new CustomResourceOptions
{
Provider = alicloud.Account2,
});
var vpc = new AliCloud.Vpc.Network("vpc", new()
{
CidrBlock = "192.168.0.0/16",
}, new CustomResourceOptions
{
Provider = alicloud.Account1,
});
var fooInstanceGrant = new AliCloud.Cen.InstanceGrant("fooInstanceGrant", new()
{
CenId = cen.Id,
ChildInstanceId = vpc.Id,
CenOwnerId = "uid2",
}, new CustomResourceOptions
{
Provider = alicloud.Account1,
});
var fooInstanceAttachment = new AliCloud.Cen.InstanceAttachment("fooInstanceAttachment", new()
{
InstanceId = cen.Id,
ChildInstanceId = vpc.Id,
ChildInstanceType = "VPC",
ChildInstanceRegionId = "cn-qingdao",
ChildInstanceOwnerId = "uid1",
}, new CustomResourceOptions
{
Provider = alicloud.Account2,
DependsOn = new[]
{
fooInstanceGrant,
},
});
});
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 {
_, err := alicloud.NewProvider(ctx, "account1", &alicloud.ProviderArgs{
AccessKey: pulumi.String("access123"),
SecretKey: pulumi.String("secret123"),
})
if err != nil {
return err
}
_, err = alicloud.NewProvider(ctx, "account2", &alicloud.ProviderArgs{
AccessKey: pulumi.String("access456"),
SecretKey: pulumi.String("secret456"),
})
if err != nil {
return err
}
cfg := config.New(ctx, "")
name := "tf-testAccCenInstanceGrantBasic"
if param := cfg.Get("name"); param != "" {
name = param
}
cen, err := cen.NewInstance(ctx, "cen", nil, pulumi.Provider(alicloud.Account2))
if err != nil {
return err
}
vpc, err := vpc.NewNetwork(ctx, "vpc", &vpc.NetworkArgs{
CidrBlock: pulumi.String("192.168.0.0/16"),
}, pulumi.Provider(alicloud.Account1))
if err != nil {
return err
}
fooInstanceGrant, err := cen.NewInstanceGrant(ctx, "fooInstanceGrant", &cen.InstanceGrantArgs{
CenId: cen.ID(),
ChildInstanceId: vpc.ID(),
CenOwnerId: pulumi.String("uid2"),
}, pulumi.Provider(alicloud.Account1))
if err != nil {
return err
}
_, err = cen.NewInstanceAttachment(ctx, "fooInstanceAttachment", &cen.InstanceAttachmentArgs{
InstanceId: cen.ID(),
ChildInstanceId: vpc.ID(),
ChildInstanceType: pulumi.String("VPC"),
ChildInstanceRegionId: pulumi.String("cn-qingdao"),
ChildInstanceOwnerId: pulumi.Int("uid1"),
}, pulumi.Provider(alicloud.Account2), pulumi.DependsOn([]pulumi.Resource{
fooInstanceGrant,
}))
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.Provider;
import com.pulumi.alicloud.ProviderArgs;
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 com.pulumi.resources.CustomResourceOptions;
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();
var account1 = new Provider("account1", ProviderArgs.builder()
.accessKey("access123")
.secretKey("secret123")
.build());
var account2 = new Provider("account2", ProviderArgs.builder()
.accessKey("access456")
.secretKey("secret456")
.build());
final var name = config.get("name").orElse("tf-testAccCenInstanceGrantBasic");
var cen = new Instance("cen", InstanceArgs.Empty, CustomResourceOptions.builder()
.provider(alicloud.account2())
.build());
var vpc = new Network("vpc", NetworkArgs.builder()
.cidrBlock("192.168.0.0/16")
.build(), CustomResourceOptions.builder()
.provider(alicloud.account1())
.build());
var fooInstanceGrant = new InstanceGrant("fooInstanceGrant", InstanceGrantArgs.builder()
.cenId(cen.id())
.childInstanceId(vpc.id())
.cenOwnerId("uid2")
.build(), CustomResourceOptions.builder()
.provider(alicloud.account1())
.build());
var fooInstanceAttachment = new InstanceAttachment("fooInstanceAttachment", InstanceAttachmentArgs.builder()
.instanceId(cen.id())
.childInstanceId(vpc.id())
.childInstanceType("VPC")
.childInstanceRegionId("cn-qingdao")
.childInstanceOwnerId("uid1")
.build(), CustomResourceOptions.builder()
.provider(alicloud.account2())
.dependsOn(fooInstanceGrant)
.build());
}
}
import pulumi
import pulumi_alicloud as alicloud
# Create a new instance-grant and use it to grant one child instance of account1 to a new CEN of account 2.
account1 = alicloud.Provider("account1",
access_key="access123",
secret_key="secret123")
account2 = alicloud.Provider("account2",
access_key="access456",
secret_key="secret456")
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "tf-testAccCenInstanceGrantBasic"
cen = alicloud.cen.Instance("cen", opts=pulumi.ResourceOptions(provider=alicloud["account2"]))
vpc = alicloud.vpc.Network("vpc", cidr_block="192.168.0.0/16",
opts=pulumi.ResourceOptions(provider=alicloud["account1"]))
foo_instance_grant = alicloud.cen.InstanceGrant("fooInstanceGrant",
cen_id=cen.id,
child_instance_id=vpc.id,
cen_owner_id="uid2",
opts=pulumi.ResourceOptions(provider=alicloud["account1"]))
foo_instance_attachment = alicloud.cen.InstanceAttachment("fooInstanceAttachment",
instance_id=cen.id,
child_instance_id=vpc.id,
child_instance_type="VPC",
child_instance_region_id="cn-qingdao",
child_instance_owner_id="uid1",
opts=pulumi.ResourceOptions(provider=alicloud["account2"],
depends_on=[foo_instance_grant]))
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
// Create a new instance-grant and use it to grant one child instance of account1 to a new CEN of account 2.
const account1 = new alicloud.Provider("account1", {
accessKey: "access123",
secretKey: "secret123",
});
const account2 = new alicloud.Provider("account2", {
accessKey: "access456",
secretKey: "secret456",
});
const config = new pulumi.Config();
const name = config.get("name") || "tf-testAccCenInstanceGrantBasic";
const cen = new alicloud.cen.Instance("cen", {}, {
provider: alicloud.account2,
});
const vpc = new alicloud.vpc.Network("vpc", {cidrBlock: "192.168.0.0/16"}, {
provider: alicloud.account1,
});
const fooInstanceGrant = new alicloud.cen.InstanceGrant("fooInstanceGrant", {
cenId: cen.id,
childInstanceId: vpc.id,
cenOwnerId: "uid2",
}, {
provider: alicloud.account1,
});
const fooInstanceAttachment = new alicloud.cen.InstanceAttachment("fooInstanceAttachment", {
instanceId: cen.id,
childInstanceId: vpc.id,
childInstanceType: "VPC",
childInstanceRegionId: "cn-qingdao",
childInstanceOwnerId: "uid1",
}, {
provider: alicloud.account2,
dependsOn: [fooInstanceGrant],
});
configuration:
name:
type: string
default: tf-testAccCenInstanceGrantBasic
resources:
# Create a new instance-grant and use it to grant one child instance of account1 to a new CEN of account 2.
account1:
type: pulumi:providers:alicloud
properties:
accessKey: access123
secretKey: secret123
account2:
type: pulumi:providers:alicloud
properties:
accessKey: access456
secretKey: secret456
cen:
type: alicloud:cen:Instance
options:
provider: ${alicloud.account2}
vpc:
type: alicloud:vpc:Network
properties:
cidrBlock: 192.168.0.0/16
options:
provider: ${alicloud.account1}
fooInstanceGrant:
type: alicloud:cen:InstanceGrant
properties:
cenId: ${cen.id}
childInstanceId: ${vpc.id}
cenOwnerId: uid2
options:
provider: ${alicloud.account1}
fooInstanceAttachment:
type: alicloud:cen:InstanceAttachment
properties:
instanceId: ${cen.id}
childInstanceId: ${vpc.id}
childInstanceType: VPC
childInstanceRegionId: cn-qingdao
childInstanceOwnerId: uid1
options:
provider: ${alicloud.account2}
dependson:
- ${fooInstanceGrant}
Create InstanceGrant Resource
new InstanceGrant(name: string, args: InstanceGrantArgs, opts?: CustomResourceOptions);
@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)
@overload
def InstanceGrant(resource_name: str,
args: InstanceGrantArgs,
opts: Optional[ResourceOptions] = 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.
- 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.
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:
- Cen
Id string The ID of the CEN.
- Cen
Owner stringId The owner UID of the CEN which the child instance granted to.
- Child
Instance stringId The ID of the child instance to grant.
- Cen
Id string The ID of the CEN.
- Cen
Owner stringId The owner UID of the CEN which the child instance granted to.
- Child
Instance stringId The ID of the child instance to grant.
- cen
Id String The ID of the CEN.
- cen
Owner StringId The owner UID of the CEN which the child instance granted to.
- child
Instance StringId The ID of the child instance to grant.
- cen
Id string The ID of the CEN.
- cen
Owner stringId The owner UID of the CEN which the child instance granted to.
- child
Instance stringId The ID of the child instance to grant.
- cen_
id str The ID of the CEN.
- cen_
owner_ strid The owner UID of the CEN which the child instance granted to.
- child_
instance_ strid The ID of the child instance to grant.
- cen
Id String The ID of the CEN.
- cen
Owner StringId The owner UID of the CEN which the child instance granted to.
- child
Instance StringId 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.
- Cen
Id string The ID of the CEN.
- Cen
Owner stringId The owner UID of the CEN which the child instance granted to.
- Child
Instance stringId The ID of the child instance to grant.
- Cen
Id string The ID of the CEN.
- Cen
Owner stringId The owner UID of the CEN which the child instance granted to.
- Child
Instance stringId The ID of the child instance to grant.
- cen
Id String The ID of the CEN.
- cen
Owner StringId The owner UID of the CEN which the child instance granted to.
- child
Instance StringId The ID of the child instance to grant.
- cen
Id string The ID of the CEN.
- cen
Owner stringId The owner UID of the CEN which the child instance granted to.
- child
Instance stringId The ID of the child instance to grant.
- cen_
id str The ID of the CEN.
- cen_
owner_ strid The owner UID of the CEN which the child instance granted to.
- child_
instance_ strid The ID of the child instance to grant.
- cen
Id String The ID of the CEN.
- cen
Owner StringId The owner UID of the CEN which the child instance granted to.
- child
Instance StringId 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
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
alicloud
Terraform Provider.