Comments (7)
Just FYI, the following patch to serverless
solved all my problems
diff --git a/node_modules/serverless/bin/serverless.js b/node_modules/serverless/bin/serverless.js
index b3f91c3..4a4b6fb 100755
--- a/node_modules/serverless/bin/serverless.js
+++ b/node_modules/serverless/bin/serverless.js
@@ -16,6 +16,12 @@ const nodeVersionMinor = Number(process.version.split('.')[1]);
const minimumSupportedVersionMajor = 12;
const minimumSupportedVersionMinor = 13;
+if (process.env.AWS_SDK_LOAD_CONFIG != '1') {
+ const { spawn } = require('child_process');
+ const args = [];
+ args.push(...process.execArgv, ...process.argv.slice(1));
+ spawn(process.argv[0], args, { stdio: 'inherit', env: { ...process.env, AWS_SDK_LOAD_CONFIG: '1' } });
+} else {
if (
nodeVersionMajor < minimumSupportedVersionMajor ||
(nodeVersionMajor === minimumSupportedVersionMajor &&
@@ -124,3 +130,4 @@ require('../lib/cli/triage')().then((cliName) => {
throw new Error(`Unrecognized CLI name "${cliName}"`);
}
});
+}
from serverless-better-credentials.
FWIW I have it set in my ~/.zshrc
, as it only comes back to bite you when you run javascript scripts using the aws-sdk
locally.
I get why they do it that way, although I appreciate it's confusing. There's a whole variety of fun flags &c. that exist surrounding credentials in AWS; scars from multiple design choices and workarounds and extensions throughout the ages.
For example - you can have named profiles in ~/.aws/credentials
(https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html); although most keys are technically only valid in the config file - but the javascript aws-sdk just treats them interchangeably. You can also specify where these files are using AWS_SHARED_CREDENTIALS_FILE
; and they all have random (/badly documentet) precedents.
Even worse - you shouldn't prefix the name of a profile with profile
if you want it to be read by the java aws-sdk, but if you don't you run in to problems other languages.
Like all good, old, evolving systems, it's a mess 😄 . My main aim with this plugin was just to make that mess consistent across the aws-sdk and serverless so people don't have to work around things twice.
from serverless-better-credentials.
Hmm - that is interesting because it is working for me.
➜ DP_STAGE=development AWS_PROFILE=iamadmin-general ../../node_modules/.bin/serverless info --verbose
✔ serverless-better-credentials: credentials resolved from config ini profile: AWS_PROFILE (iamadmin-general)
Something which I'm suspicious of - do you have AWS_SDK_LOAD_CONFIG
set in your enviornment?
Perhaps you could share the output of:
AWS_SDK_LOAD_CONFIG=1 AWS_PROFILE=profile1 sls info --verbose
from serverless-better-credentials.
Nope:
$ echo $AWS_SDK_LOAD_CONFIG
from serverless-better-credentials.
AWS_SDK_LOAD_CONFIG=1 AWS_PROFILE=profile1 sls info --verbose
correctly loads credentials.
from serverless-better-credentials.
Cool - then that explains it then.
AWS_SDK_LOAD_CONFIG
must be truthy if you're using a ~/.aws/config
file instead of the credentials file with any javascript tooling. (docs)
It is actually mentioned on the project readme:
Take note that if you are using SSO with the approach AWS document (a shared .aws/config file) you'll also need to set the AWS_SDK_LOAD_CONFIG enviornment value to something truthy (e.g. AWS_SDK_LOAD_CONFIG=1), as described in the AWS SDK documentation.
So I'm going to close this on a 'the simplest of documentation doesn't even get read' 😉 technicality.
Jokes aside - though - happy to take a PR if you have a better way of formatting the readme to make it more obvious to people who haven't encountered that quirk of the AWS + javascript toolkits before; StackOverflow attests to you not being the only one.
from serverless-better-credentials.
Ooof, it was probably created just to prevent nodejs servers from reading stuff in the filesystem.
We are talking about a cli tool, I cannot see how it shouldn't be always set to 1.
But ok. Thanks.
P.S. profiles always exist in ~/.aws/config
only.
from serverless-better-credentials.
Related Issues (20)
- Add support for serverless print HOT 3
- Unhelpful error when SSO session has expired HOT 5
- Error: Cannot find module '@serverless/utils/log' after installing and enabling HOT 4
- Plugin failed on EC2 with IAM Role HOT 4
- New AWS SSO config format HOT 8
- AWS-SDK v3 Compatibility HOT 3
- Error when trying to deploy dev branch with AWS Codepipeline HOT 3
- The installation command is incorrect HOT 3
- plugin breaks oidc auth Web Identity Provider authentication HOT 4
- Problems when using with serverless-domain-manager HOT 4
- Doesn't work since 1.2.0 HOT 8
- AWS SSO profile HOT 1
- plugin not working on aws with instance profile sourced temporary credentials HOT 6
- Add missing providers from the SDK default chain HOT 5
- enabled flag is not respected
- Support for aws-sdk v3 HOT 1
- Authentication fails on Mac M3 if `~/.aws/credentials` file is missing and valid SSO configuration exists in `~/.aws/config` HOT 1
- Error when invoking locally without credentials HOT 6
- Support Role profile with SSO profile as a source profile. HOT 16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serverless-better-credentials.