Understanding AMI Encryption and Sharing Across AWS Accounts

all aws amazon ec2 aws kms aws security aws storage Jan 31, 2024

Introduction

Amazon Machine Image (AMI) is essentially a snapshot of a root filesystem that we can use to launch new instances. An AMI contains all the information necessary to start an instance, including the operating system, the application server, and applications. Encrypting AMIs protects sensitive data from unauthorized access, ensuring only entities with decryption keys can launch instances from these AMIs. It's particularly crucial to comply with industry regulations and safeguard intellectual property or personal data. This encryption is done using AWS KMS keys.

How to Encrypt an AMI

Encrypting an AMI typically involves creating an encrypted snapshot of the EBS (Elastic Block Store) volumes associated with the AMI and then creating a new AMI from that snapshot. During this process, we specify a KMS key to be used for encryption.

Why Share Encrypted AMIs?

Sharing encrypted AMIs is useful when maintaining a secure and consistent environment across different AWS accounts. This could be for reasons such as organizational policies or compliance requirements or simply to ensure that environments are replicated accurately and securely in different parts of our organization.

Sharing Encrypted AMIs Across Accounts

Sharing an encrypted AMI involves more steps than sharing a regular, unencrypted AMI. Let’s break it down:

Step 1: Prepare the AMI for Sharing

Ensure the AMI we wish to share is encrypted using a customer-managed KMS key rather than the default AWS-managed KMS key. This is important because AWS does not allow sharing the default KMS keys across accounts.

 

Step 2: Grant access to the KMS Key

Before the target account can use the encrypted AMI, access to the KMS key used for encrypting the AMI’s underlying snapshots must be granted. This does not mean transferring the key itself but rather modifying the key's policy to include permissions for the target account. Without access to this KMS key, the target account won’t be able to decrypt the AMI.

Step 3: Modify AMI Permissions

After ensuring the target account has access to the KMS key, we must modify the AMI's launch permissions to allow the target account to use it. This is done by adding the target account as a permitted AWS account under the AMI’s "Permissions" tab in the AWS Management Console.

Step 4: Share the AMI ID with the Target Account

Once granted the necessary permissions, share the AMI ID with the target account. The administrator of the target account will then be able to launch instances from the shared AMI using the granted KMS key for decryption.

Optional: Re-encryption under the Target Account

Optionally, when launching an instance from the shared AMI, the target account can specify a new KMS key that it manages to re-encrypt the instance’s EBS volumes. This step ensures the target account has full control over the encryption keys used for its instances.

 

 

Conclusion

Sharing encrypted AMIs across AWS accounts ensures that we can maintain security and compliance standards while collaborating or migrating resources between accounts. By following the steps outlined above—preparing the AMI, granting access to the KMS key, modifying AMI permissions, and optionally re-encrypting with a new key—we can streamline the process of sharing encrypted resources in a secure manner. Remember, managing access to our KMS keys is crucial throughout this process to maintain the security and integrity of our encrypted AMIs.

Stay connected with news and updates!

Join our mailing list to receive the latest news and updates from our team.
Don't worry, your information will not be shared.

We hate SPAM. We will never sell your information, for any reason.