-
Notifications
You must be signed in to change notification settings - Fork 1
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
Accommodate new SSO aws_account_name #15
base: master
Are you sure you want to change the base?
Conversation
This should still work with old usernames as well
Leaving this as a draft until I can get someone to test this branch. |
@@ -39,7 +40,7 @@ class TreeCoverLossAnalysis(object): | |||
self.description = descript_1 + descript_2 + descript_3 | |||
self.canRunInBackground = False | |||
self.aws_account_name = ( | |||
boto3.client("sts").get_caller_identity().get("Arn").split("/")[1] | |||
aws_session.client("sts").get_caller_identity().get("Arn").split("/")[-1] |
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.
Could/should the @wri.org
part of the user label be removed?
aws_session.client("sts").get_caller_identity().get("Arn").split("/")[-1].split("@")[0]
@@ -5,6 +5,7 @@ from datetime import datetime | |||
import itertools | |||
import os | |||
|
|||
aws_session = boto3.Session(profile_name='default') |
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.
I suspect this would be a little more appropriate as a class-level variable in TreeCoverLossAnalysis
.
Is the idea that SSO users will likely override which profile is being used? I worry that hard-coding the string 'default'
might not be better than passing None
, which would signal that boto should find whatever the fallback profile is. Can the choice of profile be provided as a parameter to the execution of the tool? That way people don't have to edit the code if they have a less common environment setup.
WRI is starting to use SSO to provision new users on AWS. For SSO users the
Arn
has a different structure.This change should accommodate both formats but for SSO users their
aws_account_name
will now be their email address.I also switched over to using
boto3.Session
to accommodate people with multiple user accounts. This is set todefault
by default so it should continue to function as is for existing users.