Terraform: how to read list of maps?

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


Terraform: how to read list of maps?



See the example below:


data "aws_kms_secrets" "api_key" {
count = "${length(keys(var.keys))}"

secret {
name = "secret_name"
payload = "${element(values(var.keys), count.index)}"
}
}

resource "aws_api_gateway_api_key" "access_key" {
count = "${length(keys(var.keys))}"

name = "${var.environment}-${element(keys(var.keys), count.index)}"
value = "${lookup(element(data.aws_kms_secrets.api_key.*.plaintext, count.index), "secret_name")}"
}



It appears to be impossible to look up the plaintext values from the data resource.



value = "${lookup(element(data.aws_kms_secrets.api_key.*.plaintext, count.index), "secret_name")}"


value = "${lookup(element(data.aws_kms_secrets.api_key.*.plaintext, count.index), "secret_name")}"



Results in lookup: argument 1 should be type map, got type string in:


lookup: argument 1 should be type map, got type string in:



I have tried many combinations of element,lookup,*, and dictionary syntax nothing works.


element


lookup


*



my var.keys looks like:


var.keys


keys = {
key-name-one = "sssss"
key-name-two = "sss"
}









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

NePJS7o5Tj1K01Qv9o7AuyUb8E UXYS30Oe6 pFR1qj3fggK4c01b6VEM80tz8YPN8,SIP 1Vb6fEma,mlVa
wKIvaErw

Popular posts from this blog

Makefile test if variable is not empty

Visual Studio Code: How to configure includePath for better IntelliSense results

Will Oldham