1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. expressconnect
  5. RouterVpcAssociation
Alibaba Cloud v3.80.0 published on Wednesday, Jun 11, 2025 by Pulumi

alicloud.expressconnect.RouterVpcAssociation

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.80.0 published on Wednesday, Jun 11, 2025 by Pulumi

    Provides a Express Connect Router Express Connect Router Vpc Association resource. Bind relationship object between leased line gateway and VPC.

    For information about Express Connect Router Express Connect Router Vpc Association and how to use it, see What is Express Connect Router Vpc Association.

    NOTE: Available since v1.224.0.

    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") || "terraform-example";
    const default8qAtD6 = new alicloud.vpc.Network("default8qAtD6", {cidrBlock: "172.16.0.0/16"});
    const defaultM9YxGW = new alicloud.expressconnect.RouterExpressConnectRouter("defaultM9YxGW", {alibabaSideAsn: 65533});
    const current = alicloud.getAccount({});
    const _default = new alicloud.expressconnect.RouterVpcAssociation("default", {
        ecrId: defaultM9YxGW.id,
        allowedPrefixes: [
            "172.16.4.0/24",
            "172.16.3.0/24",
            "172.16.2.0/24",
            "172.16.1.0/24",
        ],
        vpcOwnerId: current.then(current => current.id),
        associationRegionId: "cn-hangzhou",
        vpcId: default8qAtD6.id,
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default8q_at_d6 = alicloud.vpc.Network("default8qAtD6", cidr_block="172.16.0.0/16")
    default_m9_yx_gw = alicloud.expressconnect.RouterExpressConnectRouter("defaultM9YxGW", alibaba_side_asn=65533)
    current = alicloud.get_account()
    default = alicloud.expressconnect.RouterVpcAssociation("default",
        ecr_id=default_m9_yx_gw.id,
        allowed_prefixes=[
            "172.16.4.0/24",
            "172.16.3.0/24",
            "172.16.2.0/24",
            "172.16.1.0/24",
        ],
        vpc_owner_id=current.id,
        association_region_id="cn-hangzhou",
        vpc_id=default8q_at_d6.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/expressconnect"
    	"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, "")
    		name := "terraform-example"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		default8qAtD6, err := vpc.NewNetwork(ctx, "default8qAtD6", &vpc.NetworkArgs{
    			CidrBlock: pulumi.String("172.16.0.0/16"),
    		})
    		if err != nil {
    			return err
    		}
    		defaultM9YxGW, err := expressconnect.NewRouterExpressConnectRouter(ctx, "defaultM9YxGW", &expressconnect.RouterExpressConnectRouterArgs{
    			AlibabaSideAsn: pulumi.Int(65533),
    		})
    		if err != nil {
    			return err
    		}
    		current, err := alicloud.GetAccount(ctx, map[string]interface{}{}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = expressconnect.NewRouterVpcAssociation(ctx, "default", &expressconnect.RouterVpcAssociationArgs{
    			EcrId: defaultM9YxGW.ID(),
    			AllowedPrefixes: pulumi.StringArray{
    				pulumi.String("172.16.4.0/24"),
    				pulumi.String("172.16.3.0/24"),
    				pulumi.String("172.16.2.0/24"),
    				pulumi.String("172.16.1.0/24"),
    			},
    			VpcOwnerId:          pulumi.String(current.Id),
    			AssociationRegionId: pulumi.String("cn-hangzhou"),
    			VpcId:               default8qAtD6.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 name = config.Get("name") ?? "terraform-example";
        var default8qAtD6 = new AliCloud.Vpc.Network("default8qAtD6", new()
        {
            CidrBlock = "172.16.0.0/16",
        });
    
        var defaultM9YxGW = new AliCloud.ExpressConnect.RouterExpressConnectRouter("defaultM9YxGW", new()
        {
            AlibabaSideAsn = 65533,
        });
    
        var current = AliCloud.GetAccount.Invoke();
    
        var @default = new AliCloud.ExpressConnect.RouterVpcAssociation("default", new()
        {
            EcrId = defaultM9YxGW.Id,
            AllowedPrefixes = new[]
            {
                "172.16.4.0/24",
                "172.16.3.0/24",
                "172.16.2.0/24",
                "172.16.1.0/24",
            },
            VpcOwnerId = current.Apply(getAccountResult => getAccountResult.Id),
            AssociationRegionId = "cn-hangzhou",
            VpcId = default8qAtD6.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.vpc.Network;
    import com.pulumi.alicloud.vpc.NetworkArgs;
    import com.pulumi.alicloud.expressconnect.RouterExpressConnectRouter;
    import com.pulumi.alicloud.expressconnect.RouterExpressConnectRouterArgs;
    import com.pulumi.alicloud.AlicloudFunctions;
    import com.pulumi.alicloud.expressconnect.RouterVpcAssociation;
    import com.pulumi.alicloud.expressconnect.RouterVpcAssociationArgs;
    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("terraform-example");
            var default8qAtD6 = new Network("default8qAtD6", NetworkArgs.builder()
                .cidrBlock("172.16.0.0/16")
                .build());
    
            var defaultM9YxGW = new RouterExpressConnectRouter("defaultM9YxGW", RouterExpressConnectRouterArgs.builder()
                .alibabaSideAsn(65533)
                .build());
    
            final var current = AlicloudFunctions.getAccount(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference);
    
            var default_ = new RouterVpcAssociation("default", RouterVpcAssociationArgs.builder()
                .ecrId(defaultM9YxGW.id())
                .allowedPrefixes(            
                    "172.16.4.0/24",
                    "172.16.3.0/24",
                    "172.16.2.0/24",
                    "172.16.1.0/24")
                .vpcOwnerId(current.id())
                .associationRegionId("cn-hangzhou")
                .vpcId(default8qAtD6.id())
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      default8qAtD6:
        type: alicloud:vpc:Network
        properties:
          cidrBlock: 172.16.0.0/16
      defaultM9YxGW:
        type: alicloud:expressconnect:RouterExpressConnectRouter
        properties:
          alibabaSideAsn: '65533'
      default:
        type: alicloud:expressconnect:RouterVpcAssociation
        properties:
          ecrId: ${defaultM9YxGW.id}
          allowedPrefixes:
            - 172.16.4.0/24
            - 172.16.3.0/24
            - 172.16.2.0/24
            - 172.16.1.0/24
          vpcOwnerId: ${current.id}
          associationRegionId: cn-hangzhou
          vpcId: ${default8qAtD6.id}
    variables:
      current:
        fn::invoke:
          function: alicloud:getAccount
          arguments: {}
    

    Create RouterVpcAssociation Resource

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

    Constructor syntax

    new RouterVpcAssociation(name: string, args: RouterVpcAssociationArgs, opts?: CustomResourceOptions);
    @overload
    def RouterVpcAssociation(resource_name: str,
                             args: RouterVpcAssociationArgs,
                             opts: Optional[ResourceOptions] = None)
    
    @overload
    def RouterVpcAssociation(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             association_region_id: Optional[str] = None,
                             ecr_id: Optional[str] = None,
                             vpc_id: Optional[str] = None,
                             allowed_prefixes: Optional[Sequence[str]] = None,
                             vpc_owner_id: Optional[int] = None)
    func NewRouterVpcAssociation(ctx *Context, name string, args RouterVpcAssociationArgs, opts ...ResourceOption) (*RouterVpcAssociation, error)
    public RouterVpcAssociation(string name, RouterVpcAssociationArgs args, CustomResourceOptions? opts = null)
    public RouterVpcAssociation(String name, RouterVpcAssociationArgs args)
    public RouterVpcAssociation(String name, RouterVpcAssociationArgs args, CustomResourceOptions options)
    
    type: alicloud:expressconnect:RouterVpcAssociation
    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 RouterVpcAssociationArgs
    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 RouterVpcAssociationArgs
    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 RouterVpcAssociationArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args RouterVpcAssociationArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args RouterVpcAssociationArgs
    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 routerVpcAssociationResource = new AliCloud.ExpressConnect.RouterVpcAssociation("routerVpcAssociationResource", new()
    {
        AssociationRegionId = "string",
        EcrId = "string",
        VpcId = "string",
        AllowedPrefixes = new[]
        {
            "string",
        },
        VpcOwnerId = 0,
    });
    
    example, err := expressconnect.NewRouterVpcAssociation(ctx, "routerVpcAssociationResource", &expressconnect.RouterVpcAssociationArgs{
    	AssociationRegionId: pulumi.String("string"),
    	EcrId:               pulumi.String("string"),
    	VpcId:               pulumi.String("string"),
    	AllowedPrefixes: pulumi.StringArray{
    		pulumi.String("string"),
    	},
    	VpcOwnerId: pulumi.Int(0),
    })
    
    var routerVpcAssociationResource = new RouterVpcAssociation("routerVpcAssociationResource", RouterVpcAssociationArgs.builder()
        .associationRegionId("string")
        .ecrId("string")
        .vpcId("string")
        .allowedPrefixes("string")
        .vpcOwnerId(0)
        .build());
    
    router_vpc_association_resource = alicloud.expressconnect.RouterVpcAssociation("routerVpcAssociationResource",
        association_region_id="string",
        ecr_id="string",
        vpc_id="string",
        allowed_prefixes=["string"],
        vpc_owner_id=0)
    
    const routerVpcAssociationResource = new alicloud.expressconnect.RouterVpcAssociation("routerVpcAssociationResource", {
        associationRegionId: "string",
        ecrId: "string",
        vpcId: "string",
        allowedPrefixes: ["string"],
        vpcOwnerId: 0,
    });
    
    type: alicloud:expressconnect:RouterVpcAssociation
    properties:
        allowedPrefixes:
            - string
        associationRegionId: string
        ecrId: string
        vpcId: string
        vpcOwnerId: 0
    

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

    AssociationRegionId string
    The region ID of the resource to be associated.
    EcrId string
    The ECR ID.
    VpcId string
    The VPC ID.
    AllowedPrefixes List<string>
    The list of allowed route prefixes.
    VpcOwnerId int

    The ID of the Alibaba Cloud account that owns the VPC.

    NOTE: If you want to connect to a network instance that belongs to a different account, vpc_owner_id is required.

    AssociationRegionId string
    The region ID of the resource to be associated.
    EcrId string
    The ECR ID.
    VpcId string
    The VPC ID.
    AllowedPrefixes []string
    The list of allowed route prefixes.
    VpcOwnerId int

    The ID of the Alibaba Cloud account that owns the VPC.

    NOTE: If you want to connect to a network instance that belongs to a different account, vpc_owner_id is required.

    associationRegionId String
    The region ID of the resource to be associated.
    ecrId String
    The ECR ID.
    vpcId String
    The VPC ID.
    allowedPrefixes List<String>
    The list of allowed route prefixes.
    vpcOwnerId Integer

    The ID of the Alibaba Cloud account that owns the VPC.

    NOTE: If you want to connect to a network instance that belongs to a different account, vpc_owner_id is required.

    associationRegionId string
    The region ID of the resource to be associated.
    ecrId string
    The ECR ID.
    vpcId string
    The VPC ID.
    allowedPrefixes string[]
    The list of allowed route prefixes.
    vpcOwnerId number

    The ID of the Alibaba Cloud account that owns the VPC.

    NOTE: If you want to connect to a network instance that belongs to a different account, vpc_owner_id is required.

    association_region_id str
    The region ID of the resource to be associated.
    ecr_id str
    The ECR ID.
    vpc_id str
    The VPC ID.
    allowed_prefixes Sequence[str]
    The list of allowed route prefixes.
    vpc_owner_id int

    The ID of the Alibaba Cloud account that owns the VPC.

    NOTE: If you want to connect to a network instance that belongs to a different account, vpc_owner_id is required.

    associationRegionId String
    The region ID of the resource to be associated.
    ecrId String
    The ECR ID.
    vpcId String
    The VPC ID.
    allowedPrefixes List<String>
    The list of allowed route prefixes.
    vpcOwnerId Number

    The ID of the Alibaba Cloud account that owns the VPC.

    NOTE: If you want to connect to a network instance that belongs to a different account, vpc_owner_id is required.

    Outputs

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

    AssociationId string
    The ID of the association between the ECR and the VPC.
    CreateTime string
    The time when the association was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    The deployment state of the associated resource.
    AssociationId string
    The ID of the association between the ECR and the VPC.
    CreateTime string
    The time when the association was created.
    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    The deployment state of the associated resource.
    associationId String
    The ID of the association between the ECR and the VPC.
    createTime String
    The time when the association was created.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    The deployment state of the associated resource.
    associationId string
    The ID of the association between the ECR and the VPC.
    createTime string
    The time when the association was created.
    id string
    The provider-assigned unique ID for this managed resource.
    status string
    The deployment state of the associated resource.
    association_id str
    The ID of the association between the ECR and the VPC.
    create_time str
    The time when the association was created.
    id str
    The provider-assigned unique ID for this managed resource.
    status str
    The deployment state of the associated resource.
    associationId String
    The ID of the association between the ECR and the VPC.
    createTime String
    The time when the association was created.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    The deployment state of the associated resource.

    Look up Existing RouterVpcAssociation Resource

    Get an existing RouterVpcAssociation 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?: RouterVpcAssociationState, opts?: CustomResourceOptions): RouterVpcAssociation
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            allowed_prefixes: Optional[Sequence[str]] = None,
            association_id: Optional[str] = None,
            association_region_id: Optional[str] = None,
            create_time: Optional[str] = None,
            ecr_id: Optional[str] = None,
            status: Optional[str] = None,
            vpc_id: Optional[str] = None,
            vpc_owner_id: Optional[int] = None) -> RouterVpcAssociation
    func GetRouterVpcAssociation(ctx *Context, name string, id IDInput, state *RouterVpcAssociationState, opts ...ResourceOption) (*RouterVpcAssociation, error)
    public static RouterVpcAssociation Get(string name, Input<string> id, RouterVpcAssociationState? state, CustomResourceOptions? opts = null)
    public static RouterVpcAssociation get(String name, Output<String> id, RouterVpcAssociationState state, CustomResourceOptions options)
    resources:  _:    type: alicloud:expressconnect:RouterVpcAssociation    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:
    AllowedPrefixes List<string>
    The list of allowed route prefixes.
    AssociationId string
    The ID of the association between the ECR and the VPC.
    AssociationRegionId string
    The region ID of the resource to be associated.
    CreateTime string
    The time when the association was created.
    EcrId string
    The ECR ID.
    Status string
    The deployment state of the associated resource.
    VpcId string
    The VPC ID.
    VpcOwnerId int

    The ID of the Alibaba Cloud account that owns the VPC.

    NOTE: If you want to connect to a network instance that belongs to a different account, vpc_owner_id is required.

    AllowedPrefixes []string
    The list of allowed route prefixes.
    AssociationId string
    The ID of the association between the ECR and the VPC.
    AssociationRegionId string
    The region ID of the resource to be associated.
    CreateTime string
    The time when the association was created.
    EcrId string
    The ECR ID.
    Status string
    The deployment state of the associated resource.
    VpcId string
    The VPC ID.
    VpcOwnerId int

    The ID of the Alibaba Cloud account that owns the VPC.

    NOTE: If you want to connect to a network instance that belongs to a different account, vpc_owner_id is required.

    allowedPrefixes List<String>
    The list of allowed route prefixes.
    associationId String
    The ID of the association between the ECR and the VPC.
    associationRegionId String
    The region ID of the resource to be associated.
    createTime String
    The time when the association was created.
    ecrId String
    The ECR ID.
    status String
    The deployment state of the associated resource.
    vpcId String
    The VPC ID.
    vpcOwnerId Integer

    The ID of the Alibaba Cloud account that owns the VPC.

    NOTE: If you want to connect to a network instance that belongs to a different account, vpc_owner_id is required.

    allowedPrefixes string[]
    The list of allowed route prefixes.
    associationId string
    The ID of the association between the ECR and the VPC.
    associationRegionId string
    The region ID of the resource to be associated.
    createTime string
    The time when the association was created.
    ecrId string
    The ECR ID.
    status string
    The deployment state of the associated resource.
    vpcId string
    The VPC ID.
    vpcOwnerId number

    The ID of the Alibaba Cloud account that owns the VPC.

    NOTE: If you want to connect to a network instance that belongs to a different account, vpc_owner_id is required.

    allowed_prefixes Sequence[str]
    The list of allowed route prefixes.
    association_id str
    The ID of the association between the ECR and the VPC.
    association_region_id str
    The region ID of the resource to be associated.
    create_time str
    The time when the association was created.
    ecr_id str
    The ECR ID.
    status str
    The deployment state of the associated resource.
    vpc_id str
    The VPC ID.
    vpc_owner_id int

    The ID of the Alibaba Cloud account that owns the VPC.

    NOTE: If you want to connect to a network instance that belongs to a different account, vpc_owner_id is required.

    allowedPrefixes List<String>
    The list of allowed route prefixes.
    associationId String
    The ID of the association between the ECR and the VPC.
    associationRegionId String
    The region ID of the resource to be associated.
    createTime String
    The time when the association was created.
    ecrId String
    The ECR ID.
    status String
    The deployment state of the associated resource.
    vpcId String
    The VPC ID.
    vpcOwnerId Number

    The ID of the Alibaba Cloud account that owns the VPC.

    NOTE: If you want to connect to a network instance that belongs to a different account, vpc_owner_id is required.

    Import

    Express Connect Router Express Connect Router Vpc Association can be imported using the id, e.g.

    $ pulumi import alicloud:expressconnect/routerVpcAssociation:RouterVpcAssociation example <ecr_id>:<association_id>:<vpc_id>
    

    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.80.0 published on Wednesday, Jun 11, 2025 by Pulumi