Hey there,
We’re storing output values in the AWS SSM Parameter Store, and I’m having trouble figuring out how to take a list of parameters, and make it a little easier to reference them in other modules.
Here’s what I mean. Say I’ve got this code, to retrieve everything under /infrastructure/vpc in a certain AWS account:
data "aws_ssm_parameters_by_path" "vpc" {
path = "/infrastructure/vpc"
recursive = true
}
data.aws_ssm_parameters_by_path.vpc.names produces this list:
[
"/infrastructure/vpc/private-subnets/app.dataA",
"/infrastructure/vpc/private-subnets/app.dataB",
"/infrastructure/vpc/private-subnets/app.privateA",
"/infrastructure/vpc/private-subnets/app.privateB",
"/infrastructure/vpc/public-subnets/app.publicA",
"/infrastructure/vpc/public-subnets/app.publicB",
"/infrastructure/vpc/vpc-id",
]
If we were importing a state file, we could just get these values by referencing the name of the output, however now I’ve got these strings to deal with.
Ideally, what I would like to do is retrieve the values of these parameters and build a map that would look something like this:
"vpc-id" = "parameterValue"
"app.publicA" = "parameterValue"
And they would be referenced like this:
local.mapname.vpc-id
I’ve been messing around with HCL to try to get what I want but haven’t really gotten anywhere, so I figure I’ll toss this out to the hivemind to see what you can come up with.