Skip to content

Latest commit

 

History

History

appconfig-feature-flag-sam

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

AWS AppConfig Feature Flag with SAM

This pattern creates

  • AWS AppConfig Feature Flag configuration
  • AWS Lambda that reads the feature flags from AWS AppConfig
  • Amazon API Gateway HTTP API that triggers the AWS Lambda

The feature flag configuration in this example contains two flags:

  • a simple boolean flag ON/OFF
  • a flag that can be ON/OFF but, when it is ON, it has a numeric value

Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the AWS Pricing page for details. You are responsible for any AWS costs incurred. No warranty is implied in this example.

Requirements

Deployment Instructions

  1. Create a new directory, navigate to that directory in a terminal and clone the GitHub repository:

    git clone https://github.com/aws-samples/serverless-patterns
    
  2. Change directory to the pattern directory:

    cd appconfig-feature-flag-sam
    
  3. From the command line, use AWS SAM to build and deploy the AWS resources for the pattern as specified in the template.yml file:

    sam build
    sam deploy --guided
    
  4. During the prompts:

    Once you have run sam deploy -guided mode once and saved arguments to a configuration file (samconfig.toml), you can use sam deploy in future to use these defaults.

  5. Note the outputs from the SAM deployment process. These contain the resource names and/or ARNs which are used for testing.

How it works

This pattern deploys an Amazon API Gateway HTTP API that, throuogh the config endpoint, triggers the AWS Lambda. The function retrieves the feature flags fron AWS AppConfig.

The AWS Lambda is configured to have access to the application's configuration for a specific environment.

Testing

Once the application is deployed, retrieve the HttpApiUrl value from CloudFormation Outputs. Either browse to the endpoint in a web browser or call the endpoint from Postman. Remeber to append the path of the endpoint that retrieves the configuration (config)

Example GET Request: https://{HttpApiId}.execute-api.eu-west-1.amazonaws.com/config

Response:


{
  "Pagination":{
    "Enabled":true,"PageSize":5
    },
  "WizardSwitch":{
    "Enabled":true
    }
}

Documentation

Cleanup

  1. Delete the stack

    sam delete 

This pattern was contributed by Greg Davis.


Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.

SPDX-License-Identifier: MIT-0