Hi there,
I’m trying to have a single tf file that can cater to local state or remote AWS S3 for a build pipeline running in a container.
I tried having a dynamic block:
dynamic “s3_backend” {
for_each = var.use_remote_terraform_state == false ? : [1]
terraform {
backend “s3” {
bucket = var.terraform_state_s3_bucket
key = var.terraform_state_s3_key
region = var.terraform_state_s3_region
dynamodb_table = var.terraform_state_dynamo_table
encrypt = true
}
}
}
However this results in the error:
Error: Unsupported block type
on main.tf line 10:
10: dynamic “s3_backend” {
Blocks of type “dynamic” are not expected here.
Any suggestions on how to achieve this?
Thanks in advance.
Tim