Using the AWS AppConfig extension in AWS Systems Manager Cloud Extensions
Call the AWS AppConfig extension on localhost to retrieve configurations and evaluate feature flags. The runtime serves the extension under /appconfig. Locally, the endpoint is http://localhost:5333/appconfig/. The extension uses the AWS JSON 1.1 protocol. Each request is a POST to the endpoint. The request has the operation in the X-Amz-Target header, the content type application/x-amz-json-1.1, and the parameters in a JSON body.
To get a configuration, and then to get one feature flag, run the following commands:
curl -sS -X POST http://localhost:5333/appconfig/ -H 'X-Amz-Target: AppConfig.GetConfiguration' -H 'Content-Type: application/x-amz-json-1.1' -d '{"application":"my-app","environment":"prod","configuration":"my-settings"}' curl -sS -X POST http://localhost:5333/appconfig/ -H 'X-Amz-Target: AppConfig.GetFlag' -H 'Content-Type: application/x-amz-json-1.1' -d '{"application":"my-app","environment":"prod","configuration":"my-flags","flag":"my-flag"}'
The curl examples and the HTTP client examples send no credentials. These examples work only when the authentication of the profile is none. To sign requests, see Authentication.
Using the AWS AppConfig Extension SDK
The AWS AppConfig Extension SDK is the preferred way to call the extension. The SDK sends the requests to the local endpoint of the runtime for you, and returns the configurations and the evaluated feature flags as objects in your language. To use the SDK, download it, and then add it to your application.
The rest of this topic describes the HTTP requests that the SDK sends. Use them if the SDK isn't available for your language.
Operations
The extension has two read-only operations. Both operations read the same cache entry and the same poll for a configuration.
| Operation | X-Amz-Target |
Returns | Use it when |
|---|---|---|---|
|
GetConfiguration |
|
The deployed configuration, base64-encoded, with its content type, a revision, and its version label |
You need the whole configuration, such as a JSON settings document. |
|
GetFlag |
|
One feature flag, evaluated against the context that you send: whether it's enabled, the matched variant, and typed attributes |
You use feature flags, and you want the extension to evaluate the rules for you. |
The extension calls AWS AppConfig only to retrieve a configuration that isn't cached, and in its background poll. A request for a cached configuration never calls AWS AppConfig.
Request parameters
GetConfiguration
| Parameter | Type | Required | Constraints | Description |
|---|---|---|---|---|
|
|
string |
Yes |
1 to 64 characters |
The name or ID of the AWS AppConfig application. |
|
|
string |
Yes |
1 to 64 characters |
The name or ID of the environment. |
|
|
string |
Yes |
1 to 128 characters |
The name or ID of the configuration profile. |
GetFlag
| Parameter | Type | Required | Constraints | Description |
|---|---|---|---|---|
|
|
string |
Yes |
1 to 64 characters |
The name or ID of the AWS AppConfig application. |
|
|
string |
Yes |
1 to 64 characters |
The name or ID of the environment. |
|
|
string |
Yes |
1 to 128 characters |
The name or ID of a configuration profile of type |
|
|
string |
Yes |
1 to 64 characters; matches |
The key of the flag. |
|
|
map of string to string |
No |
Up to 100 entries; keys and values up to 1,024 characters |
The values that the variant rules of the flag are evaluated against, such as |
Response shapes
GetConfiguration
The status is 200 OK, and the body is JSON:
{"content":"eyJncmVldGluZyI6ImhlbGxvIGZyb20gdjEiLCJtYXhJdGVtcyI6MTAsImZlYXR1cmVzIjpbInNlYXJjaCJdfQo=","contentType":"application/json","revision":"0sU6FR2TSJI","versionLabel":"baseline"}
| Member | Type | Always present | Notes |
|---|---|---|---|
|
|
blob (base64 string) |
Yes |
The deployed configuration. Decode it from base64. |
|
|
string |
Yes |
The content type of the deployed configuration, such as |
|
|
string |
Yes |
An 11-character value derived from the content. It changes when the content changes, so you can compare it to tell whether the configuration changed. |
|
|
string |
No |
The label of the deployed configuration version, when it has one. |
For a feature flag profile, GetConfiguration returns every flag as JSON, each with its default value, evaluated without a context.
GetFlag
The status is 200 OK, and the body is JSON:
{"enabled":true,"variant":"ukPremium","attributes":{"currency":{"string":"GBP"},"express":{"boolean":true},"maxAmount":{"number":500},"methods":{"stringList":["card","wallet"]},"tiers":{"numberList":[1,2.5]}}}
| Member | Type | Always present | Notes |
|---|---|---|---|
|
|
boolean |
Yes |
Whether the flag is enabled for this context. |
|
|
string |
No |
The name of the matched variant. Absent when the flag has no variants. |
|
|
map |
No |
The attribute values of the flag, by attribute key. Absent when the flag has none. |
Each attribute value has exactly one member that names its type:
| Member | Type | Example |
|---|---|---|
|
|
string |
|
|
|
number |
|
|
|
boolean |
|
|
|
list of strings |
|
|
|
list of numbers |
|