EC2 / Client / describe_regions

describe_regions#

EC2.Client.describe_regions(**kwargs)#

Describes the Regions that are enabled for your account, or all Regions.

For a list of the Regions supported by Amazon EC2, see Amazon EC2 service endpoints.

For information about enabling and disabling Regions for your account, see Specify which Amazon Web Services Regions your account can use in the Amazon Web Services Account Management Reference Guide.

Note

The order of the elements in the response, including those within nested structures, might vary. Applications should not assume the elements appear in a particular order.

See also: AWS API Documentation

Request Syntax

response = client.describe_regions(
    Filters=[
        {
            'Name': 'string',
            'Values': [
                'string',
            ]
        },
    ],
    RegionNames=[
        'string',
    ],
    DryRun=True|False,
    AllRegions=True|False
)
Parameters:
  • Filters (list) –

    The filters.

    • endpoint - The endpoint of the Region (for example, ec2.us-east-1.amazonaws.com).

    • opt-in-status - The opt-in status of the Region ( opt-in-not-required | opted-in | not-opted-in).

    • region-name - The name of the Region (for example, us-east-1).

    • (dict) –

      A filter name and value pair that is used to return a more specific list of results from a describe operation. Filters can be used to match a set of resources by specific criteria, such as tags, attributes, or IDs.

      If you specify multiple filters, the filters are joined with an AND, and the request returns only results that match all of the specified filters.

      • Name (string) –

        The name of the filter. Filter names are case-sensitive.

      • Values (list) –

        The filter values. Filter values are case-sensitive. If you specify multiple values for a filter, the values are joined with an OR, and the request returns all results that match any of the specified values.

        • (string) –

  • RegionNames (list) –

    The names of the Regions. You can specify any Regions, whether they are enabled and disabled for your account.

    • (string) –

  • DryRun (boolean) – Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is DryRunOperation. Otherwise, it is UnauthorizedOperation.

  • AllRegions (boolean) – Indicates whether to display all Regions, including Regions that are disabled for your account.

Return type:

dict

Returns:

Response Syntax

{
    'Regions': [
        {
            'Endpoint': 'string',
            'RegionName': 'string',
            'OptInStatus': 'string'
        },
    ]
}

Response Structure

  • (dict) –

    • Regions (list) –

      Information about the Regions.

      • (dict) –

        Describes a Region.

        • Endpoint (string) –

          The Region service endpoint.

        • RegionName (string) –

          The name of the Region.

        • OptInStatus (string) –

          The Region opt-in status. The possible values are opt-in-not-required, opted-in, and not-opted-in.

Examples

This example describes all the regions that are available to you.

response = client.describe_regions(
)

print(response)

Expected Output:

{
    'Regions': [
        {
            'Endpoint': 'ec2.ap-south-1.amazonaws.com',
            'RegionName': 'ap-south-1',
        },
        {
            'Endpoint': 'ec2.eu-west-1.amazonaws.com',
            'RegionName': 'eu-west-1',
        },
        {
            'Endpoint': 'ec2.ap-southeast-1.amazonaws.com',
            'RegionName': 'ap-southeast-1',
        },
        {
            'Endpoint': 'ec2.ap-southeast-2.amazonaws.com',
            'RegionName': 'ap-southeast-2',
        },
        {
            'Endpoint': 'ec2.eu-central-1.amazonaws.com',
            'RegionName': 'eu-central-1',
        },
        {
            'Endpoint': 'ec2.ap-northeast-2.amazonaws.com',
            'RegionName': 'ap-northeast-2',
        },
        {
            'Endpoint': 'ec2.ap-northeast-1.amazonaws.com',
            'RegionName': 'ap-northeast-1',
        },
        {
            'Endpoint': 'ec2.us-east-1.amazonaws.com',
            'RegionName': 'us-east-1',
        },
        {
            'Endpoint': 'ec2.sa-east-1.amazonaws.com',
            'RegionName': 'sa-east-1',
        },
        {
            'Endpoint': 'ec2.us-west-1.amazonaws.com',
            'RegionName': 'us-west-1',
        },
        {
            'Endpoint': 'ec2.us-west-2.amazonaws.com',
            'RegionName': 'us-west-2',
        },
    ],
    'ResponseMetadata': {
        '...': '...',
    },
}