

# Configuration options for the Secrets Manager extension in AWS Systems Manager Cloud Extensions

Configure the cache, security, and prefetch settings of the Secrets Manager extension in its profile entry. You set the settings as JSON with the `--settings` option of `create-profile-entry` or `update-profile-entry`. Cloud Extensions fills in default values. If a value is outside its range, the Cloud Extensions API rejects it when you create or update the profile entry. The extension refuses it when it starts or updates. The extension rejects unknown keys. On create, an extension with an unknown key doesn't load. On update, the extension keeps its previous settings. Valid changes apply without a restart.

Changing the `cache`, `region`, or `ignoreTransientErrors` settings clears the whole cache.

The console shows the general settings first, and then the **Security**, **Cache**, and **Prefetch** groups.

**Topics**
+ [General settings](#cloud-extensions-ext-secrets-manager-configuration-general-settings)
+ [Security](#cloud-extensions-ext-secrets-manager-configuration-security)
+ [Cache](#cloud-extensions-ext-secrets-manager-configuration-cache)
+ [Prefetch](#cloud-extensions-ext-secrets-manager-configuration-prefetch)
+ [Changing the settings with the AWS CLI](#cloud-extensions-ext-secrets-manager-configuration-changing-the-settings-with-the-aws-cli)

## General settings
<a name="cloud-extensions-ext-secrets-manager-configuration-general-settings"></a>

**Serve cached secrets on transient errors** (`ignoreTransientErrors`)
+ Type: On or off
+ Default: On
+ Description: Keeps serving an expired cached secret when a refresh fails with a timeout, a connection error, or a 5xx error.

**Region** (`region`)
+ Type: Text. This setting is optional.
+ Default: The AWS Region of the runtime
+ Constraints: An AWS Region code, such as `us-east-1`, with at most 32 characters
+ Description: The AWS Region where the extension calls Secrets Manager.

## Security
<a name="cloud-extensions-ext-secrets-manager-configuration-security"></a>

The extension requires the **Security** group (`security`). It controls the server-side request forgery (SSRF) token check. The check applies to query and path requests, which use the `workloadProvider` and `vault` interfaces, whatever the authentication of the profile. The `serviceSdk` interface has no SSRF check. While the SSRF token header check is on, every query and path request needs the SSRF token in one of the SSRF token headers.

**SSRF token header check** (`ssrfHeadersEnabled`)
+ Type: On or off
+ Default: On
+ Description: Requires the SSRF token in one of the SSRF token headers on query and path requests. Keep the setting on if the authentication of the profile is `none`. Turn the setting off if every caller signs with SigV4. The other settings in the **Security** group apply only while this setting is on. The extension refuses requests that carry an `X-Forwarded-For` header whether this setting is on or off.

**SSRF token headers** (`ssrfHeaders`)
+ Type: List of text values. This setting is optional.
+ Default: `X-Aws-Parameters-Secrets-Token` and `X-Vault-Token`
+ Constraints: 1 to 10 header names, with at most 128 characters each
+ Description: The headers that a request can carry the SSRF token in. The extension matches the header names without regard to case.

**SSRF token** (`ssrfToken`)
+ Type: Text
+ Constraints: 1 to 256 characters
+ Description: The token. The extension requires this setting while the SSRF token header check is on. The extension stores the token in plaintext in the profile entry, so anyone who can read the profile entry can read the token.

## Cache
<a name="cloud-extensions-ext-secrets-manager-configuration-cache"></a>

The **Cache** group (`cache`) controls the in-memory secret cache.

**Cache TTL (seconds)** (`ttlSeconds`)
+ Type: Whole number of seconds
+ Default: 300 seconds
+ Range: 0 to 3,600 seconds
+ Description: How long the extension serves a cached secret before it checks Secrets Manager for a newer version. A value of 0 makes the extension check on every request.

**Cache size** (`cacheSize`)
+ Type: Whole number of secrets
+ Default: 1,000
+ Range: 1 to 1,000
+ Description: The maximum number of secrets that the cache of each role holds at one time. When the cache is full, the extension drops the secret that it fetched least recently.

## Prefetch
<a name="cloud-extensions-ext-secrets-manager-configuration-prefetch"></a>

The **Prefetch** group (`prefetch`) controls the secrets that the extension loads into the cache when it starts.

**Prefetch share of the cache** (`cacheBufferRatio`)
+ Type: Number
+ Default: 0.8
+ Range: 0.1 to 1.0
+ Description: The share of the cache of each role that prefetching can fill. Prefetching stops at the limit and doesn't drop existing entries.

**Max prefetch delay (seconds)** (`maxJitterSeconds`)
+ Type: Whole number of seconds
+ Default: 0 seconds
+ Range: 0 to 10 seconds
+ Description: The longest random delay before prefetching starts. The delay spreads the load across hosts that start at the same time.

**Secrets** (`secrets`)
+ Type: List of secrets. This setting is optional. You can add up to 100 secrets.
+ Description: Secrets to prefetch. Each item has the following fields:
  + **Secret ID** (`secretId`) - The name or ARN of the secret, with 1 to 2,048 characters. The extension requires this field.
  + **Role ARN** (`roleArn`) - The ARN of a role that the extension assumes to fetch the secret. This field is optional. If you leave the field empty, the extension uses its own credentials.

**Tag filters** (`filterTags`)
+ Type: List of tag filters. This setting is optional. You can add up to 100 tag filters.
+ Description: Prefetches secrets that have any of the tag keys. Each item has the following fields:
  + **Tag key** (`key`) - The tag key, with 1 to 128 characters. The extension requires this field.
  + **Role ARN** (`roleArn`) - The ARN of a role that the extension assumes to find and fetch the secrets. This field is optional. If you leave the field empty, the extension uses its own credentials.

## Changing the settings with the AWS CLI
<a name="cloud-extensions-ext-secrets-manager-configuration-changing-the-settings-with-the-aws-cli"></a>

To see the settings that the extension declares, with their IDs, types, default values, and constraints, run the following command:

```bash
aws cloudextensions get-extension \
  --identifier aws:secretsmanager \
  --query 'configuration.settings'
```

To set the values, use the `--settings` option when you create or update the profile entry:

```bash
aws cloudextensions update-profile-entry \
  --profile-identifier my-application \
  --identifier {{profile-entry-id}} \
  --settings file://secrets-manager-settings.json
```

The runtime validates the values against the setting definitions of the extension. To see the values that the extension uses, including default values, read the `effectiveSettings` field of the profile entry.