> For the complete documentation index, see [llms.txt](https://docs.saml.to/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.saml.to/configuration/service-providers/aws-federated-roles/assuming-roles/aws-sdks.md).

# AWS SDKs

The AWS SDKs behave identically to the [AWS CLI](/configuration/service-providers/aws-federated-roles/assuming-roles/aws-cli.md). For example you can use [Environment Variables](/configuration/service-providers/aws-federated-roles/assuming-roles/aws-cli.md#using-environment-variables) or a [Named Profile](/configuration/service-providers/aws-federated-roles/assuming-roles/aws-cli.md#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
```
