1. HashiCorp Terraform Documentation
"Sensitive Input Variables": This document explicitly states
"Terraform will still record the value in the state file
and so anyone who can access the state data will have access to the sensitive values in cleartext." This directly refutes the effectiveness of option C for preventing storage in the state file. (Source: HashiCorp
Terraform Documentation
docs/language/values/variables.md
Section: "Sensitive Input Variables").
2. HashiCorp Terraform Documentation
"Provider Configuration": This page recommends against hardcoding credentials (Option B) and suggests environment variables as a preferred alternative. It states
"Hard-coding credentials into any Terraform configuration is not recommended... we recommend using environment variables where possible for the provider's credentials." This separation is key to why the credentials don't end up in the state. (Source: HashiCorp
Terraform Documentation
docs/language/providers/configuration.md
Section: "Provider Configuration").
3. HashiCorp Terraform Documentation
AWS Provider
"Authentication and Configuration": The documentation for specific providers
such as AWS
details the credential lookup order. Environment variables are a standard method where the provider's underlying SDK (e.g.
AWS SDK) reads the credentials from the environment. This process happens within the provider
outside of the configuration values that Terraform itself persists to the state file. (Source: HashiCorp
Terraform Registry
providers/hashicorp/aws/latest/docs
Section: "Authentication and Configuration").