AdSense

網頁

2024/6/17

AWS CLI 列出帳號所有區域的啟用狀態

使用AWS CLI列出帳號(Account)所有區域(Region)與啟用狀態。


環境:

  • aws-cli/2.15.32


在命令列輸入aws account list-regions即可列出所屬帳號下全部區域的啟用狀態。

% aws account list-regions
{
    "Regions": [
        {
            "RegionName": "af-south-1",
            "RegionOptStatus": "ENABLED"
        },
        {
            "RegionName": "ap-east-1",
            "RegionOptStatus": "ENABLED"
        },
        {
            "RegionName": "ap-northeast-1",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "ap-northeast-2",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "ap-northeast-3",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "ap-south-1",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "ap-south-2",
            "RegionOptStatus": "ENABLED"
        },
        {
            "RegionName": "ap-southeast-1",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "ap-southeast-2",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "ap-southeast-3",
            "RegionOptStatus": "ENABLED"
        },
        {
            "RegionName": "ap-southeast-4",
            "RegionOptStatus": "ENABLED"
        },
        {
            "RegionName": "ca-central-1",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "ca-west-1",
            "RegionOptStatus": "DISABLED"
        },
        {
            "RegionName": "eu-central-1",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "eu-central-2",
            "RegionOptStatus": "ENABLED"
        },
        {
            "RegionName": "eu-north-1",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "eu-south-1",
            "RegionOptStatus": "ENABLED"
        },
        {
            "RegionName": "eu-south-2",
            "RegionOptStatus": "ENABLED"
        },
        {
            "RegionName": "eu-west-1",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "eu-west-2",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "eu-west-3",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "il-central-1",
            "RegionOptStatus": "DISABLED"
        },
        {
            "RegionName": "me-central-1",
            "RegionOptStatus": "ENABLED"
        },
        {
            "RegionName": "me-south-1",
            "RegionOptStatus": "ENABLED"
        },
        {
            "RegionName": "sa-east-1",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "us-east-1",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "us-east-2",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "us-west-1",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        },
        {
            "RegionName": "us-west-2",
            "RegionOptStatus": "ENABLED_BY_DEFAULT"
        }
    ]
}

可加上--region-opt-status-contains [STATUS..]列出包含特定狀態的區域。

例如輸入aws account list-regions --region-opt-status-contains DISABLED列出狀態為DISABLED,即停用的區域。

% aws account list-regions --region-opt-status-contains DISABLED
{
    "Regions": [
        {
            "RegionName": "ca-west-1",
            "RegionOptStatus": "DISABLED"
        },
        {
            "RegionName": "il-central-1",
            "RegionOptStatus": "DISABLED"
        }
    ]
}


沒有留言:

AdSense