Let's say you have the following parameters defined in the AWS parameter store:
/production/worker/SOME_PARAM_1
/prodcution/worker/SOME_PARAM_2
Instead of using multiple data
blocks you can use aws_ssm_parameters_by_path
to load them all at once. \
But using them is another thing. To be able to use them easily, you can remap this data into your own object.
It looks something like this:
data "aws_ssm_parameters_by_path" "my_params" {
path = "/production/worker/"
recursive = true
}
locals {
production-worker-params = {
for k, v in data.aws_ssm_parameters_by_path.my_params.names :
trimprefix(v, "/production/worker/") => data.aws_ssm_parameters_by_path.my_params.values[k]
}
}
You can now use this in your resource
like this:
resource "aws_elastic_beanstalk_environment", "something" {
setting {
name = "SOME_PARAM_1" # The env variable to set
namespace = "aws:elasticbeanstalk:application:environment"
value = local.production-worker-params["SOME_PARAM_1"] # this comes from our freshly brewed map
}
}