def assume_role_credentials(self, arn):
        """Return the environment variables for an assumed role"""
        log.info("Assuming role as %s", arn)

        # Clear out empty values
        for name in ['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_SECURITY_TOKEN', 'AWS_SESSION_TOKEN']:
            if name in os.environ and not os.environ[name]:
                del os.environ[name]

        sts = self.amazon.session.client("sts")
        with self.catch_boto_400("Couldn't assume role", arn=arn):
            creds = sts.assume_role(RoleArn=arn, RoleSessionName="aws_syncr")

        return {
              'AWS_ACCESS_KEY_ID': creds["Credentials"]["AccessKeyId"]
            , 'AWS_SECRET_ACCESS_KEY': creds["Credentials"]["SecretAccessKey"]
            , 'AWS_SECURITY_TOKEN': creds["Credentials"]["SessionToken"]
            , 'AWS_SESSION_TOKEN': creds["Credentials"]["SessionToken"]
            }
def assume_role_credentials ( self , arn ) : log . info ( "Assuming role as %s" , arn ) for name in [ 'AWS_ACCESS_KEY_ID' , 'AWS_SECRET_ACCESS_KEY' , 'AWS_SECURITY_TOKEN' , 'AWS_SESSION_TOKEN' ] : if name in os . environ and not os . environ [ name ] : del os . environ [ name ] sts = self . amazon . session . client ( "sts" ) with self . catch_boto_400 ( "Couldn't assume role" , arn = arn ) : creds = sts . assume_role ( RoleArn = arn , RoleSessionName = "aws_syncr" ) return { 'AWS_ACCESS_KEY_ID' : creds [ "Credentials" ] [ "AccessKeyId" ] , 'AWS_SECRET_ACCESS_KEY' : creds [ "Credentials" ] [ "SecretAccessKey" ] , 'AWS_SECURITY_TOKEN' : creds [ "Credentials" ] [ "SessionToken" ] , 'AWS_SESSION_TOKEN' : creds [ "Credentials" ] [ "SessionToken" ] }
Return the environment variables for an assumed role