nerdexam
HashiCorp

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.

Implement and maintain state

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)
  • A
    94% (29)
  • C
    3% (1)
  • D
    3% (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.

ADefined in Environment variablesCorrect

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.

BInside the backend block within the Terraform configuration

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.

CDefined in a connection configuration outside of Terraform

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.

DNone of above

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

#Secrets management#Remote backend#Security best practices#Environment variables

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice