I have a module to create databases in AWS:
resource "aws_rds_cluster_instance" "db_instances" {
count = lookup(var.argument, "count")
identifier = lookup(var.argument, "identifier", count.index)
}
The argument variable is as follows:
variable "argument" {
type = map(string)
}
In my root main.tf when I try to create 2 db instances I get an error as they're both trying to use the same identifier name, however since I used count.index
in the module I thought it would take care of adding a number at the end of the db name.
variable "argument" {
default = {
count = 2
identifier = "my-db-name"
}
}
How do I make my db names become "my-db-name-0" and "my-db-name-1"?