Could we use if-conditional to apply argument ?
Example
main.tf
resource "google_compute_backend_service" "bs" {
...
if var.iaps == "true" then
iap {
oauth2_client_id = var.iapsid
oauth2_client_secret = var.iapssecret
oauth2_client_secret_sha256 = var.iaps256
}
fi
}
variables.tf
variable "iaps" { default = false }
terraform.tfvars
iaps = true
iapsid = "AAXX"
iapssecret = "1234AA"
iaps256 = "d3eb1a"
Result is the terraform will process the iap block argument, but if other developer set iaps to false then terraform will not apply iap block argument
Is there a way to do like above ?
I want to make terraform script customizable. So, i don’t need to create 2 different main.tf