code: def assume_role(role_arn, session_name=None, duration_seconds=None,
                  region='us-east-1', env_vars=None):
      
      if session_name is None:
          session_name = 'runway'
      assume_role_opts = {'RoleArn': role_arn,
                          'RoleSessionName': session_name}
      if duration_seconds:
          assume_role_opts['DurationSeconds'] = int(duration_seconds)
      boto_args = {}
      if env_vars:
          for i in ['aws_access_key_id', 'aws_secret_access_key',
                    'aws_session_token']:
              if env_vars.get(i.upper()):
                  boto_args[i] = env_vars[i.upper()]
  
      sts_client = boto3.client('sts', region_name=region, **boto_args)
      LOGGER.info("Assuming role %s...", role_arn)
      response = sts_client.assume_role(**assume_role_opts)
      return {'AWS_ACCESS_KEY_ID': response['Credentials']['AccessKeyId'],
              'AWS_SECRET_ACCESS_KEY': response['Credentials']['SecretAccessKey'],  # noqa
              'AWS_SESSION_TOKEN': response['Credentials']['SessionToken']}
docs: Assume IAM role.