aws-amplify / amplify-backend

Home to all tools related to Amplify's code-first DX (Gen 2) for building fullstack apps on AWS
Apache License 2.0
185 stars 62 forks source link

Handle case when AWS region is configured as blank string #2206

Closed sobolk closed 2 weeks ago

sobolk commented 2 weeks ago

Problem

When

export AWS_REGION=""

And running

npx ampx sandbox --debug

CLI throws:

Error: expected `region` to be configured for `aws.auth#sigv4`
[DEBUG] 2024-11-06T22:20:26.927Z: Error: expected `region` to be configured for `aws.auth#sigv4`
    at /Users/sobkamil/playground/testapp059/node_modules/@aws-sdk/client-ssm/dist-cjs/auth/httpAuthSchemeProvider.js:11:23
    at Object.defaultSSMHttpAuthSchemeParametersProvider [as httpAuthSchemeParametersProvider] (/Users/sobkamil/playground/testapp059/node_modules/@aws-sdk/client-ssm/dist-cjs/auth/httpAuthSchemeProvider.js:12:15)
    at async /Users/sobkamil/playground/testapp059/node_modules/@smithy/core/dist-cjs/index.js:61:5
    at async /Users/sobkamil/playground/testapp059/node_modules/@aws-sdk/middleware-logger/dist-cjs/index.js:34:22
    at async FileWatchingSandbox.isBootstrapped (file:///Users/sobkamil/playground/testapp059/node_modules/@aws-amplify/sandbox/lib/file_watching_sandbox.js:241:46)
    at async FileWatchingSandbox.start (file:///Users/sobkamil/playground/testapp059/node_modules/@aws-amplify/sandbox/lib/file_watching_sandbox.js:87:30)
    at async Object.handler (file:///Users/sobkamil/playground/testapp059/node_modules/@aws-amplify/backend-cli/lib/commands/sandbox/sandbox_command.js:80:9)

Changes

Detect blank region and throw user error.

After change:

npx ampx sandbox --debug

...
InvalidCredentialError: The AWS region is blank
Resolution: Ensure that a valid AWS region is provided in profile configuration or AWS_REGION environment variable.

Validation

  1. Added test.
  2. Manual validation

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

changeset-bot[bot] commented 2 weeks ago

đŸ¦‹ Changeset detected

Latest commit: 4d18724f4399b170346c2f2fadfb64d1493e292e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------------------------ | ----- | | @aws-amplify/backend-cli | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR