Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to encrypt root_block_device in aws_launch_configuration #7759

Merged
merged 1 commit into from
Aug 2, 2019

Conversation

joestump
Copy link
Contributor

@joestump joestump commented Feb 28, 2019

Refs #6246
Refs #8624

Changes proposed in this pull request:

  • Adds the encrypted attribute to the root_block_device on aws_launch_configuration.

NOTE: It appears KmsKeyId is not supported by this API.

Output from acceptance testing:

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -parallel 20 -run=TestAccAWSLaunchConfiguration_encryptedRootBlockDevice -timeout 120m
?   	github.com/terraform-providers/terraform-provider-aws	[no test files]
=== RUN   TestAccAWSLaunchConfiguration_encryptedRootBlockDevice
=== PAUSE TestAccAWSLaunchConfiguration_encryptedRootBlockDevice
=== CONT  TestAccAWSLaunchConfiguration_encryptedRootBlockDevice
--- PASS: TestAccAWSLaunchConfiguration_encryptedRootBlockDevice (34.95s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	36.220s

@ghost ghost added size/M Managed by automation to categorize the size of a PR. documentation Introduces or discusses updates to documentation. service/autoscaling Issues and PRs that pertain to the autoscaling service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Feb 28, 2019
@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label Mar 4, 2019
@bflad
Copy link
Contributor

bflad commented Mar 4, 2019

The API documentation for this parameter is pretty confusing 😅

Specifies whether the volume should be encrypted. Encrypted EBS volumes must be attached to instances that support Amazon EBS encryption. Volumes that are created from encrypted snapshots are automatically encrypted. There is no way to create an encrypted volume from an unencrypted snapshot or an unencrypted volume from an encrypted snapshot. If your AMI uses encrypted volumes, you can only launch it on supported instance types. For more information, see Amazon EBS Encryption in the Amazon EC2 User Guide for Linux Instances.

Are we sure this actually does anything for unencrypted root block devices to encrypt them? It might be worth spinning this up in an autoscaling group and verifying. We've seen this a bunch with EC2 Launch Templates where the template will create but its actual usage will cause an error.

@bflad bflad added the waiting-response Maintainers are waiting on response from community or contributor. label Mar 4, 2019
@joestump
Copy link
Contributor Author

joestump commented Mar 4, 2019

Are we sure this actually does anything for unencrypted root block devices to encrypt them?

It will definitely not do this. This only works if the instance type supports it. If you're using a snapshot, it must be encrypted. Also, like I said no KMS support so it'll be encrypted with your aws/ebs key. I suspect if you provide an unencrypted snapshot or an instance type that doesn't support encryption, you'd end up with ASG errors.

I'll run a more manual test and report back. I did verify in the console that aws_instance works as advertised. Presumably with the right instance type and no snapshot, you'd be good to go.

@ghost ghost removed the waiting-response Maintainers are waiting on response from community or contributor. label Mar 4, 2019
@jhmartin
Copy link

jhmartin commented May 14, 2019

If you're using a snapshot, it must be encrypted.

https://aws.amazon.com/about-aws/whats-new/2019/05/launch-encrypted-ebs-backed-ec2-instances-from-unencrypted-amis-in-a-single-step/ may have changed that

@aeschright aeschright requested a review from a team June 26, 2019 00:47
@atiftw
Copy link

atiftw commented Jun 29, 2019

Yep - AWS now allows you to launch instances with encrypted root block devices from amis with unencrypted ones.Also supports adding a KMS key, i can add support for the latter once this is merged to master.We need this badly.

More documentation here-:
https://aws.amazon.com/blogs/security/how-to-quickly-launch-encrypted-ebs-backed-ec2-instances-from-unencrypted-amis/

Edit-:
Sadly, the AWS GO SDK does not support passing the kms key id yet.Opened a feature request.

@hankhan425
Copy link

Can we have this merged now and create a new PR for supporting KMS key ID once that feature is in?

@bflad bflad self-assigned this Aug 2, 2019
@bflad bflad added this to the v2.23.0 milestone Aug 2, 2019
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for this, @joestump 🚀 Only change on merge was switching from Default: false to Computed: true just to prevent any oddities with existing Terraform configurations.

Output from acceptance testing:

--- PASS: TestAccAWSLaunchConfiguration_importBasic (15.77s)
--- PASS: TestAccAWSLaunchConfiguration_withSpotPrice (16.30s)
--- PASS: TestAccAWSLaunchConfiguration_withBlockDevices (18.98s)
--- PASS: TestAccAWSLaunchConfiguration_ebs_noDevice (19.10s)
--- PASS: TestAccAWSLaunchConfiguration_withEncryption (19.28s)
--- PASS: TestAccAWSLaunchConfiguration_withIAMProfile (30.49s)
--- PASS: TestAccAWSLaunchConfiguration_basic (31.32s)
--- PASS: TestAccAWSLaunchConfiguration_encryptedRootBlockDevice (31.67s)
--- PASS: TestAccAWSLaunchConfiguration_updateEbsBlockDevices (32.94s)
--- PASS: TestAccAWSLaunchConfiguration_updateRootBlockDevice (33.81s)
--- PASS: TestAccAWSLaunchConfiguration_userData (34.58s)
--- PASS: TestAccAWSLaunchConfiguration_withVpcClassicLink (42.25s)

@bflad bflad merged commit 79e5127 into hashicorp:master Aug 2, 2019
bflad added a commit that referenced this pull request Aug 2, 2019
@ghost
Copy link

ghost commented Aug 7, 2019

This has been released in version 2.23.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@jc-asdf
Copy link
Contributor

jc-asdf commented Aug 14, 2019

NOTE - this seems to have broken the instance store case.

When creating an instance-store launch template, it fails with:

Error: Error applying plan:

1 error occurred:
	* aws_launch_configuration.yes_i_used_an_instance_store_ami: 1 error occurred:
	* aws_launch_configuration.yes_i_used_an_instance_store_ami: Instance store backed AMIs do not provide a root device name - Use an EBS AMI

EDIT - full issue in #9775

@joestump joestump deleted the jstump-launch-config-encryption branch September 4, 2019 17:29
@ghost
Copy link

ghost commented Nov 1, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. enhancement Requests to existing resources that expand the functionality or scope. service/autoscaling Issues and PRs that pertain to the autoscaling service. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants