AWS: Support source_profile#299
Conversation
|
Thanks for adding this; looks very useful. I have two general questions, not about a specific part of the code:
|
According to https://docs.aws.amazon.com/cli/latest/topic/config-vars.html#using-aws-iam-roles:
The static credentials part is not something we need to concern ourselves about: Our 'static' credentials are the access keys stored in 1P and because now we support only 1 credential to be mapped to a plugin, users will always use that 1 access key pair, so looking for another pair of static credentials that can be associated to the called profile is out of scope and not supported by us. |
On a second check, I have realised there's a bug in I have opened an issue on was-vault's repo: 99designs/aws-vault#1211 I've also found out self-loops, i.e. profiles which are referencing themselves, are accepted as they would normally work with AWS cli, and it's our tools responsibility to gracefully handle that case. I have introduced a couple of regression tests to cover both roundtrip loop and self-loops. |
I agree that we are indeed achieving the functionality that is described in there. I think it will work for some cases, but I am not sure that we are achieving 100% parity with the CLI when it comes to MFA. Just to check If I understand it correctly, we're only supporting an MFA device on the first role in the chain (i.e. the one that the user refers to). However, it is very well possible that your setup requires the MFA device on a different link that chain. For example, say you have role A and B. The user can assume role A and must use MFA to do so. Role A can assume role B. In a normal config that would look something like: I am pretty sure this is possible with the AWS CLI, but I am not sure whether this is possible with our shell plugin. The example config in the PR description suggests you have gotten this to work. Are you sure that the MFA device was actually used when using the |
|
Yes yes, this is exactly what happens in our current version. Roles are chained and each profile uses all information available for retrieving their temporary credentials to pass to the next profile in the chain (so the scenario explained in your example works as you'd expect) |
… if mfa serial and otp are in 1Password item they will be used for all profiles. If only OTP is in 1Password item, it will be used only in profiles that present an mfa serial in config
|
There still is another edge case matter I'm looking to address: Using mfa authentication in multiple of the chained profiles. Specifically using the same virtual MFA device in multiple profiles in the chain. Using several different MFA devices along the chain of profiles is out of scope because we only support 1 item per plugin. UPDATE: we have decided this use case does not need to be supported, as it's something that wouldn't really occur in practice |
libutcher
left a comment
There was a problem hiding this comment.
Took a look at the rest of the error messages and left some small questions and notes, but overall I think they look good!
jpcoenen
left a comment
There was a problem hiding this comment.
One tiny remark, but overall this looks good to me. Great job, Andy! 🙌
hculea
left a comment
There was a problem hiding this comment.
Did a code-review, looks good in broad lines, only a couple nits and a question!
Overview
This change makes so that having
source_profilein your.aws/configfile doesn't error out and instead behaves as expected.This is the expected behaviour:
Case 1: Only
source_profileis specified in a profile. --> The source profile is inspected recursively and the right credentials provider is chosen to be used for the current profile.Case 2:
source_profileis specified, alongside other role/mfa specific information (role_arn.mfa_serialetc) --> the source profile is inspected recursively to determine the right provider. This provider is then used as "base" credentials for executing SDK calls to the STS service for retrieving another set of temporary credentials as marked by the other role/mfa specific information present in the current profile.Further aspects regarding recursivity:
source_profileare handled when parsing the config file using was-vault'sLoadFromProfilefunction.Type of change
Related Issue(s)
How To Test
Use a config file that specifies
source_profileand executeaws sts get-caller-identity --profile <name>to check that the right credentials were retrieved.Example of config file:
Changelog
AWS Shell Plugin now supports sourcing credentials from another profile.