`Cannot read property 'getPromise' of undefined` when using Serverless ci/cd
Closed this issue · 1 comments
Describe the bug
When using Serverless's CI/CD feature to deploy, serverless-better-credentials raises a "TypeError: Cannot read property 'getPromise' of undefined" in the init method of the ServerlessBetterCredentials class. This happens even when serverless-better-credentials as the first plugin listed.
To Reproduce
Steps to reproduce the behavior:
- Set up serverless CI/CD following this guide: https://www.serverless.com/framework/docs/guides/cicd, but using the "automatic" setup for a provider
- Trigger an automatic deployment
- In the serverless dashboard, go to "ci/cd", click the most recent deployment, then navigate to the build log
- You should see the referenced error
Expected behavior
I expected the build to succeed and for serverless-better-credentials to not throw an error.
Desktop (please complete the following information):
- OS: linux
- Version: Not sure, whatever Serverless uses to deploy for their CI/CD pipeline
- Serverless Version: 3.15.2
Additional context
I think that when using the CI/CD pipeline, serverless may be initializing the provider.cachedCredentials variable (used in the getCredentials method) before serverless-better-credentials is able to. This leads to the cachedCredentials being returned before the getCredentials method can format it, so it is not in the structure expected by the ServerlessBetterCredentials init method.
Hi - thanks for reporting.
I don't actually use serverless for deployment - but I think you're analysis is right, they're making use of the (also) undocumented cachedCredentials
property to override the default resolution mechanism.
serverless-better-credentials@1.1.2
should fix this.
I've put a guard in, and a warning. This does mean that you won't get serverless-better-credentials
resolution when you run it in the serverless ci/cd pipeline, but presumably this is OK because they're already taking control of the credential resolution...