hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io
Other
42.77k stars 9.56k forks source link

[Bug]: s3 based terraform_remote_state not support ap-south-2 region #33349

Closed olfway closed 1 year ago

olfway commented 1 year ago

Terraform Core Version

1.4.6

AWS Provider Version

5.0.1

Affected Resource(s)

Expected Behavior

Terraform should be able to read s3 based remote state in ap-south-2 region

Actual Behavior

Terraform plan return invalid region error

Relevant Error/Panic Output Snippet

❯ terraform plan
data.terraform_remote_state.test: Reading...

Planning failed. Terraform encountered an error while generating this plan.
╷
│ Error: Invalid AWS Region: ap-south-2

Terraform Configuration Files

provider "aws" {
  profile = "india-hyd"
  region  = "ap-south-2"
}

data "terraform_remote_state" "test" {
  backend = "s3"
  config = {
    bucket = "test"
    key    = "test.tfstate"
  }
}

Steps to Reproduce

Run terraform plan with config above

It working if I add

skip_region_validation = true

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 1 year ago

Transferring to Terraform Core repository, since this relates to the S3 backend/terraform_remote_state.

amoldesai1993 commented 1 year ago

anyone working on this issue??

yushao2 commented 1 year ago

Ok so I have spent some time to trace the issue and it seems to be due to this dependency:

https://github.com/hashicorp/terraform/blob/main/go.mod#L31C1-L32C1

--> this is pinned to an old version v0.7.1 where it is reading regions from aws/aws-sdk-go which is further pinned to an older version where the region is not updated. https://github.com/hashicorp/aws-sdk-go-base/blob/v0.7.1/go.mod#L4

https://github.com/aws/aws-sdk-go/blob/v1.31.9/aws/endpoints/defaults.go#L19

The latest stable version seems to be v1.1.0 but it is still pointing to v1.31.9 which would still have the same issues (https://github.com/hashicorp/aws-sdk-go-base/blob/v1.1.0/go.mod)

v2 is still in beta -- theoretically upgrading the go.mod to v2 beta this should be fixed but I'm not too sure what the impact is at the moment

yushao2 commented 1 year ago

It looks only this module is ONLY used by the s3 backend component -- I am compelled to bump up the version of the module

image

gdavison commented 1 year ago

In the interim, the workaround is to set the backend config parameter skip_region_validation to true.

gdavison commented 1 year ago

This will be addressed in Terraform v1.6. If you still see this error when v1.6 is released (or you try any of the v1.6 beta releases), please open a new issue

github-actions[bot] commented 11 months ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.