

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

Configure the cache time to live (TTL) and the cache size of the Parameter Store extension, and choose values for your workload. The settings of an extension belong to its profile entry. The Parameter Store extension has two settings. Both settings are optional. If you set a value outside the range of a setting, the extension uses the nearest value in the range.

**Topics**
+ [Descriptions of settings](#cloud-extensions-ext-parameter-store-configuration-descriptions-of-settings)
+ [What each setting does in practice](#cloud-extensions-ext-parameter-store-configuration-what-each-setting-does-in-practice)
+ [Choose values for the settings](#cloud-extensions-ext-parameter-store-configuration-choose-values-for-the-settings)
+ [Change the settings with the AWS CLI](#cloud-extensions-ext-parameter-store-configuration-change-the-settings-with-the-aws-cli)

## Descriptions of settings
<a name="cloud-extensions-ext-parameter-store-configuration-descriptions-of-settings"></a>

**Cache TTL** (`ttlSeconds`)
+ Display name: Cache TTL (seconds)
+ Type: Whole number of seconds
+ Default: 120 seconds
+ Range: 0 to 3,600 seconds
+ Description: How long the extension serves a fetched value or a stored error before it checks Parameter Store again. The extension handles the result of the check as follows:
  + Parameter Store can return that the parameter or version wasn't found, deny access, report an unusable KMS key, or report that the request isn't valid. In these cases, the extension drops the cached value. The extension returns the error and caches the error for one TTL.
  + Parameter Store can throttle the request, return a server error, be unavailable, time out, or be unreachable. The call can also be canceled. In these cases, the extension serves the cached value for another TTL. If the cache holds no value, the extension returns the error and doesn't cache the failure.
  + If the extension can't get credentials, or if Parameter Store rejects the credentials or the signature of the call, the extension returns the error. The extension doesn't serve the cached value, and it leaves the entry as it was. The next read calls Parameter Store again.
  + A value of 0 makes the extension check Parameter Store on every read. The extension doesn't cache errors. The extension still serves the last good value when a check fails for the transient reasons in the second item. A definite answer from the first item drops the last good value, so a later transient failure returns the error. A value of 0 doesn't turn caching off.

**Cache size** (`maxCacheEntries`)
+ Display name: Cache size (entries)
+ Type: Whole number of entries
+ Default: 3,000 entries
+ Range: 0 to 4,000 entries
+ Description: The maximum number of entries that the cache holds. This count includes values and stored errors. When the cache is full, the extension drops the entry that you read least recently. A value of 0 turns the cache off. Every read then calls Parameter Store, and the extension has no stale value to fall back on. A new release of the extension starts with an empty cache.

The runtime gives the extension at most 128 MB of memory. With values of 8 KB, the extension starts to throttle requests with `ThrottlingException` at roughly 3,080 to 5,080 entries. The exact number depends on the length of the names and the load. For this reason, the maximum is 4,000 entries and the default is 3,000 entries.

Secrets Manager references of 64 KB, which use the `/aws/reference/secretsmanager/` path, start to throttle requests with `ThrottlingException` at about 670 entries. If you read such references, set the cache size to 600 or less.

## What each setting does in practice
<a name="cloud-extensions-ext-parameter-store-configuration-what-each-setting-does-in-practice"></a>
+ **Cache key** – The extension keys each entry by the `WithDecryption` value and the name exactly as you send it. A name and its ARN are separate entries. A name with `:3` and the same name without a selector are separate entries. The two operations share entries.
+ **Freshness** – A value is fresh for the number of seconds in **Cache TTL**. The count starts when the extension starts the call to Parameter Store that fetched the value.
+ **Concurrent misses** – When several reads miss the cache for the same key at the same time, they wait for one call to Parameter Store.
+ **Change of the Cache TTL** – A shorter TTL makes every entry stale within one new TTL. With a value of 0, every entry is stale at once. A longer TTL applies only to values that the extension fetches later.
+ **Change of the Cache size** – A smaller size makes the extension drop the entries that you read least recently, until the cache is within the new limit.
+ **New release** – The cache starts empty and fills as your application reads parameters. The extension doesn't prefetch parameters.

## Choose values for the settings
<a name="cloud-extensions-ext-parameter-store-configuration-choose-values-for-the-settings"></a>

The following table suggests settings for common goals.


| Goal | Suggested settings | 
| --- | --- | 
| Default, balanced | **Cache TTL** 120, **Cache size** 3,000 | 
| Changes must show up fast | **Cache TTL** 5 to 30 | 
| Always check Parameter Store, but survive outages | **Cache TTL** 0 | 
| No caching at all | **Cache size** 0 | 
| Large values of about 8 KB, or long names | **Cache size** 3,000 or less | 
| Secrets Manager references of up to 64 KB | **Cache size** 600 or less | 

## Change the settings with the AWS CLI
<a name="cloud-extensions-ext-parameter-store-configuration-change-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 ssm-parameter-store \
  --query 'configuration.settings'
```

To set the values, use the `--settings` option when you create or update the profile entry. Use the setting IDs from the output of the previous command:

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

The following example file sets a TTL of 30 seconds and a cache size of 500 entries:

```json
{ "ttlSeconds": 30, "maxCacheEntries": 500 }
```

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.