1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. getRegions
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.getRegions

Explore with Pulumi AI

Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

This data source provides Alibaba Cloud regions.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const currentRegionDs = alicloud.getRegions({
    current: true,
});
export const currentRegionId = currentRegionDs.then(currentRegionDs => currentRegionDs.regions?.[0]?.id);
Copy
import pulumi
import pulumi_alicloud as alicloud

current_region_ds = alicloud.get_regions(current=True)
pulumi.export("currentRegionId", current_region_ds.regions[0].id)
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		currentRegionDs, err := alicloud.GetRegions(ctx, &alicloud.GetRegionsArgs{
			Current: pulumi.BoolRef(true),
		}, nil)
		if err != nil {
			return err
		}
		ctx.Export("currentRegionId", currentRegionDs.Regions[0].Id)
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var currentRegionDs = AliCloud.GetRegions.Invoke(new()
    {
        Current = true,
    });

    return new Dictionary<string, object?>
    {
        ["currentRegionId"] = currentRegionDs.Apply(getRegionsResult => getRegionsResult.Regions[0]?.Id),
    };
});
Copy
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 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 currentRegionDs = AlicloudFunctions.getRegions(GetRegionsArgs.builder()
            .current(true)
            .build());

        ctx.export("currentRegionId", currentRegionDs.applyValue(getRegionsResult -> getRegionsResult.regions()[0].id()));
    }
}
Copy
variables:
  currentRegionDs:
    fn::invoke:
      function: alicloud:getRegions
      arguments:
        current: true
outputs:
  currentRegionId: ${currentRegionDs.regions[0].id}
Copy

Using getRegions

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 getRegions(args: GetRegionsArgs, opts?: InvokeOptions): Promise<GetRegionsResult>
function getRegionsOutput(args: GetRegionsOutputArgs, opts?: InvokeOptions): Output<GetRegionsResult>
Copy
def get_regions(current: Optional[bool] = None,
                name: Optional[str] = None,
                output_file: Optional[str] = None,
                opts: Optional[InvokeOptions] = None) -> GetRegionsResult
def get_regions_output(current: Optional[pulumi.Input[bool]] = None,
                name: Optional[pulumi.Input[str]] = None,
                output_file: Optional[pulumi.Input[str]] = None,
                opts: Optional[InvokeOptions] = None) -> Output[GetRegionsResult]
Copy
func GetRegions(ctx *Context, args *GetRegionsArgs, opts ...InvokeOption) (*GetRegionsResult, error)
func GetRegionsOutput(ctx *Context, args *GetRegionsOutputArgs, opts ...InvokeOption) GetRegionsResultOutput
Copy

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

public static class GetRegions 
{
    public static Task<GetRegionsResult> InvokeAsync(GetRegionsArgs args, InvokeOptions? opts = null)
    public static Output<GetRegionsResult> Invoke(GetRegionsInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetRegionsResult> getRegions(GetRegionsArgs args, InvokeOptions options)
public static Output<GetRegionsResult> getRegions(GetRegionsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: alicloud:index/getRegions:getRegions
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Current bool
Set to true to match only the region configured in the provider.
Name string
The name of the region to select, such as eu-central-1.
OutputFile string

File name where to save data source results (after running pulumi preview).

NOTE: You will get an error if you set current to true and name to a different value from the one you configured in the provider. It is better to either use name or current, but not both at the same time.

Current bool
Set to true to match only the region configured in the provider.
Name string
The name of the region to select, such as eu-central-1.
OutputFile string

File name where to save data source results (after running pulumi preview).

NOTE: You will get an error if you set current to true and name to a different value from the one you configured in the provider. It is better to either use name or current, but not both at the same time.

current Boolean
Set to true to match only the region configured in the provider.
name String
The name of the region to select, such as eu-central-1.
outputFile String

File name where to save data source results (after running pulumi preview).

NOTE: You will get an error if you set current to true and name to a different value from the one you configured in the provider. It is better to either use name or current, but not both at the same time.

current boolean
Set to true to match only the region configured in the provider.
name string
The name of the region to select, such as eu-central-1.
outputFile string

File name where to save data source results (after running pulumi preview).

NOTE: You will get an error if you set current to true and name to a different value from the one you configured in the provider. It is better to either use name or current, but not both at the same time.

current bool
Set to true to match only the region configured in the provider.
name str
The name of the region to select, such as eu-central-1.
output_file str

File name where to save data source results (after running pulumi preview).

NOTE: You will get an error if you set current to true and name to a different value from the one you configured in the provider. It is better to either use name or current, but not both at the same time.

current Boolean
Set to true to match only the region configured in the provider.
name String
The name of the region to select, such as eu-central-1.
outputFile String

File name where to save data source results (after running pulumi preview).

NOTE: You will get an error if you set current to true and name to a different value from the one you configured in the provider. It is better to either use name or current, but not both at the same time.

getRegions Result

The following output properties are available:

Current bool
Id string
The provider-assigned unique ID for this managed resource.
Ids List<string>
A list of region IDs.
Name string
Regions List<Pulumi.AliCloud.Outputs.GetRegionsRegion>
A list of regions. Each element contains the following attributes:
OutputFile string
Current bool
Id string
The provider-assigned unique ID for this managed resource.
Ids []string
A list of region IDs.
Name string
Regions []GetRegionsRegion
A list of regions. Each element contains the following attributes:
OutputFile string
current Boolean
id String
The provider-assigned unique ID for this managed resource.
ids List<String>
A list of region IDs.
name String
regions List<GetRegionsRegion>
A list of regions. Each element contains the following attributes:
outputFile String
current boolean
id string
The provider-assigned unique ID for this managed resource.
ids string[]
A list of region IDs.
name string
regions GetRegionsRegion[]
A list of regions. Each element contains the following attributes:
outputFile string
current bool
id str
The provider-assigned unique ID for this managed resource.
ids Sequence[str]
A list of region IDs.
name str
regions Sequence[GetRegionsRegion]
A list of regions. Each element contains the following attributes:
output_file str
current Boolean
id String
The provider-assigned unique ID for this managed resource.
ids List<String>
A list of region IDs.
name String
regions List<Property Map>
A list of regions. Each element contains the following attributes:
outputFile String

Supporting Types

GetRegionsRegion

Id This property is required. string
ID of the region.
LocalName This property is required. string
Name of the region in the local language.
RegionId This property is required. string
Id This property is required. string
ID of the region.
LocalName This property is required. string
Name of the region in the local language.
RegionId This property is required. string
id This property is required. String
ID of the region.
localName This property is required. String
Name of the region in the local language.
regionId This property is required. String
id This property is required. string
ID of the region.
localName This property is required. string
Name of the region in the local language.
regionId This property is required. string
id This property is required. str
ID of the region.
local_name This property is required. str
Name of the region in the local language.
region_id This property is required. str
id This property is required. String
ID of the region.
localName This property is required. String
Name of the region in the local language.
regionId This property is required. String

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi