This rule ensures EC2 AMIs are not accessible to the public.
Rule | Ensure EC2 AMIs are not publicly accessible |
Framework | CloudDefense.AI Security |
Severity | ✔ High |
Rule Description
The rule ensures that Amazon Machine Images (AMIs) in your AWS EC2 environment are not publicly accessible. Publicly accessible AMIs can pose a security risk as they may contain sensitive information or configurations that should not be exposed to the internet. By enforcing the rule, you can prevent accidental exposure of AMIs and protect the integrity of your infrastructure.
Troubleshooting Steps
Remediation Steps
To remediate the issue and ensure that AMIs are not publicly accessible, follow these steps:
Remove public access to existing AMIs:
Prevent future AMIs from being publicly accessible:
Ensure proper permissions for AMIs:
Command Line Interface (CLI) Commands
To remove public access from an AMI using AWS CLI, you can use the following command:
aws ec2 modify-image-attribute --image-id <AMI_ID> --launch-permission "{\"Remove\": [{\"Group\":\"all\"}]}"
Remember to replace
<AMI_ID>
with the actual ID of the AMI that needs modification.To modify the image permissions and restrict access to specific AWS accounts, you can use the following command:
aws ec2 modify-image-attribute --image-id <AMI_ID> --launch-permission "{\"Add\": [{\"UserId\":\"<AWS_ACCOUNT_ID>\"}]}"
Replace
<AMI_ID>
with the actual ID of the AMI, and <AWS_ACCOUNT_ID>
with the AWS account ID that requires access.Please note that these commands should be executed in the AWS CLI environment with appropriate permissions.
Conclusion
By ensuring that your EC2 AMIs are not publicly accessible, you can enhance the security of your AWS environment and avoid the possibility of unauthorized access or accidental exposure of sensitive information. Regularly review the AMIs in your account and adjust their permissions as needed to maintain a secure infrastructure.