1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. cloudconnect
  5. NetworkGrant
Alibaba Cloud v3.51.0 published on Saturday, Mar 23, 2024 by Pulumi

alicloud.cloudconnect.NetworkGrant

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.51.0 published on Saturday, Mar 23, 2024 by Pulumi

    Provides a Cloud Connect Network Grant resource. If the CEN instance to be attached belongs to another account, authorization by the CEN instance is required.

    For information about Cloud Connect Network Grant and how to use it, see What is Cloud Connect Network Grant.

    NOTE: Available since v1.63.0.

    NOTE: Only the following regions support create Cloud Connect Network Grant. [cn-shanghai, cn-shanghai-finance-1, cn-hongkong, ap-southeast-1, ap-southeast-2, ap-southeast-3, ap-southeast-5, ap-northeast-1, eu-central-1]

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "tf-example";
    const cenUid = config.getNumber("cenUid") || 123456789;
    const _default = new alicloud.Provider("default", {region: "cn-shanghai"});
    // Method 1: Use assume_role to operate resources in the target cen account, detail see https://registry.terraform.io/providers/aliyun/alicloud/latest/docs#assume-role
    const cenAccount = new alicloud.Provider("cenAccount", {
        region: "cn-hangzhou",
        assumeRole: {
            roleArn: `acs:ram::${cenUid}:role/terraform-example-assume-role`,
        },
    });
    // Method 2: Use the target cen account's access_key, secret_key
    // provider "alicloud" {
    //   region     = "cn-hangzhou"
    //   access_key = "access_key"
    //   secret_key = "secret_key"
    //   alias      = "cen_account"
    // }
    const defaultNetwork = new alicloud.cloudconnect.Network("defaultNetwork", {
        description: name,
        cidrBlock: "192.168.0.0/24",
        isDefault: true,
    }, {
        provider: alicloud["default"],
    });
    const cen = new alicloud.cen.Instance("cen", {cenInstanceName: name}, {
        provider: alicloud.cen_account,
    });
    const defaultNetworkGrant = new alicloud.cloudconnect.NetworkGrant("defaultNetworkGrant", {
        ccnId: defaultNetwork.id,
        cenId: cen.id,
        cenUid: cenUid,
    }, {
        provider: alicloud["default"],
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "tf-example"
    cen_uid = config.get_float("cenUid")
    if cen_uid is None:
        cen_uid = 123456789
    default = alicloud.Provider("default", region="cn-shanghai")
    # Method 1: Use assume_role to operate resources in the target cen account, detail see https://registry.terraform.io/providers/aliyun/alicloud/latest/docs#assume-role
    cen_account = alicloud.Provider("cenAccount",
        region="cn-hangzhou",
        assume_role=alicloud.ProviderAssumeRoleArgs(
            role_arn=f"acs:ram::{cen_uid}:role/terraform-example-assume-role",
        ))
    # Method 2: Use the target cen account's access_key, secret_key
    # provider "alicloud" {
    #   region     = "cn-hangzhou"
    #   access_key = "access_key"
    #   secret_key = "secret_key"
    #   alias      = "cen_account"
    # }
    default_network = alicloud.cloudconnect.Network("defaultNetwork",
        description=name,
        cidr_block="192.168.0.0/24",
        is_default=True,
        opts=pulumi.ResourceOptions(provider=alicloud["default"]))
    cen = alicloud.cen.Instance("cen", cen_instance_name=name,
    opts=pulumi.ResourceOptions(provider=alicloud["cen_account"]))
    default_network_grant = alicloud.cloudconnect.NetworkGrant("defaultNetworkGrant",
        ccn_id=default_network.id,
        cen_id=cen.id,
        cen_uid=cen_uid,
        opts=pulumi.ResourceOptions(provider=alicloud["default"]))
    
    package main
    
    import (
    	"fmt"
    
    	"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/cloudconnect"
    	"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, "")
    		name := "tf-example"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		cenUid := float64(123456789)
    		if param := cfg.GetFloat64("cenUid"); param != 0 {
    			cenUid = param
    		}
    		_, err := alicloud.NewProvider(ctx, "default", &alicloud.ProviderArgs{
    			Region: pulumi.String("cn-shanghai"),
    		})
    		if err != nil {
    			return err
    		}
    		// Method 1: Use assume_role to operate resources in the target cen account, detail see https://registry.terraform.io/providers/aliyun/alicloud/latest/docs#assume-role
    		_, err = alicloud.NewProvider(ctx, "cenAccount", &alicloud.ProviderArgs{
    			Region: pulumi.String("cn-hangzhou"),
    			AssumeRole: &alicloud.ProviderAssumeRoleArgs{
    				RoleArn: pulumi.String(fmt.Sprintf("acs:ram::%v:role/terraform-example-assume-role", cenUid)),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		defaultNetwork, err := cloudconnect.NewNetwork(ctx, "defaultNetwork", &cloudconnect.NetworkArgs{
    			Description: pulumi.String(name),
    			CidrBlock:   pulumi.String("192.168.0.0/24"),
    			IsDefault:   pulumi.Bool(true),
    		}, pulumi.Provider(alicloud.Default))
    		if err != nil {
    			return err
    		}
    		cen, err := cen.NewInstance(ctx, "cen", &cen.InstanceArgs{
    			CenInstanceName: pulumi.String(name),
    		}, pulumi.Provider(alicloud.Cen_account))
    		if err != nil {
    			return err
    		}
    		_, err = cloudconnect.NewNetworkGrant(ctx, "defaultNetworkGrant", &cloudconnect.NetworkGrantArgs{
    			CcnId:  defaultNetwork.ID(),
    			CenId:  cen.ID(),
    			CenUid: pulumi.Float64(cenUid),
    		}, pulumi.Provider(alicloud.Default))
    		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 name = config.Get("name") ?? "tf-example";
        var cenUid = config.GetDouble("cenUid") ?? 123456789;
        var @default = new AliCloud.Provider("default", new()
        {
            Region = "cn-shanghai",
        });
    
        // Method 1: Use assume_role to operate resources in the target cen account, detail see https://registry.terraform.io/providers/aliyun/alicloud/latest/docs#assume-role
        var cenAccount = new AliCloud.Provider("cenAccount", new()
        {
            Region = "cn-hangzhou",
            AssumeRole = new AliCloud.Inputs.ProviderAssumeRoleArgs
            {
                RoleArn = $"acs:ram::{cenUid}:role/terraform-example-assume-role",
            },
        });
    
        // Method 2: Use the target cen account's access_key, secret_key
        // provider "alicloud" {
        //   region     = "cn-hangzhou"
        //   access_key = "access_key"
        //   secret_key = "secret_key"
        //   alias      = "cen_account"
        // }
        var defaultNetwork = new AliCloud.CloudConnect.Network("defaultNetwork", new()
        {
            Description = name,
            CidrBlock = "192.168.0.0/24",
            IsDefault = true,
        }, new CustomResourceOptions
        {
            Provider = alicloud.Default,
        });
    
        var cen = new AliCloud.Cen.Instance("cen", new()
        {
            CenInstanceName = name,
        }, new CustomResourceOptions
        {
            Provider = alicloud.Cen_account,
        });
    
        var defaultNetworkGrant = new AliCloud.CloudConnect.NetworkGrant("defaultNetworkGrant", new()
        {
            CcnId = defaultNetwork.Id,
            CenId = cen.Id,
            CenUid = cenUid,
        }, new CustomResourceOptions
        {
            Provider = alicloud.Default,
        });
    
    });
    
    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.inputs.ProviderAssumeRoleArgs;
    import com.pulumi.alicloud.cloudconnect.Network;
    import com.pulumi.alicloud.cloudconnect.NetworkArgs;
    import com.pulumi.alicloud.cen.Instance;
    import com.pulumi.alicloud.cen.InstanceArgs;
    import com.pulumi.alicloud.cloudconnect.NetworkGrant;
    import com.pulumi.alicloud.cloudconnect.NetworkGrantArgs;
    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();
            final var name = config.get("name").orElse("tf-example");
            final var cenUid = config.get("cenUid").orElse(123456789);
            var default_ = new Provider("default", ProviderArgs.builder()        
                .region("cn-shanghai")
                .build());
    
            var cenAccount = new Provider("cenAccount", ProviderArgs.builder()        
                .region("cn-hangzhou")
                .assumeRole(ProviderAssumeRoleArgs.builder()
                    .roleArn(String.format("acs:ram::%s:role/terraform-example-assume-role", cenUid))
                    .build())
                .build());
    
            var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()        
                .description(name)
                .cidrBlock("192.168.0.0/24")
                .isDefault(true)
                .build(), CustomResourceOptions.builder()
                    .provider(alicloud.default())
                    .build());
    
            var cen = new Instance("cen", InstanceArgs.builder()        
                .cenInstanceName(name)
                .build(), CustomResourceOptions.builder()
                    .provider(alicloud.cen_account())
                    .build());
    
            var defaultNetworkGrant = new NetworkGrant("defaultNetworkGrant", NetworkGrantArgs.builder()        
                .ccnId(defaultNetwork.id())
                .cenId(cen.id())
                .cenUid(cenUid)
                .build(), CustomResourceOptions.builder()
                    .provider(alicloud.default())
                    .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: tf-example
      cenUid:
        type: number
        default: 1.23456789e+08
    resources:
      default:
        type: pulumi:providers:alicloud
        properties:
          region: cn-shanghai
      # Method 1: Use assume_role to operate resources in the target cen account, detail see https://registry.terraform.io/providers/aliyun/alicloud/latest/docs#assume-role
      cenAccount: # Method 2: Use the target cen account's access_key, secret_key
      # provider "alicloud" {
      #   region     = "cn-hangzhou"
      #   access_key = "access_key"
      #   secret_key = "secret_key"
      #   alias      = "cen_account"
      # }
        type: pulumi:providers:alicloud
        properties:
          region: cn-hangzhou
          assumeRole:
            roleArn: acs:ram::${cenUid}:role/terraform-example-assume-role
      defaultNetwork:
        type: alicloud:cloudconnect:Network
        properties:
          description: ${name}
          cidrBlock: 192.168.0.0/24
          isDefault: true
        options:
          provider: ${alicloud.default}
      cen:
        type: alicloud:cen:Instance
        properties:
          cenInstanceName: ${name}
        options:
          provider: ${alicloud.cen_account}
      defaultNetworkGrant:
        type: alicloud:cloudconnect:NetworkGrant
        properties:
          ccnId: ${defaultNetwork.id}
          cenId: ${cen.id}
          cenUid: ${cenUid}
        options:
          provider: ${alicloud.default}
    

    Create NetworkGrant Resource

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

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

    CcnId string
    The ID of the CCN instance.
    CenId string
    The ID of the CEN instance.
    CenUid string
    The ID of the account to which the CEN instance belongs.
    CcnId string
    The ID of the CCN instance.
    CenId string
    The ID of the CEN instance.
    CenUid string
    The ID of the account to which the CEN instance belongs.
    ccnId String
    The ID of the CCN instance.
    cenId String
    The ID of the CEN instance.
    cenUid String
    The ID of the account to which the CEN instance belongs.
    ccnId string
    The ID of the CCN instance.
    cenId string
    The ID of the CEN instance.
    cenUid string
    The ID of the account to which the CEN instance belongs.
    ccn_id str
    The ID of the CCN instance.
    cen_id str
    The ID of the CEN instance.
    cen_uid str
    The ID of the account to which the CEN instance belongs.
    ccnId String
    The ID of the CCN instance.
    cenId String
    The ID of the CEN instance.
    cenUid String
    The ID of the account to which the CEN instance belongs.

    Outputs

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

    Get an existing NetworkGrant 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?: NetworkGrantState, opts?: CustomResourceOptions): NetworkGrant
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            ccn_id: Optional[str] = None,
            cen_id: Optional[str] = None,
            cen_uid: Optional[str] = None) -> NetworkGrant
    func GetNetworkGrant(ctx *Context, name string, id IDInput, state *NetworkGrantState, opts ...ResourceOption) (*NetworkGrant, error)
    public static NetworkGrant Get(string name, Input<string> id, NetworkGrantState? state, CustomResourceOptions? opts = null)
    public static NetworkGrant get(String name, Output<String> id, NetworkGrantState 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:
    CcnId string
    The ID of the CCN instance.
    CenId string
    The ID of the CEN instance.
    CenUid string
    The ID of the account to which the CEN instance belongs.
    CcnId string
    The ID of the CCN instance.
    CenId string
    The ID of the CEN instance.
    CenUid string
    The ID of the account to which the CEN instance belongs.
    ccnId String
    The ID of the CCN instance.
    cenId String
    The ID of the CEN instance.
    cenUid String
    The ID of the account to which the CEN instance belongs.
    ccnId string
    The ID of the CCN instance.
    cenId string
    The ID of the CEN instance.
    cenUid string
    The ID of the account to which the CEN instance belongs.
    ccn_id str
    The ID of the CCN instance.
    cen_id str
    The ID of the CEN instance.
    cen_uid str
    The ID of the account to which the CEN instance belongs.
    ccnId String
    The ID of the CCN instance.
    cenId String
    The ID of the CEN instance.
    cenUid String
    The ID of the account to which the CEN instance belongs.

    Import

    The Cloud Connect Network Grant can be imported using the instance_id, e.g.

    $ pulumi import alicloud:cloudconnect/networkGrant:NetworkGrant example ccn-abc123456:cen-abc123456
    

    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.51.0 published on Saturday, Mar 23, 2024 by Pulumi