Skip to main content

More Info:

Monitoring vCPU-based limits for on-demand EC2 instances avoids resource starvation. Service Quotas is an AWS service that enables you to view and manage your quotas from a central location. Quotas, also referred to as limits, are the maximum value for your resources, actions, and items in your AWS account.

Risk Level

Medium

Address

Operational Maturity, Reliability

Compliance Standards

  • APRA CPS 234 (Australia)
  • AWS Well Architected Framework
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

To remediate the misconfiguration “EC2 Instances Should Not Reach vCPU Limit” in AWS using the AWS console, follow the below steps:
  1. Open the AWS Management Console and navigate to the EC2 dashboard.
  2. Select the EC2 instance that is reaching the vCPU limit.
  3. Click on the “Actions” button and select “Instance Settings” and then click on “Change Instance Type”.
  4. Select a larger instance type that provides more vCPUs than the current instance type.
  5. Review the changes and click on “Apply”.
  6. Once the instance type is changed, the instance will have more vCPUs and the vCPU limit will no longer be reached.
Alternatively, you can also use AWS Auto Scaling to automatically adjust the instance type based on the resource utilization of the instance. This will ensure that the instance always has enough vCPUs and other resources to handle the workload.

To remediate the EC2 instances reaching vCPU limit misconfiguration in AWS using AWS CLI, follow the below steps:Step 1: Log in to the AWS Management Console.Step 2: Open the AWS CLI on your local machine.Step 3: Use the below command to describe the EC2 instances that have reached the vCPU limit:
This command will display the list of instances that have reached the vCPU limit.Step 4: Stop the EC2 instances that have reached the vCPU limit using the below command:
Replace the <instance-id> with the actual instance ID of the instance that you want to stop.Step 5: Modify the instance type of the stopped instances using the below command:
Replace <instance-id> with the actual instance ID of the instance that you want to modify, and <new-instance-type> with the desired instance type.Step 6: Start the modified EC2 instances using the below command:
Replace the <instance-id> with the actual instance ID of the instance that you want to start.By following these steps, you can remediate the EC2 instances reaching vCPU limit misconfiguration in AWS using AWS CLI.
To remediate the EC2 Instances reaching vCPU limit misconfiguration in AWS using python, you can follow the below steps:Step 1: Identify the EC2 instances which are reaching vCPU limit using the boto3 library in python.
Step 2: Stop and start the EC2 instances which are reaching the vCPU limit to remediate the misconfiguration.
By following the above steps, you can remediate the EC2 Instances reaching vCPU limit misconfiguration in AWS using python.
Stopping the instance with aws_ec2_instance_state will cause service interruption but preserves data on attached EBS volumes; it does not terminate the instance.To permanently terminate an instance via Terraform, you remove (or set count = 0/for_each = {} on) the aws_instance resource representing it and apply; this is a destructive and irreversible action and will delete the instance, and depending on its root_block_device settings, may also delete the root EBS volume and any instance-store data.AWS Service Quotas vCPU limit increases (aws service-quotas request-service-quota-increase) cannot currently be requested or managed via the Terraform AWS provider; they must be done manually or via the AWS CLI/SDK as in the provided commands.For verification, terraform plan should show:
  • For stopping: a planned change to aws_ec2_instance_state.stop_instance with state transitioning from running (or pending) to stopped.
  • For termination: the aws_instance.TARGET_INSTANCE resource marked with -/+ (destroy and recreate elsewhere) or - (destroy) if you removed it, confirming the instance will be terminated.

Additional Reading: