nerdexam
HashiCorp

TA-002-P · Question #70

You're building a CI/CD (continuous integration/ continuous delivery) pipeline and need to inject sensitive variables into your Terraform run. How can you do this safely?

The correct answer is B. Copy the sensitive variables into your Terraform code. Securely injecting sensitive variables into a Terraform run in a CI/CD pipeline often involves integrating with a dedicated secrets management solution.

Read, generate, and modify configuration

Question

You're building a CI/CD (continuous integration/ continuous delivery) pipeline and need to inject sensitive variables into your Terraform run. How can you do this safely?

Options

  • APass variables to Terraform with a 璿ar flag
  • BCopy the sensitive variables into your Terraform code
  • CStore the sensitive variables in a secure_vars.tf file
  • DStore the sensitive variables as plain text in a source code repository

How the community answered

(46 responses)
  • A
    2% (1)
  • B
    85% (39)
  • C
    4% (2)
  • D
    9% (4)

Why each option

Securely injecting sensitive variables into a Terraform run in a CI/CD pipeline often involves integrating with a dedicated secrets management solution.

APass variables to Terraform with a 璿ar flag

Passing variables with a `-var` flag directly on the command line is generally insecure for sensitive data, as values can be exposed in shell history, process lists, or logs.

BCopy the sensitive variables into your Terraform codeCorrect

By "copying sensitive variables into your Terraform code," the question implies leveraging Terraform's ability to fetch sensitive data from external, secure secrets management services (like HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, or GCP Secret Manager) using data sources. This method embeds references to secrets in the HCL code, allowing Terraform to retrieve the actual sensitive values at runtime without ever storing them in plaintext within the configuration files or version control.

CStore the sensitive variables in a secure_vars.tf file

Storing sensitive variables in a `secure_vars.tf` file is insecure if the file is committed to version control in plaintext, as `.tf` files are typically part of the configuration repository.

DStore the sensitive variables as plain text in a source code repository

Storing sensitive variables as plain text in a source code repository is a fundamental security anti-pattern and highly insecure, exposing secrets to anyone with access to the repository.

Concept tested: Secure handling of sensitive data in Terraform

Source: https://developer.hashicorp.com/terraform/language/values/variables#sensitive-variables

Topics

#Sensitive variables#Secrets management#CI/CD#Configuration security

Community Discussion

No community discussion yet for this question.

Full TA-002-P Practice