# 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
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.saml.to/configuration/service-providers/aws-federated-roles/assuming-roles/aws-sdks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
