Error: Provider configuration not present

Hello,

I am relatively new to terraform. I am in process or importing a production AWS account infrastructure to TF. Mostly it has been smooth but stuck at one issue where I have to import an S3 bucket which is in different region to all other resources.
TF version is 0.12.6
terraform -v
Terraform v0.12.6

I used following script to successfully import the s3 bucket resource
#!/bin/bash
instance=$1
provider=$2
resource_name=$3
resource_id=$4
version=0.12.5

init

docker run -it -w /infra/instances/instance \ -e "AWS_PROFILE=example-terraform" \ -v (pwd)/$instance:/infra/instances/instance \ -v (pwd)/…/modules:/infra/modules
-v $HOME/.aws/credentials:/root/.aws/credentials:ro
hashicorp/terraform:$version
init

import

docker run -it -w /infra/instances/instance \ -e "AWS_PROFILE=example-terraform" \ -v (pwd)/$instance:/infra/instances/instance \ -v (pwd)/…/modules:/infra/modules
-v $HOME/.aws/credentials:/root/.aws/credentials:ro
hashicorp/terraform:$version
import $provider $resource_name $resource_id

s3.tf file is in terraform/modules/platform/s3.tf and code for the particular bucket is

resource “aws_s3_bucket” “cloudtrail” {
provider = “aws.us_east_1”
region = “us-east-1”
bucket = “example123-cloudtrail”

tags = {
“Managed by” = “Terraform”

}
}

terraform/instances/applications/prod folder has these files
backend.tf
myplan
variables.tf
core.tf
providers.tf
terraform.tfvars

core.tf looks like this

module “platform” {
source = “…/…/…/modules/platform”

}

providers.tf look like this

provider “aws” {
region = “{var.region_name}" profile = "{var.profile_name}”

assume_role {
role_arn = “${var.role_production}”
}

version = “>= 0.12.5”
}

provider “aws” {
alias = “us_east_1”
region = “us-east-1”
profile = “${var.profile_name}”

assume_role {
role_arn = “${var.role_production}”
}

version = “>= 0.12.5”
}

I am using S3 backend for state file

When I am running terraform plan , I am getting following error

Error: Provider configuration not present

To work with module.platform.aws_s3_bucket.cloudtrail its original provider
configuration at module.platform.provider.aws.us_east_1 is required, but it
has been removed. This occurs when a provider configuration is removed while
objects created by that provider still exist in the state. Re-add the provider
configuration to destroy module.platform.aws_s3_bucket.cloudtrail, after which
you can remove the provider configuration again.

I am stuck here. Not sure what exact steps i should take to get out of this issue . I have tried removing the resource from state file but get error resource not found.

Help must be highly appreciated :slightly_smiling_face:

Many Thanks,

come on thats not a spam :slight_smile:

Hello , would it please be possible to get some help for above issue?