Skip to main content

More Info:

Amazon Machine Images (AMIs) should be encrypted to fulfill compliance requirements for data-at-rest encryption.

Risk Level

High

Address

Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • 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)
  • Essential 8
  • HITRUST CSF
  • ISO/IEC 27017
  • ISO/IEC 27018
  • 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
  • PCI
  • SOC2
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • Securities and Exchange Board of India (SEBI) - Cloud Security Adoption Framework
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

Sure, here are the step-by-step instructions to remediate the EC2 AMIs Should Be Encrypted misconfiguration for AWS using AWS console:
  1. Log in to the AWS Management Console.
  2. Navigate to the EC2 dashboard.
  3. In the left-hand navigation panel, click on the “AMIs” option.
  4. Select the AMI that needs to be encrypted.
  5. Click on the “Actions” button and select “Copy AMI”.
  6. In the “Copy AMI” wizard, select the region where the AMI will be copied and check the “Encrypt this image” option.
  7. Select the KMS key that will be used to encrypt the AMI, or create a new one.
  8. Click on the “Copy AMI” button to start the copy process.
  9. Once the copy process is complete, the new encrypted AMI will be available in the selected region.
  10. Repeat this process for all the unencrypted AMIs in your AWS account.
By following these steps, you can remediate the EC2 AMIs Should Be Encrypted misconfiguration for AWS using AWS console.

To remediate the misconfiguration “EC2 AMIs should be encrypted” in AWS using AWS CLI, follow the below steps:
  1. Open the AWS CLI on your local machine or EC2 instance and ensure that you have the necessary permissions to perform the remediation steps.
  2. List all the AMIs that are not encrypted using the following command:
This command will list all the unencrypted AMIs in your AWS account.
  1. Create a new encrypted copy of the unencrypted AMI using the following command:
Replace the ami-xxxxxxxx with the ID of the unencrypted AMI that you want to encrypt.
  1. Once the new encrypted AMI is created, deregister the unencrypted AMI using the following command:
Replace the ami-xxxxxxxx with the ID of the unencrypted AMI that you want to deregister.
  1. Verify that the new encrypted AMI is available and working correctly.
  2. Repeat the above steps for all unencrypted AMIs in your AWS account.
By following these steps, you can remediate the misconfiguration “EC2 AMIs should be encrypted” in AWS using AWS CLI.
To remediate the misconfiguration of unencrypted EC2 AMIs in AWS using Python, you can follow the following steps:
  1. Import the required AWS SDKs and libraries:
  1. Create an EC2 client object:
  1. Retrieve a list of all the EC2 instances:
  1. Loop through each instance and check if it has any unencrypted AMIs:
  1. To remediate an unencrypted AMI, create a new encrypted copy of it:
  1. Delete the original unencrypted AMI:
  1. Repeat the above steps for each unencrypted AMI found.
Note: Before running the script, make sure that you have the necessary permissions to create and delete EC2 AMIs.
This Terraform configuration creates a new, encrypted copy of the existing AMI, matching the CLI copy-image --encrypted behavior; it does not delete or deregister the original unencrypted AMI (Terraform cannot safely deregister an AMI it does not manage). After you verify workloads with the new AMI, you must manually deregister the old AMI and delete its snapshots in the AWS Console or via CLI as per the warnings.Switching existing EC2 instances, Auto Scaling Groups, or other templates/configurations to use aws_ami_copy.ENCRYPTED_AMI.id will typically cause instance replacement or recreation, which can be disruptive if not coordinated.Verification with terraform plan should show:
  • a new aws_ami_copy resource being created with encrypted = true
  • any updated launch templates / configurations changing their image_id from the old unencrypted AMI ID to the new encrypted AMI ID.

Additional Reading: