1

I am using Terraform to create aws resources. I practiced with a single region and with my aws cli credentials being used. worked great!

however when I tried to override the region in the Terraform .tf config file it hangs indefinitely.

So how does one either set my aws credentials for the CLI to allow any region, OR how does one set Terraform config files (.tf) to allow multi region infrastructure?

1 Answer 1

1

I believe you would be using multiple modules to create various resources(EC2,ELB, Etc) in AWS using Terraform. You can create a custom module having output value of each variable you want to configure per your requirement like aws-region, etc.

Then source(import) this custom module into your resource module and use its values using $.

custom_module

output "aws_region" {
  value = "us-xyz-1"
}
output "aws_anyproperty" {
  value = "abc"
}

Add above custom_module as source in your resource module

module "custom_module" {
  source="../../../modules/custom_module"
}

provider "aws" {
  version="~> y.x"
  profile="${module.custom_module.aws_anyproperty}"
  region="${module.custom_module.aws_region}"
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.