We do not have EBS Volume encryption enabled by default and that’s not something we can do at this time. However, we would like the majority of our new instances created with encryption for all volumes using the default EBS key.
This works fine using the console, but that’s not useful for partial automation (meaning, I’m not looking for Terraform, Ansible or other solutions at this point).
Our preferred method is PowerShell, but I’ve been unable to launch an Instance with an encrypted volume using the CLI either following the example here:
The only change I’ve made to the ‘mapping.json’ file in the example is to remove the KMS Key ID, which should set it to use the default key according to the blog post. I can launch an instance without encryption successfully after running that with an updated AMI ID and valid Security Group, SSH Key, etc.
If I try to launch it with Encryption, the instance will launch and then immediately terminate itself. This is the behaviour in both AWS CLI and PowerShell.
Has anyone else run into this and solved it, or know what the solution is here compared to the blog post?
EDIT - thank you everyone for the suggestions and direction. It turned out to be caused by a policy enforcing MFA access, which allows the user to reset their password and enable MFA before any other AWS services are allowed. My IAM has MFA enabled for the console and has not had an issue with any other API operation until this one with KMS. I don’t have a solution for that yet, but at least the main blocker has been figured out.
That’s what I’m saying. You are gonna have to make an instance profile that uses a role with permission to use that kms key. Search “iam role encrypt root volume” on Google and you should be able to find info on it.
The ec2 won’t stablized until it can use the kms you are instructing it to use through its instance profile
Hm, ok thanks, I’ll search for that. It’s a bit surprising in that I can use the console to create them encrypted with no issues with that IAM account.
I’m not getting any errors in CloudTrail - the instance is launching successfully and I see that in CloudTrail with no errors in the log, but then immediately terminates. I don’t see any CloudTrail message for that part.
check this if it helps → the key you are using to encrypt the volume also require permissions to use the key, the IAM user used in your powershell script or whatever your method of launch is should have permission to use the key.
Right, can’t edit it. The policy on it would suggest I have permission to use it already; I tried adding ‘ec2:*’ and ‘ebs:*’ to my IAM account policies with no change.
So you’re suprised that you as a console userv identity can have permissions to a Kms resource but that your instance, with a totally different identity does not? What user, i.e. instance profile, would you expect or prefer these instances to be using?