-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Can't access encrypted attribute of block_device_mappings list/map #6775
Comments
Unfortunately it's not really possible to get at the EBS volume attributes here. I raised a similar issue with #1623 to build on the work done in #1572 to expose some of these deeply nested attributes. Coming at it fresh I attempted the following: output "ebs" {
value = "${lookup(data.aws_ami.target_ami.0.block_device_mappings[0], "ebs")}"
} But this errors out as lookup can only work on flat maps, not nested ones like the
Going another way I tried to get at things by chaining data sources through to the If those constraints work you could do something like this:
This would tell you whether the AMI is encrypted or not but doesn't influence the AMI selection of the data source (which would be doable if it was filterable directly in the You could decide to follow in the footsteps of #1572 to expose this attribute at a higher level. It's also possible that this becomes easier in 0.12 with the release of HCL2 but I've not had enough of a play with the 0.12 alphas to be sure of that. In the end I ended up changing how I was doing things so I no longer needed to get at the EBS volume size and this might be an option for you. How are you creating your AMIs that ends up with both encrypted and unencrypted versions for the same filters? I create my AMIs using Packer and when we create an encrypted AMI it first registers an unencrypted AMI, then creates an encrypted snapshot from that before registering a new AMI for the encrypted volume, tags the new AMI and, finally, deleting the old one. As long as at least one of your filter criteria in the |
We aren’t going to automate ami creation and instead do it manually so it’s not a 100% big deal. I’m just trying to be as comprehensive as possible especially with building our test-kitchen use cases. |
Is there a reason you aren't automating AMI creation? That seems like a bigger win than writing test cases for Terraform to me. |
Our AMIs won’t be changing regularly. What is your use case where you have to create AMIs regularly? |
We follow the immutable infrastructure pattern so all changes are baked into AMIs and rolled out. So every time we change something that affects either our base AMI or a specific AMI (such as our ECS cluster AMI) or we apply patches then we need to bake a new AMI (or all the AMIs when the base AMI changes). |
Hi, @estein9825! Thank you for using Terraform and for opening up this question. Issues on GitHub are intended to be related to bugs or feature requests with the provider codebase. It appears @tomelliff has provided an answer, as well as some good feedback (thanks)! If needed, please use https://discuss.hashicorp.com/c/terraform-providers for additional feedback, community discussions, and questions around Terraform. If you believe that your issue was miscategorized as a question or closed in error, please create a new issue using one of the following provided templates: bug report or feature request. Please make sure to provide us with the appropriate information so we can best determine how to assist with the given issue. |
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! |
This issue was originally opened by @estein9825 as hashicorp/terraform#19574. It was migrated here as a result of the provider split. The original body of the issue is below.
I need to confirm whether a particular AMI has encryption enabled. My data/output calls to aws_ami are:
results in
However, for the life of me, I can't seem to grab that "encrypted" value.
I've tried accessing the
data.aws_ami.target_ami.*.block_device_mappings.#.ebs.encrypted
attribute like they suggested in the documentation and neither 0 nor * work. It keeps sayingThe purpose is to ensure that I only grab the appropriate AMI when I create an ec2 instance dynamically.
In otherwords, for
I want to make sure var.ami_id is encrypted.
I am currently using Terraform v0.11.10.
Hopefully someone knows a way.
The text was updated successfully, but these errors were encountered: