tilfinltd / aws-extend-switch-roles

Extend your AWS IAM switching roles by Chrome extension, Firefox add-on, or Edge add-on
https://goo.gl/0QFjow
MIT License
1.31k stars 140 forks source link

Accept Profile property "source_profile" in config by disregarding the property #337

Open LazaroOnline opened 7 months ago

LazaroOnline commented 7 months ago

The problem: We want to use the same profile config for both our AWS-CLI and this AWS-Switch-Roles plugin so it is easier to manage and we just edit it once and then copy and paste from/to the local /.aws/credentials file and this plugin's config.

In our AWS-CLI credentials we need the property "source_profile" in each profile so it picks up the Multi-Factor-Authentication token from another profile, since we have a single shared profile to store the MFA token. The problem is AWS-switch-roles plugin breaks if the property "source_profile" is added showing the message:
The following profiles are referenced as 'source_profile' but not defined: MfaProfileNameHere
if i try to add a profile with that name to make the error go away then it requires the profile to have an account id and role name which I don't want to add because on its own the MfaProfileNameHere should not be a visible role option in the plugin menu. If I still add the required properties then it saves the config successfully but then something goes wrong and it just won't show the role that has the "source_profile" property in the plugin's menu.

Solution:

Just disregard the property "source_profile". I don't know if there is any use-case where this property is used, but most probably there isn't, given that this plugin only requires account-id and role-name to work.

TLDR:

Just make this config work:

[dev]
color=ff0000
region=eu-west-1
source_profile = SomeProfileDontMindMeOk
role_arn = arn:aws:iam::012345678901:role/SomeRoleName

[prod]
color=0000ff
region=eu-west-1
source_profile = SomeProfileDontMindMeOk
role_arn = arn:aws:iam::123456789012:role/SomeRoleName