I have the following Terragrunt unit that I'd like to prefix a given environment too.
envs:
- dev
- stg
tables:
dynamo-db-table:
hash_key: "key"
attributes:
- name: "key"
type: "S"
working with the following module
module "dynamodb_table" {
source = "terraform-aws-modules/dynamodb-table/aws"
version = "3.3.0"
for_each = var.tables
name = each.key
hash_key = each.value.hash_key
attributes = each.value.attributes
}
variable "tables" {
description = "Dyanamodb tables"
type = map(object({
hash_key = string
attributes = list(map(string))
}))
When I apply the above config, I'd like the output to ultimately create 2 dynamodb tables "dev-dynamo-db-table" and "stg-dynamo-db-table"
I suspect there is a way of concatenating the envs value onto the map key through a locals value but am not sure how, nor if there is a much simpler way of doing it?
Full working sample code:
Output of
terraform plan: