J'écris des templates terraform pour créer deux buckets S3, cependant, mon besoin est de concaténer leurs noms dans vars.tf et ensuite de le passer au fichier tf principal. Voici les fichiers vars.tf et s3.tf principal.
vars.tf :
variable TENANT_NAME {
default = "Mansing"
}
variable BUCKET_NAME {
type = "list"
default = ["bh.${var.TENANT_NAME}.o365.attachments", "bh.${var.TENANT_NAME}.o365.eml"]
}
s3.tf :
resource "aws_s3_bucket" "b" {
bucket = "${element(var.BUCKET_NAME, 2)}"
acl = "private"
}
Lorsque je fais le plan de terraformation, j'obtiens une erreur indiquant que var peut ne pas fonctionner ici.
Error: Variables not allowed
on vars.tf line 10, in variable "BUCKET_NAME":
10: default = ["bh.${var.TENANT_NAME}.o365.attachments", "bh.${var.TENANT_NAME}.o365.eml"]
Variables may not be used here.
Error: Variables not allowed
on vars.tf line 10, in variable "BUCKET_NAME":
10: default = ["bh.${var.TENANT_NAME}.o365.attachments", "bh.${var.TENANT_NAME}.o365.eml"]
Variables may not be used here.
J'ai essayé de remplacer var dans le fichier vars par locale mais cela n'a pas fonctionné.