Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type": "feature",
"description": "IMDS credential requests are now retried. Every failed request is retried except a token request rejected with 400 or 403 and a metadata request answered with 403 or 404. `IMDSConfig.retry_strategy`, which was previously unused, now controls these retries. By default it is a `SimpleRetryStrategy` with backoff of 0.25, 0.5 and 1 seconds, making 4 attempts. The new `IMDSConfig.max_attempts` sets the attempt count when no `retry_strategy` is given, and can also be set with `AWS_METADATA_SERVICE_NUM_ATTEMPTS` or the `metadata_service_num_attempts` config setting. The new `IMDSConfig.timeout`, 1 second by default, bounds each IMDS request and can also be set with `AWS_METADATA_SERVICE_TIMEOUT` or the `metadata_service_timeout` config setting. The synchronous default credential chain now gives IMDS its own HTTP client with this timeout as its connect timeout, instead of the shared client. The synchronous resolver now keeps the HTTP client it creates, so the session token is reused across calls. Session tokens now expire after the TTL IMDS returns."
}
16 changes: 13 additions & 3 deletions packages/aws-credentials-imds/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,27 @@ service_client = ServiceClient(
)
```

Endpoint mode, token TTL, and other options can be customized through an
`IMDSConfig`:
Endpoint mode, token TTL, retries, timeout, and other options can be customized
through an `IMDSConfig`:

```python
from aws_credentials_imds import IMDSConfig, IMDSCredentialsResolver

resolver = IMDSCredentialsResolver(
config=IMDSConfig(endpoint_mode="IPv6", token_ttl=300),
config=IMDSConfig(endpoint_mode="IPv6", token_ttl=300, max_attempts=2, timeout=2.0),
)
```

Each metadata read makes up to 4 attempts, with waits of 0.25, 0.5 and 1 seconds
between them, and each request times out after 1 second. To change the backoff
as well, pass a `retry_strategy`, which overrides `max_attempts`. The default
chain reads these settings from the environment or the shared config file:

| Setting | Environment variable | Config file key |
| --- | --- | --- |
| `max_attempts` | `AWS_METADATA_SERVICE_NUM_ATTEMPTS` | `metadata_service_num_attempts` |
| `timeout` | `AWS_METADATA_SERVICE_TIMEOUT` | `metadata_service_timeout` |

## Standalone

The resolver can also be used on its own to fetch credentials directly:
Expand Down
Loading