View a markdown version of this page

Using the AWS AppConfig extension in AWS Systems Manager Cloud Extensions - AWS Systems Manager

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

AppConfig.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

AppConfig.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

application

string

Yes

1 to 64 characters

The name or ID of the AWS AppConfig application.

environment

string

Yes

1 to 64 characters

The name or ID of the environment.

configuration

string

Yes

1 to 128 characters

The name or ID of the configuration profile.

GetFlag

Parameter Type Required Constraints Description

application

string

Yes

1 to 64 characters

The name or ID of the AWS AppConfig application.

environment

string

Yes

1 to 64 characters

The name or ID of the environment.

configuration

string

Yes

1 to 128 characters

The name or ID of a configuration profile of type AWS.AppConfig.FeatureFlags.

flag

string

Yes

1 to 64 characters; matches ^[a-z][a-zA-Z\d_-]{0,63}$

The key of the flag.

context

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 {"country":"UK","tier":"gold"}. Every value is a string.

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

content

blob (base64 string)

Yes

The deployed configuration. Decode it from base64.

contentType

string

Yes

The content type of the deployed configuration, such as application/json. For a feature flag profile, this is application/json.

revision

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.

versionLabel

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

enabled

boolean

Yes

Whether the flag is enabled for this context.

variant

string

No

The name of the matched variant. Absent when the flag has no variants.

attributes

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

string

{"string":"GBP"}

number

number

{"number":500}

boolean

boolean

{"boolean":true}

stringList

list of strings

{"stringList":["card","wallet"]}

numberList

list of numbers

{"numberList":[1,2.5]}