cycloidio / terracognita

Reads from existing public and private cloud providers (reverse Terraform) and generates your infrastructure as code on Terraform configuration
MIT License
2.2k stars 164 forks source link

`aws_s3_bucket`: Value for unconfigurable attribute `arn` and `hosted_zone_id` #378

Closed xescugc closed 1 year ago

xescugc commented 1 year ago

General information:

Describe the bug:

When importing aws_s3_bucket we get this errors:

Can't configure a value for "hosted_zone_id": its value will be decided automatically based on the result of applying this configuration.

or

Can't configure a value for "arn": its value will be decided automatically based on the result of applying this configuration.

Log message

Here you can paste the log message or paste the link to console logs. If the log message is too big, you can use a tool like https://pastebin.com/.

Additional context

Add any other context about the problem here.

mrslwiseman commented 1 year ago

@xescugc I am experimenting with terracognita and encountered the same issue you have also. From stack overflow, it appears theres some incompatibility with terracognita and v4+ of the AWS provider. I was able to import my s3 buckets by downgrading the version of the aws provider, modifying my hcl.tf file like so

provider "aws" {
}

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.74.1"
    }

  }

  required_version = ">= 1.0"
}
xescugc commented 1 year ago

That is actually really useful! I see the issue, on TC we are importing with the version we use internally, at this time AWS is 4.9.0, but we declare it without a version on the terraform block, so it pulls the latest version which may have in consistencies with the imported one, as is the case.

Actually righ now if we where to set the version of the imported one like:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "=4.9.0"
    }

  }

  required_version = ">= 1.0"
}

This works, so I'll make it so we add the specific version to the provider :).