-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Support for credential_process in ~/.aws/config #4838
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
Comments
Just needs to be merged aws/aws-sdk-js#1923. Then we can implement it on serverless |
This has been merged in aws/aws-sdk-js#2559 and is available with aws-sdk-js v2.474.0 through v2.429.0 Would appreciate if this got picked up. |
- This only affects the aws provider - Resolves [Issue serverless#4838](serverless#4838) - Retrieving credentials from the AWS provider is now an asynchronous process
- This only affects the aws provider - Resolves [Issue serverless#4838](serverless#4838) - Retrieving credentials from the AWS provider is now an asynchronous process
It would be lovely to see this progress again (sorry I can't help at the moment). Currently I have to keep switching my config files between using |
Just another +1.
At the moment I'm trying to understand why the serverless framework uses it's own approach to credentials; which seems to be the reason that |
but seriously, why aren't we using the default CredentialProviderChain ?? https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CredentialProviderChain.html |
@flyinprogrammer - I'm actually trying to get together a PR to see about using it. However, because sls hasn't used the default chain, there's a few additional cases I'm working through. For comment, it's looking something like this: // Tweak the default provider chain to match serverless extensions:
// https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/CredentialProviderChain.html#defaultProviders-property
const credentialProvider = new AWS.CredentialProviderChain([
function () { return new AWS.EnvironmentCredentials('AWS'); },
function () { return new AWS.EnvironmentCredentials('AMAZON'); },
// add serverless specific AWS_${STAGE} environment
function () { return new AWS.EnvironmentCredentials(environment); },
// prefer serverless configured profile and readline token fn for ini:
function () { return new AWS.SharedIniFileCredentials({ profile, tokenCodeFn, filename }); },
// function () { return new AWS.ECSCredentials(); }
// prefer serverless configured profile for process:
function () { return new AWS.ProcessCredentials({ profile }); },
// function () { return new AWS.TokenFileWebIdentityCredentials(); },
// function () { return new AWS.EC2MetadataCredentials(); }
// support serverless config credentials
function () { return new AWS.Credentials(providerCredentials) },
]); |
Looking for feedback on a first pass at using the provider chain here: https://github.com/dougmoscrop/serverless/commit/49cd19aa4b1954aa0441fbebeca8e9291bf635fe |
Is there any workaround currently for using AWS SSO until this is done? |
If you've only got one profile, you can use this: https://github.com/benkehoe/aws-export-credentials |
@drissamri i've been using aws-vault like so:
which just causes sls to rely on environment variables existing. |
@thomasmichaelwallace I installed
To use:
|
☝️ it's an interesting solution - the main struggle we have is that we rely on I'm actually planning on picking up @dougmoscrop 's implementation and working that into a PR today. So hopefully native serverless support for this is in the future... |
☝️ watch this space. |
So - there's quite a lot of refactoring planned for/around the files that need to be touched by this PR. Unfortunately I don't have the time to look at these (#8441, #8444, #8445, #8446 - for anyone that does.) Once they're clear I'll come back and get the PR back up off the ground again. I need this feature, now, however, and so I'll be maintaining a patch with the core (support for For anyone else who wants to use this patch in the interim - I'll be maintaining it (with some instructions) here: https://gist.github.com/thomasmichaelwallace/5ef97b1fbadf8df2bca21bebafd2dd7e |
For reference: Work on that has been started here: #8415 which was closed temporarily, until dependent issues, as listed below are addressed
Any help is addressing above will be appreciated |
For anyone following - I did a resync of my patch to the latest (v2.30.3) version, While I've got everything back in sync - @medikoo - is the plan still to block on the issues mentioned in November? |
@thomasmichaelwallace yes I believe nothing changed, to welcome this enhancement safely, first we need to improve our tests (it's quite sensitive change) |
And again - re-synced for v2.61.0 for those who want to try the new ARM lambdas (patch-package compatible .patch here) @medikoo - I see that the majority of the issues that were blocking this becoming a PR again are solved. Is it worth submitting this patch as a PR? It's also worth appreciating that the assumption the serverless framework currently makes about AWS credentials (that they are synchronous and static) isn't true, and the majority of work I do when re-syncing the fixes is to refactor the tests to reflect this (see my branch ./test/unit/lib/plugins/aws/provider.test.js). |
@thomasmichaelwallace as problem with AWS credentials resolution in Framework is bigger than simply lack of support for Any help in driving that forward is ofc welcome, still as it touches sensitive parts, it needs to be done with care, and best if no implementation happens until we have full agreement on spec level. |
@medikoo is there nothing I can say/do to convince you otherwise? AWS SSO is nearly 4 years old now.
#9290 looks great (I'm sure people had their reasons, but I've also found it weird that Serverless has its own credentials resolution process) but also looks abandoned with no action for over a month, and no discussion. More worryingly it looks like it would result in a set of breaking changes that would be gated behind a major release, and it doesn't look like it'd be in time for v3. Although you will know much the roadmap better than I, it seems a fair bet that waiting for v4 means this issue (that has a solution) remains open for at least another year... n.b. As it happens the approach used does address a lot of the points in #9290 as it uses the |
It's been years and standard AWS credentials support is still broken :/ I appreciate all the hard work the maintainers have been putting into the project, but I wish one of them had to deal with this issue so they would realize how much time it is wasting for many users of the tool |
In case it hasn't been mentioned, you can use awsume as a workaround for this. It supports credential_process and will set the env vars for serverless to pick up when run. |
Similarly I'll be upgrading my patch for v3 some time next week. It makes Serverless re-use the standard aws-sdk credential chain (rather then their own one). This does has the advantage of enabling I admit I prefer the patch over using awsume because I need to do a lot of profile switching and it lets me use Honestly, I don't think they'll be any appetite for it, but I can try and post it as a PR for #9290. |
Hey everyone, just wanted to reassure you that we are aware of this issue, and that we are keeping this in mind in our roadmap. Unfortunately breaking the current behavior is hard, but we have ideas for our roadmap and we are actively trying to imagine how this issue would fit into it. To be transparent and honest, this is for the long term, don't expect a resolution in the coming weeks. But we are thinking about this. |
so In the interim I give you all the
https://github.com/thomasmichaelwallace/serverless-better-credentials (n.b. this does mean that I won't be maintaining the patch any more, but hopefully the plugin will be ~x1000 more accessible to people.) |
I am really struggling with this issue. Hope this issue is resolved and realeased ASAP. My profile: [profile myprofile]
region = 'us-west-2'
output = 'json'
credential_process = 'mycli jit aws' With this var set for the specific workspace: export AWS_CONFIG_FILE="${CONF_DIR}/aws" I can't seem to escape this error:
For compliance reasons, I can't make an IAM user let alone long lived credentials. Seems like serverless really wants the access key and secret key. So I try this to set those env vars using a temp IAM sesion: for i in `mycli jit aws -q '{AWS_ACCESS_KEY_ID: AccessKeyId, AWS_SECRET_ACCESS_KEY: SecretAccessKey, AWS_SESSION_TOKEN: SessionToken, AWS_REGION: Region}' -o env`; do export $i; done This still doesn't work. It kind of seems it does not support the session token maybe, or does it not support using env vars? Maybe because I didn't put it in the aws credentials file? If so can I at least set Then I tried using What am I missing here? I'm kind of sick of trialing and erroring something that should be trivial. Edit: I think I found the issue. My global version was different than what was in package.json. Does the newer version actually support all of this? If so why is this issue still open? Edit: Newer version does. Why is this still open? Hope customer doesn't mind upgrading. |
Hey everyone, closing this as Serverless Framework v4 uses the default AWS credential provider chain, which includes support for Thanks to everyone who contributed and shared workarounds here! |
This is a Feature Proposal
Description
AWS CLI supports the credential_process option in ~/.aws/config profiles, which allows you to store credentials somewhere else than the plain ~/.aws/credentials file. For instance, you can create a script that fetches them from 1Password using the 1Password CLI.
Serverless Framework doesn't support this so if you use this feature, you will get a
Profile does not exist
error when deploying. I know supporting this may not be quite trivial, but it might be very convenient.Additional Data
The text was updated successfully, but these errors were encountered: