-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Remove requirement for an existing AWS profile on sls package command #6564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
medikoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
@medikoo #6447 addresses a problem slightly different from this. Here, if the given serverless.yml file contains serverless.yml: |
medikoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@drexler great thanks for PR!
Still implementation as proposed removes validation step in its entirety, and we don't want to do that.
As I looked into code, the problem lies in this logic:
serverless/lib/plugins/aws/lib/validate.js
Lines 18 to 30 in babc140
| const creds = Object.assign({}, this.provider.getCredentials()); | |
| delete creds.region; | |
| delete creds.signatureVersion; | |
| if ( | |
| Object.keys(creds).length === 0 && | |
| !process.env.ECS_CONTAINER_METADATA_FILE && | |
| !process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI && | |
| !process.env.AWS_CONTAINER_CREDENTIALS_FULL_URI && | |
| ['logs', 'info', 'deploy', 'remove', 'rollback', 'metrics', 'invoke'].includes( | |
| this.serverless.processedInput.commands[0] | |
| ) && | |
| this.serverless.processedInput.commands[1] !== 'local' | |
| ) { |
Where first we check whether some AWS credentials are set (and eventually validate specified profile) and aftewards that we check does this validation step should occur for given command at all.
Real fix would be to check if command applies (and aborting eventually), before trying to retrieve AWS creds (with this.provider.getCredentials() involved)
Anyway I've also posted question here: #6536 (comment)
As I'd like to understand well, why we want to support keeping and invalid provider.profile setting in serverless.yml
|
@medikoo thought of that approach before i reached for the chainsaw solution... i'll update this PR |
6359a4b to
fbbbb2b
Compare
|
@medikoo updated the PR per your feedback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@drexler great that for update! Still it's not exactly best approach
Current situation is that we have folllowing logic(in simplified form):
creds = resolveEnvCreds()
if (hasCreds(creds) & isAppicableCommand()) ensureAwsCreds();And resolveEnvCreds() crashes for us (while isAppicableCommand() returns false). So valid solution is to improve logic seems as follows:
if (!isAppicableCommand()) return;
creds = resolveEnvCreds()
if (hasCreds(creds)) ensureAwsCreds();While what you propsed is:
if (!isAppicableCommandPartially()) return;
creds = resolveEnvCreds()
if (hasCreds(creds) & isAppicableCommand()) ensureAwsCreds();And that's not very clean (and prone to maintenance issues)
isAppicableCommand() is
serverless/lib/plugins/aws/lib/validate.js
Lines 26 to 29 in c4b7726
| ['logs', 'info', 'deploy', 'remove', 'rollback', 'metrics', 'invoke'].includes( | |
| this.serverless.processedInput.commands[0] | |
| ) && | |
| this.serverless.processedInput.commands[1] !== 'local' |
fbbbb2b to
6157177
Compare
pmuens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
medikoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@drexler thank you, looks great! Just one minor remark
6157177 to
5e425a7
Compare
medikoo
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @drexler !
We're taking this in
What did you implement:
Closes #6536
How did you implement it:
#6427 indirectly enforced a profile check on the
sls packagecommand. This removes the check since a profile not is needed by that commandHow can we verify it:
Todos:
Note: Run
npm run test-cito run all validation checks on proposed changesValidate via
npm testValidate via
npm run lint-updatedNote: Some reported issues can be automatically fixed by running
npm run lint:fixValidate via
npm run prettier-check-updatedNote: All reported issues can be automatically fixed by running
npm run prettify-updatedIs this ready for review?: Yes
Is it a breaking change?: NO