More Info:
Identify and remove any unassociated Elastic IP (EIP) addresses for cost optimization.Risk Level
LowAddress
Cost OptimisationCompliance 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)
- HITRUST CSF
- ISO/IEC 27017
- ISO/IEC 27701
- KSA PDPL
- MAS Technology Risk Management (Singapore)
- MITRE ATT&CK (Cloud)
- NIS2 Directive
- NIST CSF
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- SOC2
- SWIFT Customer Security Controls Framework
- Sarbanes-Oxley IT General Controls
- UK NCSC Cyber Assessment Framework
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
Sure, here are the step-by-step instructions to remediate the “Unassociated Elastic IP Addresses Should Be Removed” misconfiguration for AWS using the AWS console:
- Login to your AWS console.
- Go to the EC2 dashboard by clicking on the “Services” dropdown at the top of the page and selecting “EC2” under the “Compute” section.
- Click on the “Elastic IPs” link in the left-hand navigation menu.
- Look for any Elastic IP addresses that are not associated with an EC2 instance. These will be labeled as “Not associated” in the “Association ID” column.
- Select the unassociated Elastic IP address by checking the box next to it.
- Click on the “Actions” dropdown menu at the top of the page and select “Release addresses”.
- In the confirmation dialog box, click on the “Release” button to confirm the release of the unassociated Elastic IP address.
Using CLI
Using CLI
To remediate the misconfiguration “Unassociated Elastic IP Addresses Should Be Removed” in AWS using AWS CLI, follow these steps:
- Open your terminal and install AWS CLI if it is not already installed.
-
Run the following command to list all the unassociated Elastic IP addresses in your AWS account:
aws ec2 describe-addresses --filters "Name=association-id,Values=null" - Identify the Elastic IP address that needs to be removed.
-
Run the following command to release the Elastic IP address:
aws ec2 release-address --public-ip <public-ip-address>Replace<public-ip-address>with the actual Elastic IP address that needs to be removed. -
Verify that the Elastic IP address has been successfully released by running the following command:
aws ec2 describe-addresses --public-ips <public-ip-address>Replace<public-ip-address>with the actual Elastic IP address that was removed. You should get an error message stating that the Elastic IP address does not exist. - Repeat steps 4 and 5 for all the unassociated Elastic IP addresses in your AWS account.
- Once you have removed all the unassociated Elastic IP addresses, verify that the misconfiguration has been remediated by running a security scan or audit tool.
Using Python
Using Python
To remediate the misconfiguration “Unassociated Elastic IP Addresses Should Be Removed” for AWS using python, you can follow the below steps:Note: Before running this code, make sure that you have AWS credentials set up on your machine.
- Import the necessary libraries:
- Instantiate a boto3 EC2 client:
- Get a list of all unassociated Elastic IP addresses:
- Loop through the unassociated Elastic IP addresses and release them:
- Verify that the unassociated Elastic IP addresses have been removed:
Using Terraform
Using Terraform
aws_eip resource (like the example above) from your configuration (or change its count to 0/remove it from a module call) and run terraform apply. Terraform will then issue the same API call as aws ec2 release-address and permanently release the Elastic IP; this is irreversible and you must ensure it is not referenced by DNS or needed later.terraform plan should show the aws_eip resource with a - (destroy) action only, and no replacements for other resources.
