Git Product home page Git Product logo

aws-appconfig-codepipeline-cdk's Introduction

aws-appconfig-codepipeline-cdk

This sample application demos setup of AWS AppConfig using AWS CDK. AWS AppConfig application is set up to use AWS CodePipeline as configuration store. It also sets up AWS Lambda validator to validate the configuration.

In addition, the project can set up a basic serverless api using Amazon API Gateway backed by AWS Lambda which makes use of AWS AppConfig Lambda extension to query hosted configuration.

Kotlin is used as language runtime to set up both the cdk application and needed lambda functions.

img.png

Project structure

├── infrastructure          # Infrastructure code vi CDK(Kotlin) for AppConfig setup.
├── software                # Holds business logic in AWS lambda functions
│   ├── configvalidator     # Lambda validator for app config configuration
│   └── demofunction        # Sample function to using lambda extension to query app config configurations
└── ...

Prerequisite

  • Make sure you have AWS CDK installed and configured with an aws account you want to use.
  • git-remote-codecommit
  • Ensure you have docker installed and is up and running locally.

Getting started

AppConfig with CodePipeline as Configuration Store

  • Change directory to where infrastructure code lives.
    cd infrastructure
    cdk synth
  • Deploy the CDK application stack named AppConfigCiCdStack. This stack will take care of setting up app config application named ServerlessApplicationConfig with a Test environment which will use codepipeline as configuration store. CodePipeline is also created using a codecommit repository as a source for configurations.
    cdk deploy --app 'cdk.out/' AppConfigCiCdStack

Above command will take care of packaging the configvalidator lambda function as well. Acknowledge security related changes prompt during deployment process. Once completed AppConfig related details are provided as stack output.

  • Once the stack is successfully deployed, You can navigate to your aws account and see the created codepipeline project along with an empty code commit repo. You need to clone the newly created codecommit repo to push a sample config file.
    git clone codecommit://serverless-app-configurations && cd serverless-app-configurations/
  git checkout -b main
  git add .
  git commit -m "Log config"
  git push origin main

Now the codepipeline should trigger automatically and deploy the configuration. It will also invoke the validator handler to validate the configurations.

img.png

Deploy Sample Serverless Application with AppConfig Lambda Extension

  • Deploy ServerlessAppStack. Acknowledge security related changes prompt during deployment process.
  cdk deploy --app 'cdk.out/' ServerlessAppStack

Serverless Api Path is provided as stack output.

  • Validate the api response.
 curl https://<hash>.execute-api.eu-west-1.amazonaws.com/prod/

This will return api gateway proxy request itself as response. But let's see app config in action.

 curl https://<hash>.execute-api.eu-west-1.amazonaws.com/prod/?appConfig=true

This will return the app config configuration which was committed to code commit repository.

  • Now try changing the log level value in the codecommit repo logging.yaml file. Once the config is deployed via codepipeline, try accessing the same api url again. You should be able to see the latest config value in the response.
 curl https://<hash>.execute-api.eu-west-1.amazonaws.com/prod/?appConfig=true

Cleanup

    cdk destroy ServerlessAppStack
    cdk destroy AppConfigCiCdStack

Acknowledge stack deletion when prompted.

Useful commands

  • mvn package compile and run tests
  • cdk ls list all stacks in the app
  • cdk synth emits the synthesized CloudFormation template
  • cdk deploy deploy this stack to your default AWS account/region
  • cdk diff compare deployed stack with current state
  • cdk docs open CDK documentation

Enjoy!

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

aws-appconfig-codepipeline-cdk's People

Contributors

dependabot[bot] avatar pankajagrawal16 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.