localstack / localstack

💻 A fully functional local AWS cloud stack. Develop and test your cloud & Serverless apps offline
https://localstack.cloud
Other
53.1k stars 3.85k forks source link

bug: invalid AWS region name for s3 #11151

Closed afreisinger closed 1 week ago

afreisinger commented 1 week ago

Is there an existing issue for this?

Current Behavior

I am using tflocal with my localstack S3 instance but the console show me the follow error:

ValueError: 'aws-global' is not a valid AWS region name for s3 2024-07-07T20:50:05.506 INFO --- [et.reactor-1] localstack.request.aws : AWS s3.HeadBucket => 500 (InternalError)

Expected Behavior

No response

How are you starting LocalStack?

With the localstack script

Steps To Reproduce

localstack start -d tflocal init tflocal plan tflocal apply

Environment

- OS:osx
- LocalStack:
  LocalStack version:3.5.0 Profile default

Anything else?

provider.tf snnipet

provider "aws" {
  access_key                  = "test"
  secret_key                  = "test"
  skip_credentials_validation = true
  skip_metadata_api_check     = true
  alias                       = "main"
  region                      = "us-east-1"
  endpoints {
    acm                      = "http://localhost:4566"
    amplify                  = "http://localhost:4566"
    apigateway               = "http://localhost:4566"
    apigatewayv2             = "http://localhost:4566"
    appautoscaling           = "http://localhost:4566"
    appconfig                = "http://localhost:4566"
    appflow                  = "http://localhost:4566"
    appsync                  = "http://localhost:4566"
    athena                   = "http://localhost:4566"
    autoscaling              = "http://localhost:4566"
    s3                       = "http://s3.localhost.localstack.cloud:4566"
}

main.tf

resource "aws_s3_bucket" "website" {
  provider = aws.main
  bucket        = local.website_bucket_name
  force_destroy = var.website_bucket_force_destroy

  tags = merge({
    Name = "${var.name_prefix}-website"
  }, var.tags)
}
localstack-bot commented 1 week ago

Welcome to LocalStack! Thanks for reporting your first issue and our team will be working towards fixing the issue for you or reach out for more background information. We recommend joining our Slack Community for real-time help and drop a message to LocalStack Pro Support if you are a Pro user! If you are willing to contribute towards fixing this issue, please have a look at our contributing guidelines and our contributing guide.

lakkeger commented 1 week ago

Hi @afreisinger, Thanks for reaching out. This is a known "bug" introduced by the Terraform aws provider >5.55.0 and it seems it won't go away until >6.0.0 as it's part of their aws-go-sdk-v2 migration to fall back on a pseudo region called aws-global. As a temporary work around, please remove any . form your s3 bucket names and all should behave as expected. You can find the comment addressing the issue here: https://github.com/localstack/terraform-local/pull/57#issuecomment-2188342525

afreisinger commented 1 week ago

Thanks a lot @lakkeger, it worked for me ! Regards Adrian