sensedeep / dynamodb-onetable

DynamoDB access and management for one table designs with NodeJS
https://doc.onetable.io/
MIT License
690 stars 109 forks source link

"CredentialsProviderError: The SSO session associated with this profile has expired" in "overview" sample... #511

Closed busticated closed 12 months ago

busticated commented 1 year ago

hey there :wave:

thanks for this awesome lib - it's really making working w/ DynamoDB a joy šŸ™ ā¤ļø i'm trying to get my project up and running under DynamoDB Local for testing, etc. to that end, my first stop was to check out the samples in this repo.

Describe the bug

using the "overview" sample (link), i'm getting an odd error on start-up: "CredentialsProviderError: The SSO session associated with this profile has expired. To refresh this SSO session run aws sso login with the corresponding profile." given that this sample targets DynamoDB Local, i didn't think you needed to provide valid credentials - from docs:

The AWS SDKs for DynamoDB require that your application configuration specify an access key value and an AWS Region value. Unless you're using the -sharedDb or the -inMemory option, DynamoDB uses these values to name the local database file. These values don't have to be valid AWS values to run locally. However, you might find it convenient to use valid values so that you can run your code in the cloud later by changing the endpoint you're using.

edit: i should also note that i get this same error even after logging in using: aws sso login --profile <my-profile>

Error details (click to expand)

``` >>make run node dist/index.js CredentialsProviderError: The SSO session associated with this profile has expired. To refresh this SSO session run aws sso login with the corresponding profile. at resolveSSOCredentials (/Users/me/code/bust/dynamodb-onetable/samples/overview/node_modules/@aws-sdk/credential-provider-sso/dist-cjs/resolveSSOCredentials.js:33:15) at async /Users/me/code/bust/dynamodb-onetable/samples/overview/node_modules/@smithy/property-provider/dist-cjs/chain.js:12:33 at async coalesceProvider (/Users/me/code/bust/dynamodb-onetable/samples/overview/node_modules/@smithy/property-provider/dist-cjs/memoize.js:14:24) at async SignatureV4.credentialProvider (/Users/me/code/bust/dynamodb-onetable/samples/overview/node_modules/@smithy/property-provider/dist-cjs/memoize.js:33:24) at async SignatureV4.signRequest (/Users/me/code/bust/dynamodb-onetable/samples/overview/node_modules/@smithy/signature-v4/dist-cjs/SignatureV4.js:106:29) at async /Users/me/code/bust/dynamodb-onetable/samples/overview/node_modules/@aws-sdk/middleware-signing/dist-cjs/awsAuthMiddleware.js:16:18 at async /Users/me/code/bust/dynamodb-onetable/samples/overview/node_modules/@smithy/middleware-retry/dist-cjs/retryMiddleware.js:27:46 at async /Users/me/code/bust/dynamodb-onetable/samples/overview/node_modules/@aws-sdk/middleware-logger/dist-cjs/loggerMiddleware.js:7:26 at async Dynamo.send (file:///Users/me/code/bust/dynamodb-onetable/dist/mjs/Dynamo.js:82:16) at async Dynamo.createTable (file:///Users/me/code/bust/dynamodb-onetable/dist/mjs/Dynamo.js:19:16) { tryNextLink: false, '$metadata': { attempts: 1, totalRetryDelay: 0 } } ```

To Reproduce

using node@18.18.2 and npm@9.8.1 (the default that ships w/ v18 atm)...

repro steps:

  1. ensure you have fake aws_access_key_id and aws_secret_access_key key pairs set in your ~/.aws/credentials file
  2. clone down repo: $ git clone git@github.com:sensedeep/dynamodb-onetable.git
  3. check out the sha i used: $ git checkout 028a644711ad7bd42671531c965a2ff8b2861e37
  4. $ cd ./dynamodb-onetable/samples/overview
  5. install and build: $ make configure && make build
  6. run: $ make run

Expected behavior

Sample should run, tables and data should be created, logs should be printed to terminal

Environment (please complete the following information):

>>npm ls --depth=0
onetable-sample-overview@1.0.0 /Users/me/code/bust/dynamodb-onetable/samples/overview
ā”œā”€ā”€ @aws-sdk/client-dynamodb@3.458.0
ā”œā”€ā”€ @aws-sdk/util-dynamodb@3.458.0
ā”œā”€ā”€ aws-sdk@2.954.0
ā”œā”€ā”€ dynamo-db-local@4.0.2
ā”œā”€ā”€ dynamodb-onetable@2.7.1
ā””ā”€ā”€ typescript@4.3.5
busticated commented 1 year ago

looks like things work if i:

  1. manually set AWS env vars at the top of index.js like:
process.env['AWS_ACCESS_KEY_ID'] = 'fakeawsid'
process.env['AWS_SECRET_ACCESS_KEY'] = 'fakeawssecret'
  1. increase the delay() time to 5000 (5 sec) in index.js here

with the original 1s delay time, i ran into sporadic errors like:

Error: connect ECONNREFUSED 127.0.0.1:4567
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1555:16) {
  errno: -61,
  code: 'ECONNREFUSED',
  syscall: 'connect',
  address: '127.0.0.1',
  port: 4567,
  '$metadata': { attempts: 3, totalRetryDelay: 172 }
}

i'll pull together a PR with those + doc updates in case it's helpful.

mobsense commented 12 months ago

Thank you.