-
Notifications
You must be signed in to change notification settings - Fork 12
Description
The pool of program administrators who have access to the dashboard is currently controlled by a Cognito user pool, which is propagated based on admin_dashboard.admin_access of the dynamic config
Admins frequently want to add other admins to the pool. To take the burden off of us, we'd like to provide the ability to invite other admins from within the dashboard.
I believe we can do this in Python with boto3
https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_AdminCreateUser.html
https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html
Something along the lines of:
import boto3
client = boto3.client('cognito-idp', region_name='us-west-2')def invite_admin(email):
return client.admin_create_user(
UserPoolId=f"nrelopenpath-prod-{os.getenv('STUDY_CONFIG')}",
Username=email,
UserAttributes=[
{'Name': 'email', 'Value': email},
{'Name': 'email_verified', 'Value': 'true'},
],
DesiredDeliveryMediums=['EMAIL'],
)However, it is hard to know what needs to happen to configure the client correctly on production.
According to boto3 docs:
Boto3 will look in several locations when searching for credentials. The mechanism in which Boto3 looks for credentials is to search through a list of possible locations and stop as soon as it finds credentials. The order in which Boto3 searches for credentials is:
Passing credentials as parameters in the boto3.client() method
Passing credentials as parameters when creating a Session object
Environment variables
Assume role provider
Assume role with web identity provider
AWS IAM Identity Center credential provider
Shared credential file (~/.aws/credentials)
AWS config file (~/.aws/config)
Boto2 config file (/etc/boto.cfg and ~/.boto)
Container credential provider
Instance metadata service on an Amazon EC2 instance that has an IAM role configured.
What config files and/or environment variables are available in the environment where the dashboard runs? Will they be picked up or do we need to manually handle aws_access_key_id, aws_secret_access_key, and aws_session_token?