'export a environment variable for terraform does not work?

i am trying to set a environment variable for terraform

using export TF_VAR_instanceType="t2.nano"

my tf file looks something like this:-

resource "aws_instance" "myFirstEc2Instance" {

  ami           = "ami-0ca285d4c2cda3300"
  instance_type = var.instanceType
}

Note there is terraform.tfvars as well as variables.tf files too, i am trying to see how exporting environment variables work in Mac. It is using value present terraform.tfvars file.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source