'Terraform command line arguments doesn't work with conditional expression
I am trying to deploy a resource block either into dev or prod depending on the variable using conditional expression , for this i am trying to use command line argument.
This work with terraform.tfvars but doesn't work with CMD arguments which means when i am trying to run terraform plan it doesn't not have any other changes.
ideally it should add 1 instance.
here is my resource block
main.tf file
resource "aws_instance" "dev" {
ami = "ami-0ca285d4c2cda3300"
instance_type = var.instanceType
count = var.istest == true ? 1 : 0
}
resource "aws_instance" "prod" {
ami = "ami-0ca285d4c2cda3300"
instance_type = "t2.micro"
count = var.istest == false ? 1 : 0
}
variables.tf
variable "istest" {
default = true
}
terraform .tf vars is empty, command to run terraform
terraform plan -var="istest=false"
amazon-web-services">
amazon-web-servicesterraformterraform-provider-awspythonpycharmrelative-pathabsolute-pathpysimplegui
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
