To keep Terraform configuration secure, you shouldn't hardcode credentials. How can you securely provide your backend configuration using Terraform CLI?
Experience Level: Junior
Tags: Terraform
Answer
First insert the backend block into Terraform configuration. Don't provide credentials. Such setup is called Partial Configuration.
This way you can keep the configuration in version control without leaking sensitive information.
Later run terraform init -backend-config=PATH or terraform init -backend-config="KEY=VALUE"
This way you can provide the credentials on-demand.
Related Terraform job interview questions
Will 'terraform validate' raise error when you use both tabs and spaces in Terraform configuration?
Terraform JuniorWhat does 'terraform validate' command to in Terraform CLI?
Terraform JuniorShould you store the .terraform folder to version control?
Terraform JuniorWhat is stored in .terraform folder?
Terraform JuniorWhat is a default backend in Terraform?
Terraform Junior