Definitely is: A
https://www.terraform.io/language/settings/backends/configuration#credentials-and-sensitive-data
Warning: We recommend using environment variables to supply credentials and other sensitive data. If you use -backend-config or hardcode these values directly in your configuration, Terraform will include these values in both the .terraform subdirectory and in plan files. This can leak sensitive credentials.
Authentication outside of Terraform is more secure than environment variables. Your environment variables can still refer to a file or the definition of your variables inside terraform. So I would go for C.
https://developer.hashicorp.com/terraform/language/backend
Warning: We recommend using environment variables to supply credentials and other sensitive data. If you use -backend-config or hardcode these values directly in your configuration, Terraform will include these values in both the .terraform subdirectory and in plan files. This can leak sensitive credentials.
The correct answer is **A. Defined in Environment variables**.
Environment variables are considered the most secure place to store secrets for connecting to a Terraform remote backend because:
- They keep sensitive information out of source control (such as in `.tf` files or other configuration files).
- Secrets stored in environment variables can be managed securely by the operating system or deployment environment and can be encrypted or otherwise protected.
Storing secrets inside the backend block (option B) or in a connection configuration outside Terraform (option C) can expose them to version control or make them less secure. Therefore, it's best practice to use environment variables for storing sensitive credentials securely.
The correct answer is: A. Defined in Environment variables
Explanation:
When storing secrets for connecting to a Terraform remote backend, environment variables are the most secure option. Here's why:
Environment Variables:
Secure: Environment variables can be securely managed outside of Terraform configuration files and are not checked into version control.
Flexibility: You can use tools like HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault to inject secrets as environment variables dynamically.
Common Practice: Many services (e.g., AWS, Azure, Google Cloud) support using environment variables for storing sensitive credentials like access keys, secret keys, and tokens.
I've answered D - "None of the above", because the most secure way is e.g. Azure Key Vault, when working with Azure, of course.
In this case - we're not revealing any of the secrets values.
Terraform can refer them via "data" operators.
(and, yes, this approach is not a "connection configuration")
The most secure option for storing secrets when connecting to a Terraform remote backend is A. Defined in environment variables. This approach keeps sensitive information, such as API keys or access tokens, out of your version-controlled configuration files. Defining secrets in environment variables reduces the risk of accidental exposure or leakage through your Terraform configuration. Using external secret management tools (like HashiCorp Vault) to manage environment variables can further enhance security.
C. Defined in a connection configuration outside of Terraform (Most Secure)
This is the most secure option. Here, you store your secrets in a separate dedicated location outside of your Terraform configuration. There are several ways to achieve this:
Secret Management Tools: Utilize tools like HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault to store and manage your secrets securely. These tools offer access control and encryption mechanisms.
Encrypted Files: Store secrets in an encrypted file outside your Terraform configuration directory. Terraform can access these secrets during execution by referencing the decrypted content of the file.
choose A:
when we use vault, we still need to download it into a file,here is official doc:
- **File**: A configuration file may be specified via the `init` command line. To specify a file, use the `-backend-config=PATH` option when running `terraform init`. If the file contains secrets it may be kept in a secure data store, such as [Vault](https://www.vaultproject.io/), in which case it must be downloaded to the local disk before running Terraform.
https://developer.hashicorp.com/terraform/language/settings/backends/configuration#credentials-and-sensitive-data
From the documentation :
Warning: We recommend using environment variables to supply credentials and other sensitive data. If you use -backend-config or hardcode these values directly in your configuration, Terraform will include these values in both the .terraform subdirectory and in plan files. This can leak sensitive credentials.
So it's A
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
zyxphreez
Highly Voted 2 years, 6 months agoAlandt
1 year, 1 month agodeepeshukla
1 year, 8 months agoGomjaba
1 year, 6 months agoCHRIS12722222
Highly Voted 2 years, 7 months agoAlandt
1 year, 1 month agoKG8
Most Recent 4 days, 6 hours agoAsif_draxi
1 month, 3 weeks agosuri_surendra
2 months, 1 week agoDimedrol1
4 months, 1 week agoAlgol
6 months agopremnick
7 months, 2 weeks agoSureNot
9 months agoMolly1994
9 months, 1 week agodeepakpamban
10 months, 1 week agoVenki_dev
10 months, 3 weeks agokingfighers
11 months, 1 week agoaksliveswithaws
11 months, 2 weeks agoAntonyPeter7
1 year agoKaname93
1 year agoAlandt
1 year, 1 month ago