In my terraform
directory I have several .tf
files among which:
vars.tf
variable "AWS_ACCESS_KEY" {}
variable "AWS_SECRET_KEY" {}
and terraform.tfvars
AWS_ACCESS_KEY="xxxxxxxxx"
AWS_SECRET_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
however,
$ terraform init
Initializing the backend...
Error configuring the backend "s3": No valid credential sources found for AWS Provider.
Please see https://terraform.io/docs/providers/aws/index.html for more information on
providing credentials for the AWS Provider
Please update the configuration in your Terraform files to fix this error
then run this command again.
Do I need to set them as env vars too?
Although the AWS provider picks up your environment variables automatically when you define the provider as provider "aws" {}
, it doesn't apply the same magic to looking up tfvars
.
In order to use the variables from vars.tf
you'll need to add those to your provider definition [1] :
provider "aws" {
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"
}
You can also use a shared credentials file if you'd prefer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.