本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用 Service Quotas範例 AWS CLI
下列程式碼範例示範如何搭配 AWS Command Line Interface Service Quotas 使用 來執行動作和實作常見案例。
Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會示範如何呼叫個別服務函數,但您可以在相關案例中查看內容中的動作。
每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。
主題
動作
下列程式碼範例示範如何使用 get-aws-default-service-quota
。
- AWS CLI
-
描述預設服務配額
下列
get-aws-default-service-quota
範例顯示指定配額的詳細資訊。aws service-quotas get-aws-default-service-quota \ --service-code
ec2
\ --quota-codeL-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" } } }
-
如需API詳細資訊,請參閱 命令參考 GetAwsDefaultServiceQuota
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 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" } }
-
如需API詳細資訊,請參閱 命令參考 GetRequestedServiceQuotaChange
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 get-service-quota
。
- AWS CLI
-
描述服務配額
下列
get-service-quota
範例顯示指定配額的詳細資訊。aws service-quotas get-service-quota \ --service-code
ec2
\ --quota-codeL-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詳細資訊,請參閱 命令參考 GetServiceQuota
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 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 } ] }
-
如需API詳細資訊,請參閱 命令參考 ListAwsDefaultServiceQuotas
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 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-codeL-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" } ] }
-
如需API詳細資訊,請參閱 命令參考 ListRequestedServiceQuotaChangeHistoryByQuota
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 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" } ] }
-
如需API詳細資訊,請參閱 命令參考 ListRequestedServiceQuotaChangeHistory
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 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 } ] }
-
如需API詳細資訊,請參閱 命令參考 ListServiceQuotas
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 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詳細資訊,請參閱 命令參考 ListServices
中的 。 AWS CLI
-
下列程式碼範例示範如何使用 request-service-quota-increase
。
- AWS CLI
-
請求增加服務配額
下列
request-service-quota-increase
範例會請求增加指定的服務配額。aws service-quotas request-service-quota-increase \ --service-code
ec2
\ --quota-codeL-20F13EBD
\ --desired-value2
輸出:
{ "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" } }
-
如需API詳細資訊,請參閱 命令參考 RequestServiceQuotaIncrease
中的 。 AWS CLI
-