Service Quotas 範例使用 AWS CLI - AWS Command Line Interface

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

Service Quotas 範例使用 AWS CLI

下列程式碼範例說明如何使用「Service Quotas」來執行動作及實作常見案例。 AWS Command Line Interface

Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會告訴您如何呼叫個別服務函數,但您可以在其相關情境和跨服務範例中查看內容中的動作。

Scenarios (案例) 是向您展示如何呼叫相同服務中的多個函數來完成特定任務的程式碼範例。

每個範例都包含一個連結 GitHub,您可以在其中找到如何在內容中設定和執行程式碼的指示。

主題

動作

下列程式碼範例會示範如何使用get-aws-default-service-quota

AWS CLI

說明預設服務配額

下列get-aws-default-service-quota範例會顯示指定配額的詳細資料。

aws service-quotas get-aws-default-service-quota \ --service-code ec2 \ --quota-code L-1216C47A

輸出:

{ "Quota": { "ServiceCode": "ec2", "ServiceName": "Amazon Elastic Compute Cloud (Amazon EC2)", "QuotaArn": "arn:aws:servicequotas:us-east-2::ec2/L-1216C47A", "QuotaCode": "L-1216C47A", "QuotaName": "Running On-Demand Standard (A, C, D, H, I, M, R, T, Z) instances", "Value": 5.0, "Unit": "None", "Adjustable": true, "GlobalQuota": false, "UsageMetric": { "MetricNamespace": "AWS/Usage", "MetricName": "ResourceCount", "MetricDimensions": { "Class": "Standard/OnDemand", "Resource": "vCPU", "Service": "EC2", "Type": "Resource" }, "MetricStatisticRecommendation": "Maximum" } } }

下列程式碼範例會示範如何使用get-requested-service-quota-change

AWS CLI

描述服務配額增加要求

下列get-requested-service-quota-change範例說明指定的配額增加要求。

aws service-quotas get-requested-service-quota-change \ --request-id d187537d15254312a9609aa51bbf7624u7W49tPO

輸出:

{ "RequestedQuota": { "Id": "d187537d15254312a9609aa51bbf7624u7W49tPO", "CaseId": "6780195351", "ServiceCode": "ec2", "ServiceName": "Amazon Elastic Compute Cloud (Amazon EC2)", "QuotaCode": "L-20F13EBD", "QuotaName": "Running Dedicated c5n Hosts", "DesiredValue": 2.0, "Status": "CASE_OPENED", "Created": 1580446904.067, "LastUpdated": 1580446953.265, "Requester": "{\"accountId\":\"123456789012\",\"callerArn\":\"arn:aws:iam::123456789012:root\"}", "QuotaArn": "arn:aws:servicequotas:us-east-2:123456789012:ec2/L-20F13EBD", "GlobalQuota": false, "Unit": "None" } }

下列程式碼範例會示範如何使用get-service-quota

AWS CLI

描述服務配額

下列get-service-quota範例會顯示有關指定配額的詳細資料。

aws service-quotas get-service-quota \ --service-code ec2 \ --quota-code L-1216C47A

輸出:

{ "Quota": { "ServiceCode": "ec2", "ServiceName": "Amazon Elastic Compute Cloud (Amazon EC2)", "QuotaArn": "arn:aws:servicequotas:us-east-2:123456789012:ec2/L-1216C47A", "QuotaCode": "L-1216C47A", "QuotaName": "Running On-Demand Standard (A, C, D, H, I, M, R, T, Z) instances", "Value": 1920.0, "Unit": "None", "Adjustable": true, "GlobalQuota": false, "UsageMetric": { "MetricNamespace": "AWS/Usage", "MetricName": "ResourceCount", "MetricDimensions": { "Class": "Standard/OnDemand", "Resource": "vCPU", "Service": "EC2", "Type": "Resource" }, "MetricStatisticRecommendation": "Maximum" } } }
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考GetServiceQuota中的。

下列程式碼範例會示範如何使用list-aws-default-service-quotas

AWS CLI

若要列出服務的預設配額

下列list-aws-default-service-quotas範例會列出指定服務配額的預設值。

aws service-quotas list-aws-default-service-quotas \ --service-code xray

輸出:

{ "Quotas": [ { "ServiceCode": "xray", "ServiceName": "AWS X-Ray", "QuotaArn": "arn:aws:servicequotas:us-west-2::xray/L-C6B6F05D", "QuotaCode": "L-C6B6F05D", "QuotaName": "Indexed annotations per trace", "Value": 50.0, "Unit": "None", "Adjustable": false, "GlobalQuota": false }, { "ServiceCode": "xray", "ServiceName": "AWS X-Ray", "QuotaArn": "arn:aws:servicequotas:us-west-2::xray/L-D781C0FD", "QuotaCode": "L-D781C0FD", "QuotaName": "Segment document size", "Value": 64.0, "Unit": "Kilobytes", "Adjustable": false, "GlobalQuota": false }, { "ServiceCode": "xray", "ServiceName": "AWS X-Ray", "QuotaArn": "arn:aws:servicequotas:us-west-2::xray/L-998BFF16", "QuotaCode": "L-998BFF16", "QuotaName": "Trace and service graph retention in days", "Value": 30.0, "Unit": "None", "Adjustable": false, "GlobalQuota": false } ] }

下列程式碼範例會示範如何使用list-requested-service-quota-change-history-by-quota

AWS CLI

列出您的配額增加請求

下列list-requested-service-quota-change-history-by-quota範例會列出指定配額的配額增加要求。

aws service-quotas list-requested-service-quota-change-history-by-quota \ --service-code ec2 \ --quota-code L-20F13EBD

輸出:

{ "RequestedQuotas": [ { "Id": "d187537d15254312a9609aa51bbf7624u7W49tPO", "CaseId": "6780195351", "ServiceCode": "ec2", "ServiceName": "Amazon Elastic Compute Cloud (Amazon EC2)", "QuotaCode": "L-20F13EBD", "QuotaName": "Running Dedicated c5n Hosts", "DesiredValue": 2.0, "Status": "CASE_OPENED", "Created": 1580446904.067, "LastUpdated": 1580446953.265, "Requester": "{\"accountId\":\"123456789012\",\"callerArn\":\"arn:aws:iam::123456789012:root\"}", "QuotaArn": "arn:aws:servicequotas:us-east-2:123456789012:ec2/L-20F13EBD", "GlobalQuota": false, "Unit": "None" } ] }

下列程式碼範例會示範如何使用list-requested-service-quota-change-history

AWS CLI

列出您的配額增加請求

下列list-requested-service-quota-change-history範例會列出指定服務的配額增加要求。

aws service-quotas list-requested-service-quota-change-history \ --service-code ec2

輸出:

{ "RequestedQuotas": [ { "Id": "d187537d15254312a9609aa51bbf7624u7W49tPO", "CaseId": "6780195351", "ServiceCode": "ec2", "ServiceName": "Amazon Elastic Compute Cloud (Amazon EC2)", "QuotaCode": "L-20F13EBD", "QuotaName": "Running Dedicated c5n Hosts", "DesiredValue": 2.0, "Status": "CASE_OPENED", "Created": 1580446904.067, "LastUpdated": 1580446953.265, "Requester": "{\"accountId\":\"123456789012\",\"callerArn\":\"arn:aws:iam::123456789012:root\"}", "QuotaArn": "arn:aws:servicequotas:us-east-2:123456789012:ec2/L-20F13EBD", "GlobalQuota": false, "Unit": "None" } ] }

下列程式碼範例會示範如何使用list-service-quotas

AWS CLI

若要列出服務的配額

下列list-service-quotas範例顯示的配額詳細資料 AWS CloudFormation。

aws service-quotas list-service-quotas \ --service-code cloudformation

輸出:

{ "Quotas": [ { "ServiceCode": "cloudformation", "ServiceName": "AWS CloudFormation", "QuotaArn": "arn:aws:servicequotas:us-east-2:123456789012:cloudformation/L-87D14FB7", "QuotaCode": "L-87D14FB7", "QuotaName": "Output count in CloudFormation template", "Value": 60.0, "Unit": "None", "Adjustable": false, "GlobalQuota": false }, { "ServiceCode": "cloudformation", "ServiceName": "AWS CloudFormation", "QuotaArn": "arn:aws:servicequotas:us-east-2:123456789012:cloudformation/L-0485CB21", "QuotaCode": "L-0485CB21", "QuotaName": "Stack count", "Value": 200.0, "Unit": "None", "Adjustable": true, "GlobalQuota": false } ] }

下列程式碼範例會示範如何使用list-services

AWS CLI

列出可用的服務

下列命令會列出「Service Quotas」中可用的服務。

aws service-quotas list-services

輸出:

{ "Services": [ { "ServiceCode": "AWSCloudMap", "ServiceName": "AWS Cloud Map" }, { "ServiceCode": "access-analyzer", "ServiceName": "Access Analyzer" }, { "ServiceCode": "acm", "ServiceName": "AWS Certificate Manager (ACM)" }, ...truncated... { "ServiceCode": "xray", "ServiceName": "AWS X-Ray" } ] }

您可以加入--query參數,將顯示篩選到您感興趣的資訊中。下列範例只會顯示服務代碼。

aws service-quotas list-services \ --query Services[*].ServiceCode

輸出:

[ "AWSCloudMap", "access-analyzer", "acm", "acm-pca", "amplify", "apigateway", "application-autoscaling", ...truncated... "xray" ]
  • 如需 API 詳細資訊,請參閱AWS CLI 命令參考ListServices中的。

下列程式碼範例會示範如何使用request-service-quota-increase

AWS CLI

要求增加服務配額

下列request-service-quota-increase範例要求增加指定的服務配額。

aws service-quotas request-service-quota-increase \ --service-code ec2 \ --quota-code L-20F13EBD \ --desired-value 2

輸出:

{ "RequestedQuota": { "Id": "d187537d15254312a9609aa51bbf7624u7W49tPO", "ServiceCode": "ec2", "ServiceName": "Amazon Elastic Compute Cloud (Amazon EC2)", "QuotaCode": "L-20F13EBD", "QuotaName": "Running Dedicated c5n Hosts", "DesiredValue": 2.0, "Status": "PENDING", "Created": 1580446904.067, "Requester": "{\"accountId\":\"123456789012\",\"callerArn\":\"arn:aws:iam::123456789012:root\"}", "QuotaArn": "arn:aws:servicequotas:us-east-2:123456789012:ec2/L-20F13EBD", "GlobalQuota": false, "Unit": "None" } }