TA-002-P · Question #76
Which of these options is the most secure place to store secrets foe connecting to a Terraform remote backend?
The correct answer is A. Defined in Environment variables. For connecting to a Terraform remote backend, storing sensitive credentials as environment variables is generally considered the most secure option among the choices, especially in automated CI/CD environments.
Question
Which of these options is the most secure place to store secrets foe connecting to a Terraform remote backend?
Options
- ADefined in Environment variables
- BInside the backend block within the Terraform configuration
- CDefined in a connection configuration outside of Terraform
- DNone of above
How the community answered
(31 responses)- A94% (29)
- C3% (1)
- D3% (1)
Why each option
For connecting to a Terraform remote backend, storing sensitive credentials as environment variables is generally considered the most secure option among the choices, especially in automated CI/CD environments.
Environment variables (e.g., provider-specific variables or `TF_BACKEND_CONFIG_` prefixed variables) are generally the most secure way to provide sensitive credentials to Terraform in CI/CD pipelines. They can often be masked in logs, are not stored in plaintext in the repository, and are typically managed by secure CI/CD secrets features.
Storing secrets directly inside the `backend` block within the Terraform configuration (e.g., in `main.tf`) is highly insecure because these files are usually committed to version control in plaintext, exposing the secrets.
While external secrets managers are ideal, simply stating 'Defined in a connection configuration outside of Terraform' without specifying how it's secured doesn't make it inherently more secure than environment variables.
Since storing secrets in environment variables is a common and recommended secure practice for Terraform backends and providers, 'None of above' is incorrect.
Concept tested: Secure backend authentication
Source: https://developer.hashicorp.com/terraform/language/settings/backends/configuration#sensitive-data-in-backend-configuration
Topics
Community Discussion
No community discussion yet for this question.