Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Encrypt root volume of EC2 while creating stack using cloud formation

Working on cloud formation script which will create simple ec2 instance. here i want to encrypt a root volume at the time of launch. its possible to create a separate EBS, encrypt it and attach it as boot volume. but i couldn't find a way to encrypt it while launching. any way to do this?

Thanks In Advance

like image 403
Kiran Avatar asked Jun 17 '26 17:06

Kiran


1 Answers

It looks like AWS has recently released a feature to launch an instance with encrypted volume based on non-encrypted AMI. Launch encrypted EBS backed EC2 instances from unencrypted AMIs in a single step

From the CloudFormation perspective, you need to overwrite AMI block device configuration. So for example, you can write like this:

  BlockDeviceMappings:
  - DeviceName: "/dev/xvda"
    Ebs:
      VolumeSize: '8'
      Encrypted: 'true'

This will start an instance with encrypted root EBS from non-encrypted AMI with a default KMS key

like image 59
dhavryk Avatar answered Jun 20 '26 04:06

dhavryk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!