# AWS SDKs

The AWS SDKs behave identically to the [AWS CLI](https://docs.saml.to/configuration/service-providers/aws-federated-roles/assuming-roles/aws-cli). For example you can use [Environment Variables](https://docs.saml.to/configuration/service-providers/aws-federated-roles/aws-cli#using-environment-variables) or a [Named Profile](https://docs.saml.to/configuration/service-providers/aws-federated-roles/aws-cli#using-profiles) before the application is launced with the AWS SDK.

## Environment Variables

`myscript.py`

```
import boto3

ec2 = boto3.client('ec2')

for i in ec2.instances.all():
    if i.state['Name'] == 'stopped':
        i.start()
```

Then, to invoke `myscript.py` with temporary credentials from SAML.to, in a Subshell (`$(...)`)

```
$(saml-to assume the-role-name --headless)
python myscript.py
```

## Named Profiles

`myscript.py`

```
import boto3

ec2 = boto3.client('ec2', profile_name='the-profile-name')

for i in ec2.instances.all():
    if i.state['Name'] == 'stopped':
        i.start()
```

Then, to invoke `myscript.py` with temporary credentials from SAML.to:

```
saml-to assume the-role-name --save the-profile-name
python myscript.py
```
