Forcing a refresh with refreshNow in AWS Systems Manager Cloud Extensions
By default, the extension serves cached values until their time to live (TTL) expires. If a secret rotates before then, you might get a stale value. To force an immediate refresh, add refreshNow=true to a query or path request. The parameter accepts true, false, 1, or 0, in any case. The default is false.
Without refreshNow, the extension behaves as follows:
-
It uses cached values until the TTL expires.
-
After the TTL expires, it checks the version with
DescribeSecretand fetches the value only if the version changed. -
It can serve an expired value when Secrets Manager has a transient error. For more information, see General settings.
With refreshNow=true, the extension behaves as follows:
-
It bypasses the cache and calls
GetSecretValue. -
It updates the cache with the new value and resets the TTL.
-
It returns an error if the call fails, instead of falling back to a cached value.
To force a refresh with curl, run the following command:
curl -v \ --aws-sigv4 "aws:amz:us-west-2:secretsmanager" \ --user "ACCESS_KEY_ID:SECRET_KEY" \ -H "X-Aws-Parameters-Secrets-Token: YOUR_SSRF_TOKEN" \ 'http://localhost:5333/secretsmanager/get?secretId=YOUR_SECRET_ID&refreshNow=true'