Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.

Unlimited Access

Get Unlimited Contributor Access to the all ExamTopics Exams!
Take advantage of PDF Files for 1000+ Exams along with community discussions and pass IT Certification Exams Easily.

Exam Terraform Associate topic 1 question 171 discussion

Actual exam question from HashiCorp's Terraform Associate
Question #: 171
Topic #: 1
[All Terraform Associate Questions]

Which provider authentication method prevents credentials from being stored in the state file?

  • A. Using environment variables
  • B. Specifying the login credentials in the provider block
  • C. Setting credentials as Terraform variables
  • D. None of the above
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Jayanth
Highly Voted 11 months, 2 weeks ago
D is the right answer. I tested in my local machine to create Sql server with 2 environment vaiables $env:TF_VAR_sql_admin = "username" and $env:TF_VAR_sql_password = "sqldbpassword" Also created the SQL Server with Terraform which accesses env variable during execution. BUT FOUND MY SENSITIVE ENVIRONMENT VARIABLE VALUES ARE STILL LISTED IN THE "STATE FILE" so answer should be "D"
upvoted 5 times
...
dzhang344
Most Recent 2 weeks ago
Selected Answer: A
When you use environment variables to store credentials, Terraform does not include these credentials in the state file. Environment variables are read at runtime, which means they are not persisted in the configuration files or the state file.
upvoted 1 times
...
abobeida94
1 month, 3 weeks ago
Selected Answer: A
Answer is A 100%: Using environment variables We already use Terraform this way: Bash export AWS_ACCESS_KEY_ID="YOUR_ACCESS_KEY" export AWS_SECRET_ACCESS_KEY="YOUR_SECRET_KEY" Terraform provider "aws" { access_key = "YOUR_ACCESS_KEY" secret_key = "YOUR_SECRET_KEY" }
upvoted 1 times
...
mattuyghur
4 months, 3 weeks ago
Selected Answer: A
Using environment variables
upvoted 1 times
...
Bere
5 months, 2 weeks ago
Selected Answer: D
1. Code example: ... resource "azurerm_sql_server" "example" { name = "example-sqlserver" resource_group_name = azurerm_resource_group.example.name location = azurerm_resource_group.example.location version = "12.0" administrator_login = var.sql_admin_username administrator_login_password = var.sql_admin_password } variable "sql_admin_username" {} variable "sql_admin_password" {} ... 2. Set env variables: export TF_VAR_sql_admin_username="adminuser" export TF_VAR_sql_admin_password="SuperSecretPassword" 3. terraform init 4. terraform apply 5. After applying, if you inspect the state file (terraform.tfstate), you will find that it contains the administrator login and password.
upvoted 1 times
...
frees
6 months, 3 weeks ago
Selected Answer: D
Terraform Enterprise and Terraform Cloud credentials are not stored in Terraform state or the CI/CD platform. Therefore, the correct answer to your question is D. None of the above.
upvoted 1 times
AndreiWebNet
5 months, 2 weeks ago
It doesn't say anything about Terraform Enterprise or Terraform Cloud. Its something you assumed. . .
upvoted 3 times
...
...
Ramdi1
7 months, 2 weeks ago
Selected Answer: A
nswer: using environment variables The only method list above that will not result in the username/password being written to the state file is environment variables. All of the other options will result in the provider's credentials in the state file. Terraform runs will receive the full text of sensitive variables, and might print the value in logs and state files if the configuration pipes the value through to an output or a resource parameter. Additionally, Sentinel mocks downloaded from runs will contain the sensitive values of Terraform (but not environment) variables. Take care when writing your configurations to avoid unnecessary credential disclosure. Whenever possible, use environment variables since these cannot end up in state files or in Sentinel mocks. (Environment variables can end up in log files if TF_LOG is set to TRACE.)
upvoted 1 times
...
akm_1010
11 months ago
Selected Answer: D
All secrets will end up in statefile.
upvoted 1 times
Alandt
5 months, 2 weeks ago
Your answer is right, but your explanation is not.
upvoted 1 times
...
Alandt
5 months, 2 weeks ago
Wrong. In terraform, are environment variables stored in state file? ChatGPT No, environment variables are not stored in the Terraform state file. The state file contains information about resources, not configuration values. Use environment variables or other secure methods to pass sensitive information during Terraform execution.
upvoted 2 times
...
...
Rajmane
11 months ago
Selected Answer: D
It's D only currently there is no way to prevent it
upvoted 2 times
...
Ha_Baruh_Architect13
11 months, 3 weeks ago
nothign prevents this, only thing is we can encrytp answer is D
upvoted 3 times
...
VSMu
11 months, 3 weeks ago
Selected Answer: D
Refer: https://developer.hashicorp.com/terraform/language/values/variables Setting a variable as sensitive prevents Terraform from showing its value in the plan or apply output, when you use that variable elsewhere in your configuration. Terraform will still record sensitive values in the state, and so anyone who can access the state data will have access to the sensitive values in cleartext. For more information, see Sensitive Data in State.
upvoted 2 times
...
[Removed]
1 year ago
Selected Answer: A
The answer is A. Using environment variables. Here is an example of how to use environment variables to provide authentication credentials for an AWS provider: provider "aws" { region = var.aws_region access_key_id = var.aws_access_key_id secret_access_key = var.aws_secret_access_key }
upvoted 1 times
...
Jhaggar
1 year, 1 month ago
Selected Answer: D
No, environment variables are not safe to store credentials in the state file of Terraform. Environment variables can be accessed by any process running on the same machine, including potentially malicious processes. It's important to use a secure method of storing credentials, such as using a secrets manager or key vault. Additionally, it's important to ensure that the state file itself is properly secured, either by encrypting it or by storing it in a secure location.
upvoted 2 times
...
OMERKENT
1 year, 1 month ago
I think correct answer is A. I have checked in my remote state file sitting in Azure storage account. (I used Azure DevOps environment variables) secret files are not visible in the state file.
upvoted 2 times
...
zanhsieh
1 year, 2 months ago
Selected Answer: A
Opt A. If you look into official terraform provider documentation, including terraform enterprise, all providers point to "Dynamic Provider Credentials". This workflow generally exposes a temporary OIDC compliment token as environment variable and authenticated by cloud providers. So I would say the straight forward answer would be environment variables.
upvoted 3 times
zanhsieh
1 year, 2 months ago
https://developer.hashicorp.com/terraform/enterprise/workspaces/dynamic-provider-credentials
upvoted 1 times
...
...
FarziWaliMarzi
1 year, 2 months ago
Selected Answer: D
Definitely "D", I wonder how A is the even an "authentication method"? Read the question carefully, or am I trying to read in between the lines?
upvoted 1 times
...
Stanislav4907
1 year, 3 months ago
Selected Answer: D
None of the above options prevents credentials from being stored in the state file. Storing credentials in Terraform code or environment variables is not recommended, as it can expose sensitive information and make it more difficult to manage and rotate credentials. Instead, you should use an external authentication method, such as the "external" authentication method in Terraform, which allows you to execute an external program to obtain authentication credentials at runtime, rather than storing the credentials in the state file. This method keeps your credentials secure and allows you to use authentication mechanisms that do not expose credentials in plain text or that require interactive authentication.
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
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.

SaveCancel
Loading ...
ex Want to SAVE BIG on Certification Exam Prep?
close
ex Unlock All Exams with ExamTopics Pro 75% Off
  • arrow Choose From 1000+ Exams
  • arrow Access to 10 Exams per Month
  • arrow PDF Format Available
  • arrow Inline Discussions
  • arrow No Captcha/Robot Checks
Limited Time Offer
Ends in