Skip to content

A simple serverless microservice including CI/CD pipeline

License

Notifications You must be signed in to change notification settings

badfun/new-user-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

New User Service

This repository contains a microservice that uses Amazon Cognito to manage the registration process, then stores the user information in S3. An event is created using a confirmation trigger and sent to an SNS topic with the user information payload. This topic can be subscribed to by other services by using the topic ARN from the stack output.

It also provides a pipeline for staging and prodution environments using the AWS CDK.

This is a simple stand-alone service that can be used as part of a larger application framework. It contains its own datastore, and supplies the data in a publish-subscribe pattern. By copying the payload from Cognito to S3, we have access to the full-user data for other services while still allow Cognito to manage the users.

Architecture

Architecture

Requirements

Instructions

CI/CD

Source -> Build -> Test -> Deploy to Staging -> Deploy to Production (Manual approval + Deploy)

Stages and actions are implemented using AWS CodePipeline, AWS CodeBuild and AWS CodeDeploy (behind the scenes through sam deploy command).

Pipeline itself is defined and provisioned by AWS CDK using Typescript.

  1. Run the pipeline using AWS CDK to deploy the CI/CD pipeline first.
  • First, install AWS CDK tools:

    npm install -g aws-cdk
  • Then, fetch dependencies and provision pipeline:

    cd pipeline
    npm install
    npm run build
    cdk deploy

If you have permission issues on deploy try overriding configuration and/or supplying a profile, depending on your setup:

cdk deploy --require-approval never --profile your-aws-profile

SAM

  1. CDK deploy will have created a new empty repository. Get the SSH or HTTPS url from CodeCommit and add it to git.
git remote add origin
  1. Push the local repo to CodeCommit. The new code will trigger the pipeline and it will package and create all the resources defined in template.yaml
git push origin master

The pipeline will run through build, test and deploy to staging stages. After the pipeline has run there will be a new Cognito user pool created. There is no front-end included in this service so testing has to be done with scripts or a proprietary front-end.

There is a manual approval stage before changes are deployed to production. This can be accessed in the CodePipeline console.

Notes

  • This project has borrowed heavily from https://github.com/aws-samples/aws-serverless-app-sam-cdk/ . Take a look at that repository for more information.

  • The E2E tests are not working right now. This is because AWS does not have a native way of testing S3 (that I'm aware of) and there were many issues trying Localstack to solve the problem. Hopefully in the near future this will be solved.

  • This project is part of a larger application currently in development. Expect changes as things progress.

  • When deleting the stack it is neccesary to empty and delete 2 S3 buckets as well

License

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

About

A simple serverless microservice including CI/CD pipeline

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published