I came to an issue, I did not found any great documentation on the way to avoid setting the backend configuration or the access_key of Terraform out of the source code.
Is this the best way ? : Hashicorp Terraform Remote State and Azure
Any one have a great solution for it ?
backend "azurerm" {
resource_group_name = "tfstate"
storage_account_name = "<storage_account_name>"
container_name = "tfstate"
key = "terraform.tfstate"
access_key = "value" # This is a bad value to expose
}
Have a good day.
2
Answers
You can leverage TF_VAR_name
So you need to create
variable "access_key"
and then set environment variable TF_VAR_access_key and assign your access key.Your terraform code will be
and your pipeline
access_key
should be stored as secret in variable group, or loaded from key vault.Have you tried hashicorp offering called vault , specially designed to take care secrets, identity and others sensitive information.
Official website:-
https://www.vaultproject.io/