0
votes

Context :

  • I have set my aws credentials using aws configure.
  • I use terraform remote backend to store the terraform state

Using the following terraform configuration.

terraform {
 backend "remote" {
   hostname     = "app.terraform.io"
   organization = "test"

   workspaces {
     prefix = "networking-"
   }
 }
}

provider "aws" {
 region = "eu-west-3"
}

Problem: When I run terraform apply I have this error.

    ╷
    │ Error: 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
    │ 
    │   with provider["registry.terraform.io/hashicorp/aws"],
    │   on main.tf line 13, in provider "aws":
    │   13: provider "aws" {
    │ 
    ╵
1
Read this section of the documentation: registry.terraform.io/providers/hashicorp/aws/latest/… - Kay
Either ensure you have environnment variables set AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY,AWS_DEFAULT_REGION alternatively use credential file - Kay

1 Answers

0
votes

If you are using terraform cloud remote backend by default when you create a workspace, the terraform plan command in executed on the remote backend and not of your local machine. This is why, terraform can not find your credentials, because they are not set in the remote machine. To fix this problem, you need to order terraform to run the plan on your machine. To do so go in your workspace enter image description here then go in the general settings enter image description here then switch from remote execution mode to local enter image description here

Then try to run again your plan on your machine