serverless-aws-ci
Create a CI pipeline using AWS CodePipeline and AWS CodeBuild to automatically deploy your Serverless project when changes are committed.
Getting Started
Prerequisites
Make sure you have the following installed before starting:
The AWS credentials used to create the CI pipeline via the serverless
command will need the following permissions:
cloudformation:DescribeStackResources
codebuild:CreateProject
codebuild:ListBuilds
codepipeline:CreatePipeline
The IAM role (specified via the custom.awsCI.roleArn
configuration) that AWS CodePipeline and AWS CodeBuild will assume will need to be assigned the AWSCodeBuildDeveloperAccess
policy AND be assigned the following permissions:
logs:CreateLogGroup
logs:CreateLogStream
Installing
# From npm (recommended)
npm install serverless-aws-ci
# From github
npm install https://github.com/mscifo/serverless-aws-ci.git
Then make the following edits to your serverless.yml
file:
plugins:
- serverless-aws-ci
custom:
awsCI:
roleArn: # (required) the AWS ARN for the role CodePipeline/CodeBuild will assume
Running
To create the pipeline (you only need to run this once per branch/stage):
serverless awsci -g [GITHUB_OWNER/GITHUB_REPO] -b [GITHUB_BRANCH] -t [GITHUB_PERSONAL_ACCESS_TOKEN] -s [STAGE]
Be sure to commit the created buildspec.yml
so the pipeline will know how to deploy your Serverless project.
Running Tests
To run the test:
npm test
All tests should pass.