Terraform Associate Exam QuestionsBrowse all questions from this exam

Terraform Associate Exam - Question 76


Which of these options is the most secure place to store secrets foe connecting to a Terraform remote backend?

Show Answer
Correct Answer: C

The most secure place to store secrets for connecting to a Terraform remote backend is by defining them in a connection configuration outside of Terraform. Utilizing secret management tools such as HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault provides higher security through access control and encryption mechanisms. By keeping secrets outside of the Terraform configuration, it minimizes the risk of exposing sensitive information in configuration files or environment variables, which could be inadvertently exposed or shared.

Discussion

57 comments
Sign in to comment
zyxphreezOption: A
Aug 24, 2022

Definitely is: A https://www.terraform.io/language/settings/backends/configuration#credentials-and-sensitive-data Warning: We recommend using environment variables to supply credentials and other sensitive data. If you use -backend-config or hardcode these values directly in your configuration, Terraform will include these values in both the .terraform subdirectory and in plan files. This can leak sensitive credentials.

deepeshukla
Jun 26, 2023

I will select C. In option A, any debugging will still disclose data.

Gomjaba
Sep 9, 2023

I presume they are hinting at vault here.

Gomjaba
Sep 9, 2023

I presume they are hinting at vault here.

Alandt
Jan 23, 2024

Authentication outside of Terraform is more secure than environment variables. Your environment variables can still refer to a file or the definition of your variables inside terraform. So I would go for C.

CHRIS12722222Option: C
Jul 29, 2022

I will go for option C. Whenever possible, it is best to authenticate outside of terraform to keep secrets out of state file

Alandt
Jan 25, 2024

I agree with this.

Fatoch
Oct 30, 2022

A or C ?

ARJUNKMUKUNDAN
Mar 22, 2023

A will be the correct answer.

gofavad926Option: C
Sep 29, 2023

C. Defined in a connection configuration outside of Terraform The most secure place to store secrets for connecting to a Terraform remote backend is typically outside of the Terraform configuration, and it's often done in a separate connection configuration or configuration file. This helps in keeping sensitive information, such as access keys or authentication tokens, separate from the main Terraform configuration.

Venki_devOption: C
Apr 19, 2024

C. Defined in a connection configuration outside of Terraform (Most Secure) This is the most secure option. Here, you store your secrets in a separate dedicated location outside of your Terraform configuration. There are several ways to achieve this: Secret Management Tools: Utilize tools like HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault to store and manage your secrets securely. These tools offer access control and encryption mechanisms. Encrypted Files: Store secrets in an encrypted file outside your Terraform configuration directory. Terraform can access these secrets during execution by referencing the decrypted content of the file.

Zam88
Jun 19, 2022

A is correct

kcw6Option: C
Aug 4, 2022

I think it is C because it is for "Terraform remote backend" and I am sure of how to apply the environment variables to it.

ChokiesOption: A
Sep 8, 2022

Connection block is for provisioners.

BaburTurkOption: C
Aug 25, 2023

he answer is C. Defined in a connection configuration outside of Terraform. Secrets should never be stored in the Terraform configuration file itself, as this file is often checked into version control. This means that anyone with access to the code could also access the secrets. The best practice is to define secrets in a separate connection configuration file, which is then referenced by the Terraform configuration file. This connection configuration file can be stored in a secure location, such as a password manager or a secrets management service. Storing secrets in environment variables is also a good option, as environment variables are not stored in the Terraform configuration file. However, it is important to make sure that the environment variables are only accessible to trusted users. Storing secrets in the backend block within the Terraform configuration is not recommended, as this makes the secrets more accessible to unauthorized users.

satamex
Oct 17, 2023

Badly formed question, but I would go with C.

samimshaikhOption: C
Dec 29, 2023

C. Defined in a connection configuration outside of Terraform The most secure option for storing secrets for connecting to a Terraform remote backend is to define them in a connection configuration outside of Terraform. This involves using external configuration files or secure credential management tools. Option A (defined in environment variables) is also a good practice for sensitive information, but it might be less secure than an external configuration file if, for example, there is a risk of exposing environment variables. Option B (inside the backend block within the Terraform configuration) is generally not recommended for storing sensitive information like secrets because Terraform configuration files may be versioned and shared, posing a security risk. Therefore, when dealing with sensitive information, it's a good practice to use external and secure methods for configuration, such as a separate configuration file or a secure credential management tool.

EltoothOption: A
Jun 28, 2022

D would be most secure by using 3rd party keyvault tools and .var calls from within code. However A is best option to pass an secret/password using the -var switch.

yogishrb2020
Oct 8, 2022

Connection configuration only for login details.

crickmeisterOption: C
Feb 16, 2023

The most secure place to store secrets for connecting to a Terraform remote backend is option C, defined in a connection configuration outside of Terraform. It is generally not recommended to store secrets or sensitive information in the Terraform configuration or environment variables as they can be easily exposed or accidentally checked into version control. Instead, a more secure option is to store secrets in an external configuration file or secure credential storage service, and reference it in your Terraform configuration. This can include using tools like HashiCorp Vault or AWS Secrets Manager to manage and retrieve secrets at runtime. Therefore, option C, defined in a connection configuration outside of Terraform, is the most secure option for storing secrets for connecting to a Terraform remote backend.

Yazn
Apr 1, 2023

C. I think most people got confused by the term connection configuration. It refers to the configuration settings that can be initiated in the cloud CLI outside Terraform, like aws CLI. It is definitely more secure than the environment variables which is available to everyone. The CLI needs login to be accessed and storing the secrets as config values in it adds a new layer of security.

sylvergorillaOption: C
Apr 14, 2023

Storing secrets for connecting to a Terraform remote backend in a password manager or a secure key-value store such as HashiCorp Vault is considered best practice. Avoid storing secrets in plain text files or environment variables.

kiran15789Option: C
May 7, 2023

By storing secrets outside of the Terraform configuration and providing them through a separate, secure channel, you can help ensure that sensitive data remains secure and is not accidentally exposed or shared with others.

Ni33Option: C
May 9, 2023

C is the correct option

sdm13168Option: C
May 18, 2023

C is the most secure way

raf123123Option: C
May 24, 2023

Answer: C

[Removed]Option: C
Jun 29, 2023

Ans A is also a possible choice. However, the recommended will be using HashiCorp Vault. https://developer.hashicorp.com/well-architected-framework/security/security-sensitive-data

BereOption: A
Aug 16, 2023

Answer: A. Defined in Environment variables Storing secrets in environment variables is a common best practice. Environment variables keep the secrets out of the code and state files. C. Defined in a connection configuration outside of Terraform: This method can be ambiguous. Depending on the mechanism, it might be secure, but without specifics, it's hard to definitively say it's the "most secure."

Ramdi1Option: A
Nov 21, 2023

This extract is taken from another course on Udemy with explanation 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.)

enookOption: C
Jan 18, 2024

Chat GPT: The most secure option for storing secrets for connecting to a Terraform remote backend is typically: C. Defined in a connection configuration outside of Terraform Storing sensitive information, such as authentication credentials, outside of the Terraform configuration helps enhance security by preventing accidental exposure or leakage of sensitive data. Using external tools or configuration management systems to manage secrets can provide additional layers of security and access control. It is generally not recommended to store sensitive information directly within the Terraform configuration (option B) to minimize the risk of inadvertent exposure. Additionally, environment variables (option A) can be a good practice for storing secrets securely, but they need to be managed carefully to avoid unintended exposure.

kingfighers
Apr 3, 2024

choose A: when we use vault, we still need to download it into a file,here is official doc: - **File**: A configuration file may be specified via the `init` command line. To specify a file, use the `-backend-config=PATH` option when running `terraform init`. If the file contains secrets it may be kept in a secure data store, such as [Vault](https://www.vaultproject.io/), in which case it must be downloaded to the local disk before running Terraform. https://developer.hashicorp.com/terraform/language/settings/backends/configuration#credentials-and-sensitive-data

deepakpamban
May 4, 2024

Option C

SureNotOption: C
Jun 11, 2024

Let's imagine use AWS S3 bas a backend. Credentials to S3 Bucket are stored in ~/.aws/credentials file - Outside of terraform, most secure way.

premnick
Jul 27, 2024

Question is which one is MOST secure. Environment variable is not secure. You type env command from the host and easily view the secret value.

Aws2222
Jul 26, 2022

D. https://www.terraform.io/language/state/sensitive-data

RVivekOption: A
Sep 23, 2022

A -- This is possible under workspace configuration on Terraform Cloud or enterprise B-- Including the crdential on the code is not secured C - Configuring it outside terraform on Terraform Cloud or enterprise. Not sure how to do that D. -- The question says Which of these options and A is the option

TechHero
Jan 18, 2023

Storing secrets, such as access keys for a Terraform remote backend, in environment variables or within the Terraform configuration file can make them vulnerable to exposure through processes such as version control or system backups. A more secure option would be to use a secure secrets management solution, such as Hashicorp Vault, and retrieve the secrets dynamically at runtime. Another option would be to use a connection configuration outside of Terraform with proper access controls and encryption.

agmesasOption: A
Feb 6, 2023

really I dont understand the question. In AWS is not necessary to configure secrets for remote backend connection in backend block. In this case A is correct , set AWS_ACCESS and secret as Environment Variable a run terraform plan

iulitruli
Mar 1, 2023

ChatGPT said it is C

NunyabiznesOption: A
Mar 24, 2023

The most secure place to store secrets for connecting to a Terraform remote backend among the given options is: A. Defined in Environment variables Storing secrets in environment variables is more secure than putting them directly in the Terraform configuration, as it prevents sensitive data from being accidentally committed to a version control system. Environment variables are not stored in the Terraform code, and they can be set securely at runtime, making it more difficult for unauthorized users to access the secrets. However, an even more secure solution would be to use a secrets management system like HashiCorp Vault or AWS Secrets Manager to store sensitive data. This allows you to centralize your secret management, enforce access control, and provide an audit trail for secret access.

campsOption: C
Mar 31, 2023

C. Defined in a connection configuration outside of Terraform. It is important to store secrets securely when connecting to a Terraform remote backend. A remote backend is a way to store Terraform state in a central location, which allows for collaboration and ensures consistency between runs. Terraform supports multiple remote backend types, including Amazon S3, Azure Blob Storage, and HashiCorp Consul.

Stanislav4907Option: D
Apr 7, 2023

Storing secrets in environment variables is a common practice, but it may not always be the most secure option. Environment variables can be accessed by any application running on the same machine or system, which could potentially compromise the security of the secrets. The best option for storing secrets for connecting to a Terraform remote backend is to use a dedicated password manager or secret management tool, such as HashiCorp Vault or AWS Secrets Manager. These tools provide additional security features such as encryption, access controls, and audit logs, and are specifically designed for securely storing and managing secrets. Therefore, the correct answer is D. None of the above options are the most secure place to store secrets for connecting to a Terraform remote backend.

icecoolcat
May 13, 2023

It is C. A is the second most secure way.

March2023Option: A
Jun 12, 2023

going with A

Jlee7
Jun 26, 2023

Correct Answer is C. A would be the second option if the question is asking to select TWO answers

SairamObili
Aug 15, 2023

you should authenticate outside of terraform first, example if you are running the pieplines giving access to specific account using an SPN in Azure and the next option would be environmental variables option C

Spandrop
Aug 31, 2023

I would go with A (external) connection configuration could be several things like a JSON FILE (which is not secure at all) and also includes the environment variables. The way that it was wrote, connection configuration, is to much a generic statement.

dn_mohammed_dataOption: A
Sep 26, 2023

A is correct

[Removed]
Nov 27, 2023

It is C

TigerInTheCloudOption: A
Dec 19, 2023

https://developer.hashicorp.com/terraform/language/settings/backends/configuration Warning: We recommend using environment variables to supply credentials and other sensitive data. If you use -backend-config or hardcode these values directly in your configuration, Terraform will include these values in both the .terraform subdirectory and in plan files. This can leak sensitive credentials.

[Removed]Option: D
Dec 20, 2023

It seems to be D

vipulchoubisa
Jan 9, 2024

Warning: We recommend using environment variables to supply credentials and other sensitive data. If you use -backend-config or hardcode these values directly in your configuration, Terraform will include these values in both the .terraform subdirectory and in plan files. This can leak sensitive credentials. ANSWER SHOULD BE "A"

parag09Option: A
Jan 11, 2024

The most secure place to store secrets for connecting to a Terraform remote backend is typically defined in environment variables.

AlandtOption: C
Jan 23, 2024

Definitely C. Authentication outside of Terraform is the most secure way.

Kaname93Option: A
Feb 26, 2024

From the documentation : Warning: We recommend using environment variables to supply credentials and other sensitive data. If you use -backend-config or hardcode these values directly in your configuration, Terraform will include these values in both the .terraform subdirectory and in plan files. This can leak sensitive credentials. So it's A

AntonyPeter7Option: C
Mar 3, 2024

Authentication outside of Terraform is more secure than environment variables. Like using terraform vault or cloud

aksliveswithawsOption: A
Apr 1, 2024

https://developer.hashicorp.com/terraform/language/settings/backends/configuration#credentials-and-sensitive-data:~:text=and%20apply%20steps.-,backend%20types,-The%20block%20label

Molly1994
Jun 5, 2024

C vault as example

AlgolOption: A
Sep 12, 2024

The most secure option for storing secrets when connecting to a Terraform remote backend is A. Defined in environment variables. This approach keeps sensitive information, such as API keys or access tokens, out of your version-controlled configuration files. Defining secrets in environment variables reduces the risk of accidental exposure or leakage through your Terraform configuration. Using external secret management tools (like HashiCorp Vault) to manage environment variables can further enhance security.

Dimedrol1
Oct 29, 2024

I've answered D - "None of the above", because the most secure way is e.g. Azure Key Vault, when working with Azure, of course. In this case - we're not revealing any of the secrets values. Terraform can refer them via "data" operators. (and, yes, this approach is not a "connection configuration")

suri_surendraOption: A
Dec 29, 2024

The correct answer is: A. Defined in Environment variables Explanation: When storing secrets for connecting to a Terraform remote backend, environment variables are the most secure option. Here's why: Environment Variables: Secure: Environment variables can be securely managed outside of Terraform configuration files and are not checked into version control. Flexibility: You can use tools like HashiCorp Vault, AWS Secrets Manager, or Azure Key Vault to inject secrets as environment variables dynamically. Common Practice: Many services (e.g., AWS, Azure, Google Cloud) support using environment variables for storing sensitive credentials like access keys, secret keys, and tokens.

Asif_draxiOption: A
Jan 17, 2025

The correct answer is **A. Defined in Environment variables**. Environment variables are considered the most secure place to store secrets for connecting to a Terraform remote backend because: - They keep sensitive information out of source control (such as in `.tf` files or other configuration files). - Secrets stored in environment variables can be managed securely by the operating system or deployment environment and can be encrypted or otherwise protected. Storing secrets inside the backend block (option B) or in a connection configuration outside Terraform (option C) can expose them to version control or make them less secure. Therefore, it's best practice to use environment variables for storing sensitive credentials securely.

KG8Option: A
Mar 7, 2025

https://developer.hashicorp.com/terraform/language/backend Warning: We recommend using environment variables to supply credentials and other sensitive data. If you use -backend-config or hardcode these values directly in your configuration, Terraform will include these values in both the .terraform subdirectory and in plan files. This can leak sensitive credentials.