$npx -y skills add aws-samples/sample-devops-agent-tools --skill service-quota-checkUse this skill during any incident investigation, capacity planning, or
| 1 | # Service Quota Check |
| 2 | |
| 3 | Use this skill to check AWS service quota utilization during investigations and before |
| 4 | provisioning new resources. It determines whether a quota is nearing its limit (85%+ |
| 5 | utilization) and takes action: requesting a quota increase via the Service Quotas API |
| 6 | when possible, or recommending a support case when programmatic increases are not supported. |
| 7 | |
| 8 | ## When to Use This Skill |
| 9 | |
| 10 | - An error message indicates throttling or limit exceeded (e.g., `ThrottlingException`, |
| 11 | `TooManyRequestsException`, `LimitExceededException`, `ResourceLimitExceeded`). |
| 12 | - A resource creation or scaling operation fails with capacity errors. |
| 13 | - An investigation recommendation involves provisioning additional AWS resources |
| 14 | (e.g., adding EC2 instances, creating VPCs, adding NAT Gateways, launching RDS instances). |
| 15 | - Capacity planning or pre-launch readiness checks. |
| 16 | - Proactive monitoring of quota utilization across services. |
| 17 | |
| 18 | ## Prerequisites |
| 19 | |
| 20 | - The agent must have permissions to call Service Quotas APIs: |
| 21 | - `servicequotas:ListServices` |
| 22 | - `servicequotas:ListServiceQuotas` |
| 23 | - `servicequotas:GetServiceQuota` |
| 24 | - `servicequotas:RequestServiceQuotaIncrease` |
| 25 | - `servicequotas:ListRequestedServiceQuotaChangeHistory` |
| 26 | - `servicequotas:CreateSupportCase` |
| 27 | - For utilization data via CloudWatch, the agent needs: |
| 28 | - `cloudwatch:GetMetricData` |
| 29 | - `cloudwatch:GetMetricStatistics` |
| 30 | - Service Quotas is a regional service. Quotas must be checked in the region |
| 31 | where resources are deployed. |
| 32 | |
| 33 | --- |
| 34 | |
| 35 | ## Step 1: Identify the Service and Quota Context |
| 36 | |
| 37 | Determine which service and quota to check based on the investigation context: |
| 38 | |
| 39 | 1. **From error messages** — extract the service name and specific limit mentioned. |
| 40 | 2. **From recommendations** — if the recommendation is to provision resources, identify |
| 41 | the service (e.g., EC2, VPC, RDS, Lambda, ELB) and the resource type. |
| 42 | 3. **From alarms** — if a CloudWatch alarm indicates capacity pressure, identify the |
| 43 | underlying service. |
| 44 | |
| 45 | ### Common service codes |
| 46 | |
| 47 | | AWS Service | Service Code | |
| 48 | |-------------|-------------| |
| 49 | | Amazon EC2 | `ec2` | |
| 50 | | Amazon VPC | `vpc` | |
| 51 | | Elastic Load Balancing | `elasticloadbalancing` | |
| 52 | | Amazon RDS | `rds` | |
| 53 | | AWS Lambda | `lambda` | |
| 54 | | Amazon ECS | `ecs` | |
| 55 | | Amazon EKS | `eks` | |
| 56 | | Amazon S3 | `s3` | |
| 57 | | Amazon DynamoDB | `dynamodb` | |
| 58 | | AWS Fargate | `fargate` | |
| 59 | | Amazon CloudWatch | `monitoring` | |
| 60 | | AWS CloudFormation | `cloudformation` | |
| 61 | | Amazon SQS | `sqs` | |
| 62 | | Amazon SNS | `sns` | |
| 63 | | Amazon ElastiCache | `elasticache` | |
| 64 | | Amazon OpenSearch Service | `es` | |
| 65 | | Auto Scaling | `autoscaling` | |
| 66 | |
| 67 | If you do not know the service code, use: |
| 68 | |
| 69 | ```bash |
| 70 | aws service-quotas list-services \ |
| 71 | --query "Services[?contains(ServiceName, '<keyword>')]" \ |
| 72 | --region <region> |
| 73 | ``` |
| 74 | |
| 75 | --- |
| 76 | |
| 77 | ## Step 2: Retrieve Quota Value and Utilization |
| 78 | |
| 79 | ### Get the applied quota value |
| 80 | |
| 81 | ```bash |
| 82 | aws service-quotas get-service-quota \ |
| 83 | --service-code <service-code> \ |
| 84 | --quota-code <quota-code> \ |
| 85 | --region <region> |
| 86 | ``` |
| 87 | |
| 88 | The response includes: |
| 89 | - `Value` — the current quota limit (applied value, or default if no increase was granted) |
| 90 | - `Adjustable` — whether the quota can be increased |
| 91 | - `UsageMetric` — CloudWatch metric to check current utilization (if available) |
| 92 | |
| 93 | ### If you do not know the quota code |
| 94 | |
| 95 | List all quotas for the service: |
| 96 | |
| 97 | ```bash |
| 98 | aws service-quotas list-service-quotas \ |
| 99 | --service-code <service-code> \ |
| 100 | --region <region> |
| 101 | ``` |
| 102 | |
| 103 | Filter by quota name keyword: |
| 104 | |
| 105 | ```bash |
| 106 | aws service-quotas list-service-quotas \ |
| 107 | --service-code <service-code> \ |
| 108 | --region <region> \ |
| 109 | --query "Quotas[?contains(QuotaName, '<keyword>')]" |
| 110 | ``` |
| 111 | |
| 112 | ### Get current utilization via CloudWatch |
| 113 | |
| 114 | If the `UsageMetric` field is present in the quota response, query CloudWatch for actual usage: |
| 115 | |
| 116 | ```bash |
| 117 | aws cloudwatch get-metric-statistics \ |
| 118 | --namespace "<MetricNamespace>" \ |
| 119 | --metric-name "<MetricName>" \ |
| 120 | --dimensions <MetricDimensions> \ |
| 121 | --start-time "<15-minutes-ago-ISO8601>" \ |
| 122 | --end-time "<now-ISO8601>" \ |
| 123 | --period 300 \ |
| 124 | --statistics <MetricStatisticRecommendation> \ |
| 125 | --region <region> |
| 126 | ``` |
| 127 | |
| 128 | The `UsageMetric` object from the quota response provides all the parameters: |
| 129 | - `MetricNamespace` — typically `AWS/Usage` |
| 130 | - `MetricName` — typically `ResourceCount` |
| 131 | - `MetricDimensions` — service-specific dimensions ( |