alicloud logo
Alibaba Cloud v3.34.0, Mar 17 23

alicloud.vpc.getSwitches

This data source provides a list of VSwitches owned by an Alibaba Cloud account.

Example Usage

using System.Collections.Generic;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var config = new Config();
    var name = config.Get("name") ?? "vswitchDatasourceName";
    var defaultZones = AliCloud.GetZones.Invoke();

    var vpc = new AliCloud.Vpc.Network("vpc", new()
    {
        CidrBlock = "172.16.0.0/16",
        VpcName = name,
    });

    var vswitch = new AliCloud.Vpc.Switch("vswitch", new()
    {
        AvailabilityZone = defaultZones.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
        CidrBlock = "172.16.0.0/24",
        VpcId = vpc.Id,
        VswitchName = name,
    });

    var defaultSwitches = AliCloud.Vpc.GetSwitches.Invoke(new()
    {
        NameRegex = vswitch.VswitchName,
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
	"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 := "vswitchDatasourceName"
		if param := cfg.Get("name"); param != "" {
			name = param
		}
		defaultZones, err := alicloud.GetZones(ctx, nil, nil)
		if err != nil {
			return err
		}
		vpc, err := vpc.NewNetwork(ctx, "vpc", &vpc.NetworkArgs{
			CidrBlock: pulumi.String("172.16.0.0/16"),
			VpcName:   pulumi.String(name),
		})
		if err != nil {
			return err
		}
		vswitch, err := vpc.NewSwitch(ctx, "vswitch", &vpc.SwitchArgs{
			AvailabilityZone: *pulumi.String(defaultZones.Zones[0].Id),
			CidrBlock:        pulumi.String("172.16.0.0/24"),
			VpcId:            vpc.ID(),
			VswitchName:      pulumi.String(name),
		})
		if err != nil {
			return err
		}
		_ = vpc.GetSwitchesOutput(ctx, vpc.GetSwitchesOutputArgs{
			NameRegex: vswitch.VswitchName,
		}, nil)
		return nil
	})
}
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.GetZonesArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.vpc.VpcFunctions;
import com.pulumi.alicloud.vpc.inputs.GetSwitchesArgs;
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("vswitchDatasourceName");
        final var defaultZones = AlicloudFunctions.getZones();

        var vpc = new Network("vpc", NetworkArgs.builder()        
            .cidrBlock("172.16.0.0/16")
            .vpcName(name)
            .build());

        var vswitch = new Switch("vswitch", SwitchArgs.builder()        
            .availabilityZone(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
            .cidrBlock("172.16.0.0/24")
            .vpcId(vpc.id())
            .vswitchName(name)
            .build());

        final var defaultSwitches = VpcFunctions.getSwitches(GetSwitchesArgs.builder()
            .nameRegex(vswitch.vswitchName())
            .build());

    }
}
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "vswitchDatasourceName"
default_zones = alicloud.get_zones()
vpc = alicloud.vpc.Network("vpc",
    cidr_block="172.16.0.0/16",
    vpc_name=name)
vswitch = alicloud.vpc.Switch("vswitch",
    availability_zone=default_zones.zones[0].id,
    cidr_block="172.16.0.0/24",
    vpc_id=vpc.id,
    vswitch_name=name)
default_switches = alicloud.vpc.get_switches_output(name_regex=vswitch.vswitch_name)
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const config = new pulumi.Config();
const name = config.get("name") || "vswitchDatasourceName";
const defaultZones = alicloud.getZones({});
const vpc = new alicloud.vpc.Network("vpc", {
    cidrBlock: "172.16.0.0/16",
    vpcName: name,
});
const vswitch = new alicloud.vpc.Switch("vswitch", {
    availabilityZone: defaultZones.then(defaultZones => defaultZones.zones?.[0]?.id),
    cidrBlock: "172.16.0.0/24",
    vpcId: vpc.id,
    vswitchName: name,
});
const defaultSwitches = alicloud.vpc.getSwitchesOutput({
    nameRegex: vswitch.vswitchName,
});
configuration:
  name:
    type: string
    default: vswitchDatasourceName
resources:
  vpc:
    type: alicloud:vpc:Network
    properties:
      cidrBlock: 172.16.0.0/16
      vpcName: ${name}
  vswitch:
    type: alicloud:vpc:Switch
    properties:
      availabilityZone: ${defaultZones.zones[0].id}
      cidrBlock: 172.16.0.0/24
      vpcId: ${vpc.id}
      vswitchName: ${name}
variables:
  defaultZones:
    fn::invoke:
      Function: alicloud:getZones
      Arguments: {}
  defaultSwitches:
    fn::invoke:
      Function: alicloud:vpc:getSwitches
      Arguments:
        nameRegex: ${vswitch.vswitchName}

Using getSwitches

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getSwitches(args: GetSwitchesArgs, opts?: InvokeOptions): Promise<GetSwitchesResult>
function getSwitchesOutput(args: GetSwitchesOutputArgs, opts?: InvokeOptions): Output<GetSwitchesResult>
def get_switches(cidr_block: Optional[str] = None,
                 dry_run: Optional[bool] = None,
                 ids: Optional[Sequence[str]] = None,
                 is_default: Optional[bool] = None,
                 name_regex: Optional[str] = None,
                 output_file: Optional[str] = None,
                 resource_group_id: Optional[str] = None,
                 route_table_id: Optional[str] = None,
                 status: Optional[str] = None,
                 tags: Optional[Mapping[str, Any]] = None,
                 vpc_id: Optional[str] = None,
                 vswitch_name: Optional[str] = None,
                 vswitch_owner_id: Optional[int] = None,
                 zone_id: Optional[str] = None,
                 opts: Optional[InvokeOptions] = None) -> GetSwitchesResult
def get_switches_output(cidr_block: Optional[pulumi.Input[str]] = None,
                 dry_run: Optional[pulumi.Input[bool]] = None,
                 ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                 is_default: Optional[pulumi.Input[bool]] = None,
                 name_regex: Optional[pulumi.Input[str]] = None,
                 output_file: Optional[pulumi.Input[str]] = None,
                 resource_group_id: Optional[pulumi.Input[str]] = None,
                 route_table_id: Optional[pulumi.Input[str]] = None,
                 status: Optional[pulumi.Input[str]] = None,
                 tags: Optional[pulumi.Input[Mapping[str, Any]]] = None,
                 vpc_id: Optional[pulumi.Input[str]] = None,
                 vswitch_name: Optional[pulumi.Input[str]] = None,
                 vswitch_owner_id: Optional[pulumi.Input[int]] = None,
                 zone_id: Optional[pulumi.Input[str]] = None,
                 opts: Optional[InvokeOptions] = None) -> Output[GetSwitchesResult]
func GetSwitches(ctx *Context, args *GetSwitchesArgs, opts ...InvokeOption) (*GetSwitchesResult, error)
func GetSwitchesOutput(ctx *Context, args *GetSwitchesOutputArgs, opts ...InvokeOption) GetSwitchesResultOutput

> Note: This function is named GetSwitches in the Go SDK.

public static class GetSwitches 
{
    public static Task<GetSwitchesResult> InvokeAsync(GetSwitchesArgs args, InvokeOptions? opts = null)
    public static Output<GetSwitchesResult> Invoke(GetSwitchesInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetSwitchesResult> getSwitches(GetSwitchesArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
  function: alicloud:vpc/getSwitches:getSwitches
  arguments:
    # arguments dictionary

The following arguments are supported:

CidrBlock string

Filter results by a specific CIDR block. For example: "172.16.0.0/12".

DryRun bool

Specifies whether to precheck this request only. Valid values: true and false.

Ids List<string>

A list of VSwitch IDs.

IsDefault bool

Indicate whether the VSwitch is created by the system.

NameRegex string

A regex string to filter results by name.

OutputFile string
ResourceGroupId string

The Id of resource group which VSWitch belongs.

RouteTableId string

The route table ID of the VSwitch.

Status string

The status of the VSwitch. Valid values: Available and Pending.

Tags Dictionary<string, object>

A mapping of tags to assign to the resource.

VpcId string

ID of the VPC that owns the VSwitch.

VswitchName string

The name of the VSwitch.

VswitchOwnerId int

The VSwitch owner id.

ZoneId string

The availability zone of the VSwitch.

CidrBlock string

Filter results by a specific CIDR block. For example: "172.16.0.0/12".

DryRun bool

Specifies whether to precheck this request only. Valid values: true and false.

Ids []string

A list of VSwitch IDs.

IsDefault bool

Indicate whether the VSwitch is created by the system.

NameRegex string

A regex string to filter results by name.

OutputFile string
ResourceGroupId string

The Id of resource group which VSWitch belongs.

RouteTableId string

The route table ID of the VSwitch.

Status string

The status of the VSwitch. Valid values: Available and Pending.

Tags map[string]interface{}

A mapping of tags to assign to the resource.

VpcId string

ID of the VPC that owns the VSwitch.

VswitchName string

The name of the VSwitch.

VswitchOwnerId int

The VSwitch owner id.

ZoneId string

The availability zone of the VSwitch.

cidrBlock String

Filter results by a specific CIDR block. For example: "172.16.0.0/12".

dryRun Boolean

Specifies whether to precheck this request only. Valid values: true and false.

ids List<String>

A list of VSwitch IDs.

isDefault Boolean

Indicate whether the VSwitch is created by the system.

nameRegex String

A regex string to filter results by name.

outputFile String
resourceGroupId String

The Id of resource group which VSWitch belongs.

routeTableId String

The route table ID of the VSwitch.

status String

The status of the VSwitch. Valid values: Available and Pending.

tags Map<String,Object>

A mapping of tags to assign to the resource.

vpcId String

ID of the VPC that owns the VSwitch.

vswitchName String

The name of the VSwitch.

vswitchOwnerId Integer

The VSwitch owner id.

zoneId String

The availability zone of the VSwitch.

cidrBlock string

Filter results by a specific CIDR block. For example: "172.16.0.0/12".

dryRun boolean

Specifies whether to precheck this request only. Valid values: true and false.

ids string[]

A list of VSwitch IDs.

isDefault boolean

Indicate whether the VSwitch is created by the system.

nameRegex string

A regex string to filter results by name.

outputFile string
resourceGroupId string

The Id of resource group which VSWitch belongs.

routeTableId string

The route table ID of the VSwitch.

status string

The status of the VSwitch. Valid values: Available and Pending.

tags {[key: string]: any}

A mapping of tags to assign to the resource.

vpcId string

ID of the VPC that owns the VSwitch.

vswitchName string

The name of the VSwitch.

vswitchOwnerId number

The VSwitch owner id.

zoneId string

The availability zone of the VSwitch.

cidr_block str

Filter results by a specific CIDR block. For example: "172.16.0.0/12".

dry_run bool

Specifies whether to precheck this request only. Valid values: true and false.

ids Sequence[str]

A list of VSwitch IDs.

is_default bool

Indicate whether the VSwitch is created by the system.

name_regex str

A regex string to filter results by name.

output_file str
resource_group_id str

The Id of resource group which VSWitch belongs.

route_table_id str

The route table ID of the VSwitch.

status str

The status of the VSwitch. Valid values: Available and Pending.

tags Mapping[str, Any]

A mapping of tags to assign to the resource.

vpc_id str

ID of the VPC that owns the VSwitch.

vswitch_name str

The name of the VSwitch.

vswitch_owner_id int

The VSwitch owner id.

zone_id str

The availability zone of the VSwitch.

cidrBlock String

Filter results by a specific CIDR block. For example: "172.16.0.0/12".

dryRun Boolean

Specifies whether to precheck this request only. Valid values: true and false.

ids List<String>

A list of VSwitch IDs.

isDefault Boolean

Indicate whether the VSwitch is created by the system.

nameRegex String

A regex string to filter results by name.

outputFile String
resourceGroupId String

The Id of resource group which VSWitch belongs.

routeTableId String

The route table ID of the VSwitch.

status String

The status of the VSwitch. Valid values: Available and Pending.

tags Map<Any>

A mapping of tags to assign to the resource.

vpcId String

ID of the VPC that owns the VSwitch.

vswitchName String

The name of the VSwitch.

vswitchOwnerId Number

The VSwitch owner id.

zoneId String

The availability zone of the VSwitch.

getSwitches Result

The following output properties are available:

Id string

The provider-assigned unique ID for this managed resource.

Ids List<string>

A list of VSwitch IDs.

Names List<string>

A list of VSwitch names.

Vswitches List<Pulumi.AliCloud.Vpc.Outputs.GetSwitchesVswitch>

A list of VSwitches. Each element contains the following attributes:

CidrBlock string

CIDR block of the VSwitch.

DryRun bool
IsDefault bool

Whether the VSwitch is the default one in the region.

NameRegex string
OutputFile string
ResourceGroupId string

The resource group ID of the VSwitch.

RouteTableId string

The route table ID of the VSwitch.

Status string

The status of the VSwitch.

Tags Dictionary<string, object>

The Tags of the VSwitch.

VpcId string

ID of the VPC that owns the VSwitch.

VswitchName string

Name of the VSwitch.

VswitchOwnerId int
ZoneId string

ID of the availability zone where the VSwitch is located.

Id string

The provider-assigned unique ID for this managed resource.

Ids []string

A list of VSwitch IDs.

Names []string

A list of VSwitch names.

Vswitches []GetSwitchesVswitch

A list of VSwitches. Each element contains the following attributes:

CidrBlock string

CIDR block of the VSwitch.

DryRun bool
IsDefault bool

Whether the VSwitch is the default one in the region.

NameRegex string
OutputFile string
ResourceGroupId string

The resource group ID of the VSwitch.

RouteTableId string

The route table ID of the VSwitch.

Status string

The status of the VSwitch.

Tags map[string]interface{}

The Tags of the VSwitch.

VpcId string

ID of the VPC that owns the VSwitch.

VswitchName string

Name of the VSwitch.

VswitchOwnerId int
ZoneId string

ID of the availability zone where the VSwitch is located.

id String

The provider-assigned unique ID for this managed resource.

ids List<String>

A list of VSwitch IDs.

names List<String>

A list of VSwitch names.

vswitches List<GetSwitchesVswitch>

A list of VSwitches. Each element contains the following attributes:

cidrBlock String

CIDR block of the VSwitch.

dryRun Boolean
isDefault Boolean

Whether the VSwitch is the default one in the region.

nameRegex String
outputFile String
resourceGroupId String

The resource group ID of the VSwitch.

routeTableId String

The route table ID of the VSwitch.

status String

The status of the VSwitch.

tags Map<String,Object>

The Tags of the VSwitch.

vpcId String

ID of the VPC that owns the VSwitch.

vswitchName String

Name of the VSwitch.

vswitchOwnerId Integer
zoneId String

ID of the availability zone where the VSwitch is located.

id string

The provider-assigned unique ID for this managed resource.

ids string[]

A list of VSwitch IDs.

names string[]

A list of VSwitch names.

vswitches GetSwitchesVswitch[]

A list of VSwitches. Each element contains the following attributes:

cidrBlock string

CIDR block of the VSwitch.

dryRun boolean
isDefault boolean

Whether the VSwitch is the default one in the region.

nameRegex string
outputFile string
resourceGroupId string

The resource group ID of the VSwitch.

routeTableId string

The route table ID of the VSwitch.

status string

The status of the VSwitch.

tags {[key: string]: any}

The Tags of the VSwitch.

vpcId string

ID of the VPC that owns the VSwitch.

vswitchName string

Name of the VSwitch.

vswitchOwnerId number
zoneId string

ID of the availability zone where the VSwitch is located.

id str

The provider-assigned unique ID for this managed resource.

ids Sequence[str]

A list of VSwitch IDs.

names Sequence[str]

A list of VSwitch names.

vswitches Sequence[GetSwitchesVswitch]

A list of VSwitches. Each element contains the following attributes:

cidr_block str

CIDR block of the VSwitch.

dry_run bool
is_default bool

Whether the VSwitch is the default one in the region.

name_regex str
output_file str
resource_group_id str

The resource group ID of the VSwitch.

route_table_id str

The route table ID of the VSwitch.

status str

The status of the VSwitch.

tags Mapping[str, Any]

The Tags of the VSwitch.

vpc_id str

ID of the VPC that owns the VSwitch.

vswitch_name str

Name of the VSwitch.

vswitch_owner_id int
zone_id str

ID of the availability zone where the VSwitch is located.

id String

The provider-assigned unique ID for this managed resource.

ids List<String>

A list of VSwitch IDs.

names List<String>

A list of VSwitch names.

vswitches List<Property Map>

A list of VSwitches. Each element contains the following attributes:

cidrBlock String

CIDR block of the VSwitch.

dryRun Boolean
isDefault Boolean

Whether the VSwitch is the default one in the region.

nameRegex String
outputFile String
resourceGroupId String

The resource group ID of the VSwitch.

routeTableId String

The route table ID of the VSwitch.

status String

The status of the VSwitch.

tags Map<Any>

The Tags of the VSwitch.

vpcId String

ID of the VPC that owns the VSwitch.

vswitchName String

Name of the VSwitch.

vswitchOwnerId Number
zoneId String

ID of the availability zone where the VSwitch is located.

Supporting Types

GetSwitchesVswitch

AvailableIpAddressCount int

The available ip address count of the VSwitch.

CidrBlock string

Filter results by a specific CIDR block. For example: "172.16.0.0/12".

CreationTime string

Time of creation.

Description string

Description of the VSwitch.

Id string

ID of the VSwitch.

Ipv6CidrBlock string

The IPv6 CIDR block of the switch.

IsDefault bool

Indicate whether the VSwitch is created by the system.

Name string

Name of the VSwitch.

ResourceGroupId string

The Id of resource group which VSWitch belongs.

RouteTableId string

The route table ID of the VSwitch.

Status string

The status of the VSwitch. Valid values: Available and Pending.

Tags Dictionary<string, object>

A mapping of tags to assign to the resource.

VpcId string

ID of the VPC that owns the VSwitch.

VswitchId string

ID of the VSwitch.

VswitchName string

The name of the VSwitch.

ZoneId string

The availability zone of the VSwitch.

AvailableIpAddressCount int

The available ip address count of the VSwitch.

CidrBlock string

Filter results by a specific CIDR block. For example: "172.16.0.0/12".

CreationTime string

Time of creation.

Description string

Description of the VSwitch.

Id string

ID of the VSwitch.

Ipv6CidrBlock string

The IPv6 CIDR block of the switch.

IsDefault bool

Indicate whether the VSwitch is created by the system.

Name string

Name of the VSwitch.

ResourceGroupId string

The Id of resource group which VSWitch belongs.

RouteTableId string

The route table ID of the VSwitch.

Status string

The status of the VSwitch. Valid values: Available and Pending.

Tags map[string]interface{}

A mapping of tags to assign to the resource.

VpcId string

ID of the VPC that owns the VSwitch.

VswitchId string

ID of the VSwitch.

VswitchName string

The name of the VSwitch.

ZoneId string

The availability zone of the VSwitch.

availableIpAddressCount Integer

The available ip address count of the VSwitch.

cidrBlock String

Filter results by a specific CIDR block. For example: "172.16.0.0/12".

creationTime String

Time of creation.

description String

Description of the VSwitch.

id String

ID of the VSwitch.

ipv6CidrBlock String

The IPv6 CIDR block of the switch.

isDefault Boolean

Indicate whether the VSwitch is created by the system.

name String

Name of the VSwitch.

resourceGroupId String

The Id of resource group which VSWitch belongs.

routeTableId String

The route table ID of the VSwitch.

status String

The status of the VSwitch. Valid values: Available and Pending.

tags Map<String,Object>

A mapping of tags to assign to the resource.

vpcId String

ID of the VPC that owns the VSwitch.

vswitchId String

ID of the VSwitch.

vswitchName String

The name of the VSwitch.

zoneId String

The availability zone of the VSwitch.

availableIpAddressCount number

The available ip address count of the VSwitch.

cidrBlock string

Filter results by a specific CIDR block. For example: "172.16.0.0/12".

creationTime string

Time of creation.

description string

Description of the VSwitch.

id string

ID of the VSwitch.

ipv6CidrBlock string

The IPv6 CIDR block of the switch.

isDefault boolean

Indicate whether the VSwitch is created by the system.

name string

Name of the VSwitch.

resourceGroupId string

The Id of resource group which VSWitch belongs.

routeTableId string

The route table ID of the VSwitch.

status string

The status of the VSwitch. Valid values: Available and Pending.

tags {[key: string]: any}

A mapping of tags to assign to the resource.

vpcId string

ID of the VPC that owns the VSwitch.

vswitchId string

ID of the VSwitch.

vswitchName string

The name of the VSwitch.

zoneId string

The availability zone of the VSwitch.

available_ip_address_count int

The available ip address count of the VSwitch.

cidr_block str

Filter results by a specific CIDR block. For example: "172.16.0.0/12".

creation_time str

Time of creation.

description str

Description of the VSwitch.

id str

ID of the VSwitch.

ipv6_cidr_block str

The IPv6 CIDR block of the switch.

is_default bool

Indicate whether the VSwitch is created by the system.

name str

Name of the VSwitch.

resource_group_id str

The Id of resource group which VSWitch belongs.

route_table_id str

The route table ID of the VSwitch.

status str

The status of the VSwitch. Valid values: Available and Pending.

tags Mapping[str, Any]

A mapping of tags to assign to the resource.

vpc_id str

ID of the VPC that owns the VSwitch.

vswitch_id str

ID of the VSwitch.

vswitch_name str

The name of the VSwitch.

zone_id str

The availability zone of the VSwitch.

availableIpAddressCount Number

The available ip address count of the VSwitch.

cidrBlock String

Filter results by a specific CIDR block. For example: "172.16.0.0/12".

creationTime String

Time of creation.

description String

Description of the VSwitch.

id String

ID of the VSwitch.

ipv6CidrBlock String

The IPv6 CIDR block of the switch.

isDefault Boolean

Indicate whether the VSwitch is created by the system.

name String

Name of the VSwitch.

resourceGroupId String

The Id of resource group which VSWitch belongs.

routeTableId String

The route table ID of the VSwitch.

status String

The status of the VSwitch. Valid values: Available and Pending.

tags Map<Any>

A mapping of tags to assign to the resource.

vpcId String

ID of the VPC that owns the VSwitch.

vswitchId String

ID of the VSwitch.

vswitchName String

The name of the VSwitch.

zoneId String

The availability zone of the VSwitch.

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes

This Pulumi package is based on the alicloud Terraform Provider.