Does anyone know if something like this can be done in terraform 11:
You can use count
for such scenario:
resource "aws_s3_bucket" "feedback_service_bucket" {
count = "${var.account_name == "prod" ? 1 : 0}"
bucket = "ces-${var.environment}-QA-compendex"
acl = "private"
}
You can refer to this: https://www.terraform.io/docs/configuration-0-11/interpolation.html#conditionals
I will upgrade soon to terraform 13, but as this is required in this sprint I don’t have time.
For info, Terraform 0.13 won’t give you much advantages for this specific use case. You would still use count
. What changes in 0.13 regarding conditional resources is that you have an alternative using for_each
– introduced with v0.12 – and in which you can achieve the same behavior.
CLICK HERE to find out more related problems solutions.