1. Packages
  2. AWS Classic
  3. API Docs
  4. getRegions

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

aws.getRegions

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi

    Provides information about AWS Regions. Can be used to filter regions i.e., by Opt-In status or only regions enabled for current account. To get details like endpoint and description of each region the data source can be combined with the aws.getRegion data source.

    Example Usage

    Enabled AWS Regions:

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const current = aws.getRegions({});
    
    import pulumi
    import pulumi_aws as aws
    
    current = aws.get_regions()
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := aws.GetRegions(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var current = Aws.GetRegions.Invoke();
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.AwsFunctions;
    import com.pulumi.aws.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 current = AwsFunctions.getRegions();
    
        }
    }
    
    variables:
      current:
        fn::invoke:
          Function: aws:getRegions
          Arguments: {}
    

    All the regions regardless of the availability

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const current = aws.getRegions({
        allRegions: true,
    });
    
    import pulumi
    import pulumi_aws as aws
    
    current = aws.get_regions(all_regions=True)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := aws.GetRegions(ctx, &aws.GetRegionsArgs{
    			AllRegions: pulumi.BoolRef(true),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var current = Aws.GetRegions.Invoke(new()
        {
            AllRegions = true,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.AwsFunctions;
    import com.pulumi.aws.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 current = AwsFunctions.getRegions(GetRegionsArgs.builder()
                .allRegions(true)
                .build());
    
        }
    }
    
    variables:
      current:
        fn::invoke:
          Function: aws:getRegions
          Arguments:
            allRegions: true
    

    To see regions that are filtered by "not-opted-in", the all_regions argument needs to be set to true or no results will be returned.

    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const current = aws.getRegions({
        allRegions: true,
        filters: [{
            name: "opt-in-status",
            values: ["not-opted-in"],
        }],
    });
    
    import pulumi
    import pulumi_aws as aws
    
    current = aws.get_regions(all_regions=True,
        filters=[{
            "name": "opt-in-status",
            "values": ["not-opted-in"],
        }])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := aws.GetRegions(ctx, &aws.GetRegionsArgs{
    			AllRegions: pulumi.BoolRef(true),
    			Filters: []aws.GetRegionsFilter{
    				{
    					Name: "opt-in-status",
    					Values: []string{
    						"not-opted-in",
    					},
    				},
    			},
    		}, nil)
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var current = Aws.GetRegions.Invoke(new()
        {
            AllRegions = true,
            Filters = new[]
            {
                new Aws.Inputs.GetRegionsFilterInputArgs
                {
                    Name = "opt-in-status",
                    Values = new[]
                    {
                        "not-opted-in",
                    },
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.AwsFunctions;
    import com.pulumi.aws.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 current = AwsFunctions.getRegions(GetRegionsArgs.builder()
                .allRegions(true)
                .filters(GetRegionsFilterArgs.builder()
                    .name("opt-in-status")
                    .values("not-opted-in")
                    .build())
                .build());
    
        }
    }
    
    variables:
      current:
        fn::invoke:
          Function: aws:getRegions
          Arguments:
            allRegions: true
            filters:
              - name: opt-in-status
                values:
                  - not-opted-in
    

    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>
    def get_regions(all_regions: Optional[bool] = None,
                    filters: Optional[Sequence[GetRegionsFilter]] = None,
                    id: Optional[str] = None,
                    opts: Optional[InvokeOptions] = None) -> GetRegionsResult
    def get_regions_output(all_regions: Optional[pulumi.Input[bool]] = None,
                    filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetRegionsFilterArgs]]]] = None,
                    id: Optional[pulumi.Input[str]] = None,
                    opts: Optional[InvokeOptions] = None) -> Output[GetRegionsResult]
    func GetRegions(ctx *Context, args *GetRegionsArgs, opts ...InvokeOption) (*GetRegionsResult, error)
    func GetRegionsOutput(ctx *Context, args *GetRegionsOutputArgs, opts ...InvokeOption) GetRegionsResultOutput

    > 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)
    }
    public static CompletableFuture<GetRegionsResult> getRegions(GetRegionsArgs args, InvokeOptions options)
    // Output-based functions aren't available in Java yet
    
    fn::invoke:
      function: aws:index/getRegions:getRegions
      arguments:
        # arguments dictionary

    The following arguments are supported:

    AllRegions bool
    If true the source will query all regions regardless of availability.
    Filters List<GetRegionsFilter>
    Configuration block(s) to use as filters. Detailed below.
    Id string
    Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
    AllRegions bool
    If true the source will query all regions regardless of availability.
    Filters []GetRegionsFilter
    Configuration block(s) to use as filters. Detailed below.
    Id string
    Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
    allRegions Boolean
    If true the source will query all regions regardless of availability.
    filters List<GetRegionsFilter>
    Configuration block(s) to use as filters. Detailed below.
    id String
    Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
    allRegions boolean
    If true the source will query all regions regardless of availability.
    filters GetRegionsFilter[]
    Configuration block(s) to use as filters. Detailed below.
    id string
    Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
    all_regions bool
    If true the source will query all regions regardless of availability.
    filters Sequence[GetRegionsFilter]
    Configuration block(s) to use as filters. Detailed below.
    id str
    Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
    allRegions Boolean
    If true the source will query all regions regardless of availability.
    filters List<Property Map>
    Configuration block(s) to use as filters. Detailed below.
    id String
    Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).

    getRegions Result

    The following output properties are available:

    Id string
    Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
    Names List<string>
    Names of regions that meets the criteria.
    AllRegions bool
    Filters List<GetRegionsFilter>
    Id string
    Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
    Names []string
    Names of regions that meets the criteria.
    AllRegions bool
    Filters []GetRegionsFilter
    id String
    Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
    names List<String>
    Names of regions that meets the criteria.
    allRegions Boolean
    filters List<GetRegionsFilter>
    id string
    Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
    names string[]
    Names of regions that meets the criteria.
    allRegions boolean
    filters GetRegionsFilter[]
    id str
    Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
    names Sequence[str]
    Names of regions that meets the criteria.
    all_regions bool
    filters Sequence[GetRegionsFilter]
    id String
    Identifier of the current partition (e.g., aws in AWS Commercial, aws-cn in AWS China).
    names List<String>
    Names of regions that meets the criteria.
    allRegions Boolean
    filters List<Property Map>

    Supporting Types

    GetRegionsFilter

    Name string
    Name of the filter field. Valid values can be found in the [describe-regions AWS CLI Reference][1].
    Values List<string>
    Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
    Name string
    Name of the filter field. Valid values can be found in the [describe-regions AWS CLI Reference][1].
    Values []string
    Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
    name String
    Name of the filter field. Valid values can be found in the [describe-regions AWS CLI Reference][1].
    values List<String>
    Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
    name string
    Name of the filter field. Valid values can be found in the [describe-regions AWS CLI Reference][1].
    values string[]
    Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
    name str
    Name of the filter field. Valid values can be found in the [describe-regions AWS CLI Reference][1].
    values Sequence[str]
    Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
    name String
    Name of the filter field. Valid values can be found in the [describe-regions AWS CLI Reference][1].
    values List<String>
    Set of values that are accepted for the given filter field. Results will be selected if any given value matches.

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.42.0 published on Wednesday, Jun 26, 2024 by Pulumi