THIS POST CONTINUES FROM PART 1
STEP 4 – CREATE THE CI/CD PIPELINE
In the following steps, we’ll create a continuous integration and deployment pipeline to build (or rather package) our serverless application, deploy into our development environment, await approval to promote before deploying into production all using AWS CodePipeline and AWS CodeBuild.
Note: We won’t be using AWS CodeDeploy to deploy our serverless application. Instead we will use AWS CodeBuild so we can leverage the built-in deployment features of the Serverless Framework CLI.
- Tell our pipeline where our source code lives
AWS CodeCommit as the source provider on step 2 of 5
- Select the repository we created in the steps above
master as the branch and leave the rest as default
STEP 5 – TEST THE CI/CD PIPELINE
To test our pipeline works, trigger the pipeline using the
Release change button from the console or push a change from your development machine to CodeCommit to invoke the continuous integration.
Once deployment into the development environment has completed successfully, the pipeline waits for approval before deploying our application into production.
Navigating to CloudFormation in the AWS console shows us the stack the Serverless Framework generated to provision, deploy and manage our development environment.
After testing the application functions correctly in dev, approve the request generated by the pipeline using either the linked emailed via SNS or by the waiting pipeline in the AWS console.
STEP 6 – TESTING THE SAMPLE APPLICATION
In this step we’ll test the sample application provided during this post. If you chose to develop your own, then just skip ahead to the next step.
- Open a browser and navigate to the URL of the web client the serverless-finch plugin deployed as part of our serverless application stack.
Note: The URL of the single page app will be
http://-.s3-website-us-east-1.amazonaws.com/ substituting the name of the bucket and provider region you specified in the
- Fill out the options and click on the Chaos button to randomly send a message to one of the numbers provided.
Tip: Check your Twilio settings are configured correctly as described in the sample application walkthrough above.
- In the AWS console, navigate to the Lambda Management Console and view the configuration and invocations details of your serverless function.
STEP 7 – CLEANING UP OUR AWS RESOURCES
The Serverless Framework uses CloudFormation under the hood so cleaning up our AWS resources is as simple as issuing the
remove command using the Serverless Framework CLI.
- Clean up our development environment
serverless remove –stage dev
serverless client remove –stage dev
- Clean up our production environment
serverless remove –stage prod
serverless client remove –stage prod
- Optionally delete additional AWS resources through the console
- AWS CodePipeline pipeline and IAM role
- AWS CodeBuild project and IAM roles
In this post, we walked through the steps required to automate the delivery of a full stack serverless application on AWS using the Serverless Framework. Using serverless application frameworks provide an opinionated, repeatable and automated approach to build, deploy and run serverless applications and allow a consistent development toolchain no matter which cloud provider or language used.
For further reading check out the following links: