如何使用 AWS CLI 命令要求、檢視和管理增加服務配額的要求?

3 分的閱讀內容
0

我想使用 AWS Command Line Interface (AWS CLI) 命令要求增加服務配額,然後檢視和管理這些要求。

簡短說明

您可以從 Service Quotas 主控台或使用 AWS CLI 命令來要求、檢視和管理 AWS 服務的配額 (以前稱為限制)。

如需服務配額 AWS CLI 命令的清單,請參閱 AWS CLI 命令參考Service Quotas API 參考

**注意事項:**如果您在執行 AWS CLI 命令時收到錯誤訊息,請確認您使用的是最新版本的 AWS CLI

使用 AWS CLI 管理 Service Quotas 時,請檢閱下列各點:

  • 除非另有說明,否則配額均特定於每個 AWS 區域。請務必使用要求提高配額的區域取代命令中的 --region 參數。
  • 特定時間內的作用中服務配額要求具有數量上限。此外,您無法調整配額值。如需相關資訊,請參閱適用於 Service Quotas 的服務配額
  • API 命令的輸出會以表格形式顯示。如需將輸出變更為以文字或 JSON 格式顯示的相關資訊,請參閱控制 AWS CLI 的命令輸出

解決方案

**注意事項:**Service Quotas 中提供的每一種 AWS 服務都有與其相關聯的服務代碼。在每項服務中,可用的配額類型都有一個配額代碼。您必須在增加服務配額要求中包含這些代碼。

執行 list-services 命令,查看區域的服務代碼清單。使用您的區域取代 eu-west-1

# aws service-quotas list-services --region eu-west-1 --output table

執行 list-service-quotas 命令,查看特定服務和區域的可用配額代碼。在下列範例中,使用您的特定服務和區域取代 --service-code--region。下列範例要求適用於 eu-west-1 區域中 Amazon Elastic Compute Cloud (Amazon EC2) 的服務配額。

# aws service-quotas list-service-quotas --service-code ec2 --region eu-west-1 --query "Quotas[*].{ServiceName:ServiceName,QuotaName:QuotaName,QuotaCode:QuotaCode,Value:Value}" --output table

要求增加服務配額

要求增加服務配額時,請檢查目前的限制,然後增加特定區域中的服務配額。

1.    執行 get-service-quota 命令,檢查您要增加服務的已套用配額值。下列範例要求適用於 eu-west-1 區域的 Amazon EC2 中彈性 IP 地址數量的服務配額。使用您要求的值取代 --service-code--quota-code--region

# aws service-quotas get-service-quota --service-code ec2 --quota-code L-0263D0A3 --region eu-west-1
{
    "Quota": {
        "ServiceCode": "ec2",
        "ServiceName": "Amazon Elastic Compute Cloud (Amazon EC2)",
        "QuotaArn": "arn:aws:servicequotas:eu-west-1:111122223333:ec2/L-0263D0A3",
        "QuotaCode": "L-0263D0A3",
        "QuotaName": "EC2-VPC Elastic IPs",
        "Value": 5.0,
        "Unit": "None",
        "Adjustable": true,
        "GlobalQuota": false
    }
}

2.    使用 request-service-quota-increase 命令來要求增加配額。下列範例要求適用於 eu-west-1 區域的 Amazon EC2 中彈性 IP 地址數量的增加配額。使用您要求的值取代 --service-code--quota-code--region

# aws service-quotas request-service-quota-increase --service-code ec2 --quota-code L-0263D0A3 --region eu-west-1 --desired-value 10
{
    "RequestedQuota": {
        "Id": "d323c5f4eb8d400e96fbf34743b373a7YRHQ2y20",
        "ServiceCode": "ec2",
        "ServiceName": "Amazon Elastic Compute Cloud (Amazon EC2)",
        "QuotaCode": "L-0263D0A3",
        "QuotaName": "EC2-VPC Elastic IPs",
        "DesiredValue": 10.0,
        "Status": "PENDING",
        "Created": 1576431516.421,
        "Requester": "{\"accountId\":\"111122223333\",\"callerArn\":\"arn:aws:iam::111122223333:user/testeksuser\"}",
        "QuotaArn": "arn:aws:servicequotas:eu-west-1:111122223333:ec2/L-0263D0A3",
        "GlobalQuota": false,
        "Unit": "None"
    }

建立要求之後,您可以使用 Service Quotas 主控台追蹤新案例。或者,您可以使用 AWS CLI 來檢查要求狀態。

檢查增加服務配額要求的狀態

執行 get-requested-service-quota-change 命令,檢查待處理要求的狀態。在下列範例中,使用您要求的值取代 --request-id--region。輸出顯示案例 ID 和該要求的狀態

# aws service-quotas get-requested-service-quota-change --request-id "d323c5f4eb8d400e96fbf34743b373a7YRHQ2y20" --region eu-west-1
{
    "RequestedQuota": {
        "Id": "d323c5f4eb8d400e96fbf34743b373a7YRHQ2y20",
        "CaseId": "6672648091",
        "ServiceCode": "ec2",
        "ServiceName": "Amazon Elastic Compute Cloud (Amazon EC2)",
        "QuotaCode": "L-0263D0A3",
        "QuotaName": "EC2-VPC Elastic IPs",
        "DesiredValue": 10.0,
        "Status": "CASE_OPENED",
        "Created": 1576431516.421,
        "LastUpdated": 1576431520.527,
        "Requester": "{\"accountId\":\"111122223333\",\"callerArn\":\"arn:aws:iam::111122223333:user/testeksuser\"}",
        "QuotaArn": "arn:aws:servicequotas:eu-west-1:111122223333:ec2/L-0263D0A3",
        "GlobalQuota": false,
        "Unit": "None"
    }
}

增加配額要求達到 CASE_CLOSED, APPROVEDDENIED 狀態後,您可以檢查要求的詳細資訊。增加服務配額要求的歷史記錄會保留 90 天。如需相關資訊,請參閱 ListRequestedServiceQuotaChangeHistoryByQuota

# aws service-quotas get-requested-service-quota-change --request-id "d323c5f4eb8d400e96fbf34743b373a7YRHQ2y20" --region eu-west-1
{
    "RequestedQuota": {
        "Id": "d323c5f4eb8d400e96fbf34743b373a7YRHQ2y20",

                                          "CaseId": "6672648091",
        "ServiceCode": "ec2",
        "ServiceName": "Amazon Elastic Compute Cloud (Amazon EC2)",

                                    "QuotaCode": "L-0263D0A3",
        "QuotaName": "EC2-VPC Elastic IPs",
        "DesiredValue": 10.0,
        "Status": "CASE_CLOSED",

                                          "Created": 1576431516.421,
        "LastUpdated": 1576432913.04,
        "Requester": "{\"accountId\":\"111122223333\",\"callerArn\":\"arn:aws:iam::111122223333:user/testeksuser\"}",

                                          "QuotaArn": "arn:aws:servicequotas:eu-west-1:111122223333:ec2/L-0263D0A3",
        "GlobalQuota": false,
        "Unit": "None"
    }
}

追蹤多個增加服務配額要求

使用下列 API,您可以檢查在特定區域提出的所有要求,包括所有服務及其配額代碼。您還可以查看針對配額代碼的特定區域提出的所有要求。

範例 1

執行下列命令,檢查在特定區域中提出的所有要求狀態,包括所有服務及其配額代碼:

# aws service-quotas list-requested-service-quota-change-history --region eu-west-1 --query "RequestedQuotas[*].{CaseId:CaseId,Id:Id,QuotaCode:QuotaCode,QuotaName:QuotaName,DesiredValue:DesiredValue,Status:Status}" --output table
-------------------------------------------------------------------------------------------------------------------------------------------------
|                                                    ListRequestedServiceQuotaChangeHistory                                                     |
+------------+---------------+--------------------------------------------+-------------+----------------------------------------+--------------+
|   CaseId   | DesiredValue  |                    Id                      |  QuotaCode  |               QuotaName                |   Status     |
+------------+---------------+--------------------------------------------+-------------+----------------------------------------+--------------+
|  None      |  50.0         |  2f919bc7e8b942e4a4d9e48b70e714547VLCFkjY  |  L-3D9CCA6E |  Tasks per Maintenance Window          |  APPROVED    |
|  6673136551|  10.0         |  cc07103300c74653911cebbd78739dacEToPmn3Z  |  L-DE82EABA |  Running Dedicated g3 Hosts            |  CASE_OPENED |
|  6673112701|  10.0         |  fb78996c9c364915825bab46f2b6a313J8FAIAFm  |  L-8CCBD91B |  Running On-Demand m5d hosts           |  CASE_OPENED |
|  6673109881|  10.0         |  06db5543f3a74dcda55346ca4812a6a0H4jikbty  |  L-24D7D4AD |  Running On-Demand m5n hosts           |  CASE_OPENED |
|  6673043811|  10.0         |  0cf070a56ae742acaf5143f5685d9cc8pGWjHH9l  |  L-0263D0A3 |  EC2-VPC Elastic IPs                   |  CASE_OPENED |
|  6672648091|  10.0         |  d323c5f4eb8d400e96fbf34743b373a7YRHQ2y20  |  L-0263D0A3 |  EC2-VPC Elastic IPs                   |  CASE_CLOSED |
+------------+---------------+--------------------------------------------+-------------+----------------------------------------+--------------+

範例 2

執行下列命令,檢查針對特定配額代碼提出的所有要求狀態:

# aws service-quotas list-requested-service-quota-change-history-by-quota --service-code ec2 --quota-code L-0263D0A3 --region eu-west-1 --query "RequestedQuotas[*].{CaseId:CaseId,Id:Id,QuotaCode:QuotaCode,QuotaName:QuotaName,DesiredValue:DesiredValue,Status:Status}" --output table
--------------------------------------------------------------------------------------------------------------------------------------
|                                            ListRequestedServiceQuotaChangeHistoryByQuota                                           |
+------------+---------------+--------------------------------------------+-------------+----------------------------+---------------+
|   CaseId   | DesiredValue  |                    Id                      |  QuotaCode  |         QuotaName          |    Status     |
+------------+---------------+--------------------------------------------+-------------+----------------------------+---------------+
|  6673043811|  10.0         |  0cf070a56ae742acaf5143f5685d9cc8pGWjHH9l  |  L-0263D0A3 |  EC2-VPC Elastic IPs       |  CASE_OPENED  |
|  6672648091|  10.0         |  d323c5f4eb8d400e96fbf34743b373a7YRHQ2y20  |  L-0263D0A3 |  EC2-VPC Elastic IPs       |  CASE_CLOSED  |
+------------+---------------+--------------------------------------------+-------------+----------------------------+---------------+

相關資訊

如何使用 AWS CLI 管理 Service Quotas 要求對錯誤進行疑難排解? 

什麼是 Service Quotas?

Service Quotas 介紹: 從單一位置集中檢視和管理 AWS 服務的配額

AWS 官方
AWS 官方已更新 1 年前