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?
A.
Pass variables to Terraform with a ג€"var flag
B.
Copy the sensitive variables into your Terraform code
C.
Store the sensitive variables in a secure_vars.tf file
D.
Store the sensitive variables as plain text in a source code repository
The safest method to inject sensitive variables into your Terraform run in a CI/CD pipeline is:
A. Pass variables to Terraform with a -var flag.
When running Terraform in your CI/CD pipeline, you would pass the sensitive variables like this:
terraform apply -var="database_password=mysecretpassword" -var="api_key=1234567890abcdef"
For enhanced security, in a CI/CD environment, you'd typically use environment variables or secret management tools that are supported by your CI/CD platform to pass these sensitive values, so they are never exposed in logs or stored in insecure locations.
For instance, using environment variables:
export TF_VAR_database_password=mysecretpassword
export TF_VAR_api_key=1234567890abcdef
terraform apply
The safest option among the choices provided is to use the -var flag to pass sensitive variables to Terraform. This allows you to provide variable values at runtime without hardcoding them directly into the Terraform code or exposing them in the source code repository.
A. Pass variables to Terraform with a "var" flag.
When running Terraform in a CI/CD pipeline, it is important to securely pass sensitive variables to Terraform. One way to pass sensitive variables to Terraform is to use the -var flag to supply the value of the variable at runtime.
A is correct answer : -var
See Topic 1 # Question 43
https://blog.gruntwork.io/a-comprehensive-guide-to-managing-secrets-in-your-terraform-code-1d586955ace1
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.
Bere
Highly Voted 1 year, 3 months agorfd
Highly Voted 2 years, 5 months agoakki_0108
Most Recent 2 months agosamimshaikh
10 months, 4 weeks agoTlakmini
1 year, 3 months agocloudznj
1 year, 4 months agoLunarPhobia
1 year, 3 months agoFaaizz
1 year, 7 months agocamps
1 year, 7 months agoPower123
1 year, 7 months agothor7
1 year, 7 months agoeduvar4
2 years, 1 month agotf_user
2 years, 2 months agoTomcrui1234589
2 years, 3 months agoAhmad_Terraform
2 years, 4 months agoEltooth
2 years, 4 months agobp339
2 years, 5 months agobiscuithammer
2 years, 6 months ago