How to make Terraform to read AWS Credentials file?
Answer recommended by AWS Collective
Answer recommended by AWS Collective
Right now it’s not possible to achieve that. There were previous discussions on github about the same topic in the following issues: https://github.com/hashicorp/terraform/issues/5480 https://github.com/hashicorp/terraform/issues/4585 https://github.com/hashicorp/terraform/issues/2714 https://github.com/hashicorp/terraform/issues/1742 https://github.com/hashicorp/terraform/issues/1478 TL;DR the sharing of variables between modules is against terraform core clarity/explicity principles. Workaround A workaround is to have the *shared* files in the parent directory and using … Read more
There are 3 possible workarounds depending on your specific scenario in order to solve it: Case 1 If you have a backup of your AWS S3 terrform.tfstate file you could restored your state backend “s3” {key = “path/to/terraform.tfstate”} to an older version. Re try terraform init and validate if it works well. Case 2 Remove … Read more
This is one way using the coalesce() function: locals{ prod = “${var.environment == “PROD” ? “east” : “”}” prod2 = “${var.environment == “PROD2” ? “west2” : “”}” nonprod = “${var.environment != “PROD” && var.environment != “PROD2” ? “west” : “”}” region = “${coalesce(local.prod,local.prod2, local.nonprod)}” }
Terraform 0.12 (yet to be released) will also bring support for HCL2 which allows you to use nullable arguments with something like this: resource “aws_ebs_volume” “my_volume” { availability_zone = “xyz” size = 30 snapshot_id = var.staging_mode ? local.a_specific_snapshot_id : null } Nullable arguments are covered in this 0.12 preview guide. For version of Terraform before … Read more
There is no –except feature in terraform destroy command currently. If you really want to do that, and you know what you are doing, here is the workaround. # list all resources terraform state list # remove that resource you don’t want to destroy # you can add more to be excluded if required terraform … Read more