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

EBS root block encryption not available in EC2 #6246

Closed
georgesvachulay opened this issue Oct 23, 2018 · 10 comments · Fixed by #7757
Closed

EBS root block encryption not available in EC2 #6246

georgesvachulay opened this issue Oct 23, 2018 · 10 comments · Fixed by #7757
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@georgesvachulay
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

I would like the following to work:

    root_block_device = {
      volume_type = "gp2"
      volume_size = "10"
      encrypted   = true
    }

Current state if used:

root_block_device.0: invalid or unknown key: encrypted

Works fine with the ebs_block_device resource (https://www.terraform.io/docs/providers/aws/r/instance.html#block-devices). This is a fairly general use case in AWS, without this the most used volume of an instance won't be encrypted.

New or Affected Resource(s)

  • aws_instance
  • aws_ebs_volume (potentially)

Potential Terraform Configuration

resource "aws_instance" "xy" {
    root_block_device = {
      volume_type = "gp2"
      volume_size = "10"
      encrypted   = true
    }
}

References

@jcreyf
Copy link

jcreyf commented Nov 13, 2018

Please also add support for kms_key_id

@a-h
Copy link
Contributor

a-h commented Dec 19, 2018

aws_launch_configuration would also need updating to allow machines to have their root volumes encrypted.

Input

resource "aws_launch_configuration" "example_config" {
  image_id             = "ami-0274e11dced17bb5b"
  instance_type        = "t2.micro"
  root_block_device {
    encrypted = true
  }
}

Current Output

aws_launch_configuration.example_config: root_block_device.0: invalid or unknown key: encrypted

The current workaround for this is use an encrypted AMI (see terraform-aws-modules/terraform-aws-ec2-instance#6 (comment)).

@johnjelinek
Copy link

I hacked on this functionality and got it to read the root block encrypted state, but I could not get it to encrypt an AMI that was unencrypted.

--- FAIL: TestAccAWSInstance_blockDevices (7.80s)
    testing.go:538: Step 0 error: Error applying: 1 error occurred:
                * aws_instance.foo: 1 error occurred:
                * aws_instance.foo: Error launching source instance: InvalidBlockDeviceMapping: the encrypted flag cannot be specified since device /dev/sda1 has a snapshot specified.
                status code: 400, request id: eafc2b82-1ce1-47e4-9b4a-c5949696c7d4

@nywilken nywilken added enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service. labels Feb 5, 2019
@joestump
Copy link
Contributor

@johnjelinek I got this working in #7757 with unencrypted AMIs. The acceptance tests use vanilla public Ubuntu AMIs. @jcreyf I also added kms_key_id to both ebs_block_device and root_block_device.

@a-h sadly, I didn't get to aws_launch_configuration. I'll try to get to that in another PR.

@joestump
Copy link
Contributor

joestump commented Feb 28, 2019

@a-h #7759 adds encrypted to root_block_device on aws_launch_configuration. 👍

@felixb
Copy link
Contributor

felixb commented Apr 2, 2019

@joestump what about launch templates? do you plan to add a third PR for that?

@joestump
Copy link
Contributor

joestump commented Apr 2, 2019

@felixb I'll take a look.

@captn3m0
Copy link

Relevant to this issue: AWS now supports sharing encrypted AMIs across accounts now

@nywilken
Copy link
Contributor

Hi Folks thanks for pushing this request forward. To help consolidate this EBS encryption request, I am going to roll this issue into this new parent #8624. Where we can continue to track progress and discuss implementation details.

@ghost
Copy link

ghost commented Nov 3, 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 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants