localstack / localstack-demo

Simple demo application deployed using LocalStack
https://docs.localstack.cloud/getting-started/quickstart/
61 stars 33 forks source link

Deployment bucket error with new S3 provider #52

Closed joe4dev closed 1 year ago

joe4dev commented 1 year ago

Deployment through make deploy fails against the new S3 provider (PROVIDER_OVERRIDE_S3=v2) with the following error:

-------- Deployment Bucket Error --------
The specified location-constraint is not valid
Using custom endpoint for S3: http://127.0.0.1:4566
Creating deployment bucket 'localstack-test-bucket'...
Using custom endpoint for S3: http://127.0.0.1:4566

-------- Deployment Bucket Error --------
The specified location-constraint is not valid
Using custom endpoint for CloudFormation: http://127.0.0.1:4566
Using custom endpoint for S3: http://127.0.0.1:4566

✖ Stack demo1 failed to deploy (3s)
Environment: darwin, node 19.1.0, framework 3.23.0 (local) 3.27.0v (global), plugin 6.2.2, SDK 4.3.2
Credentials: Local, environment variables
Docs:        docs.serverless.com
Support:     forum.serverless.com
Bugs:        github.com/serverless/serverless/issues

Error:
Could not locate deployment bucket: "localstack-test-bucket". Error: The specified bucket does not exist

Starting point

This could be related to the patching of the LocationConstraint in serverless-localstack. We should probably also check the demo against AWS (see docs related to https://github.com/aws/aws-sdk-js/issues/3647), maybe the new S3 enforces parity related to this location constraint behavior.

joe4dev commented 1 year ago

This seems related to patchS3BucketLocationResponse() https://github.com/localstack/serverless-localstack/blob/master/src/index.js#LL512C3-L512C34

LocalStack returns a 400 (InvalidLocationConstraint) when using the us-east-1 region with the new S3 provider.

It is a well-known behavior of the S3 API leading to confusion because other regions than us-east-1 (default region) work well: