Remote Execution in Terraform Cloud

I tried to migrate my terraform state and code from my local machine to Terraform cloud , I have been able to migrate the state successfully but I’m unable to run Terraform plan or apply from the Terraform cloud and getting the below error , The same runs fine if I try to run locally and having the state file in the terraform cloud backend , below are the code snippets

terraform {

  backend "remote" {

    hostname     = "app.terraform.io"

    organization = "$$$$$$$$$"

    workspaces {

      name = "*******"

    }

  }

  required_providers {

    aws = {

      source  = "hashicorp/aws"

      version = "4.5.0"

    }

  }

}
provider "aws" {

  profile = "default"

  region  = "us-east-1"

}

provider "aws" {

  profile = "default"

  region  = "eu-west-1"

  alias   = "eu"

}
Error: error configuring Terraform AWS Provider: failed to get shared config profile, default
│
│   with provider["registry.terraform.io/hashicorp/aws"],
│   on providers.tf line 1, in provider "aws":
│    1: provider "aws"

Below Environment variables have been set in Terraform cloud

Hi @Sheshgiriv,

I think the problem here is that your configuration requests a named profile “default”, and named profiles always come from the credentials file in your home directory rather than from environment variables.

Since you will not have a credentials file in the Terraform Cloud execution environment, you could perhaps remove that argument from your configuration so that the provider can use the environment variables instead.

2 Likes

@apparentlymart Thanks for highlighting the profile issue , I’m able to run successfully after removing the profile attribute in provider section.