schrodinger.stepper.cloud.aws_client module

Helper module for returning an AWS client object.

schrodinger.stepper.cloud.aws_client.get_client(aws_service)

Retrieve an AWS client for the requested AWS service. AWS credentials are obtained in one of the following manner and order: 1. Shared credential file (~/.aws/credentials) 2. AWS config file (~/.aws/config) 3. Environment variables: SCHRODINGER_AWS_KEY_ID and SCHRODINGER_AWS_KEY

See https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html for more details.

Parameters

aws_service (str) – name of AWS service to connect to.

Returns

an active client connected to requested AWS service.

Return type

boto3.Session.client

schrodinger.stepper.cloud.aws_client.get_resource(aws_service)

Retrieve an AWS resource for the requested AWS service. See aws_client.get_client() for details on how credentials are obtained.

Parameters

aws_service (str) – name of AWS service to connect to.

Returns

an active resource connected to requested AWS service.

Return type

boto3.Session.resource

schrodinger.stepper.cloud.aws_client.get_session()

Retrieve an AWS active session. AWS credentials are obtained in one of the following manner and order: 1. Shared credential file (~/.aws/credentials) 2. AWS config file (~/.aws/config)

Returns

an active AWS session.

Return type

boto3.Session

schrodinger.stepper.cloud.aws_client.get_credentials()

This helper method usage is meant to retrieve aws credentials when they are set under ~/.aws. Note that this is typically encouraged only for development purposes and production services should instead use IAM roles for authentication across aws services.

Returns

boto3 active credentials object

Return type

botocore.credential.Credential

schrodinger.stepper.cloud.aws_client.get_region()

Retrieves the AWS region (e.g. us-east-1) in the following manner and order:

  1. Custom schrodinger environment variable

  2. EC2 instance metadata (most production services will use this feature).

If neither are available then None is returned. (Passing a region of None to the AWS client library (boto) will just cause boto to infer the region from the credentials of the machine/instance)

Returns

AWS region

Return type

str or None