How to setup CI/CD with AWS CodePipeline
How to setup CI/CD with AWS CodePipeline John Vanderzyden (Guest Author) November 28, 2017
How to setup CI/CD with AWS CodePipeline
AWS cater two cloud-computing CD services that can aid alleviate your path toward the goal of CD automation: AWS CodePipeline, a continuous integration and CI and CD service, and AWS CodeDeploy, an automated application deployment service.
In this clause, we ply an overview of how to integrate, configure, and use AWS CodePipeline in your development workflow. We too provide links to diverse resources that offer much more point and avenue for exploration.
Why Use AWS CodePipeline?
AWS CodePipeline do it much easier than other CI/CD tools to model, visualize, configure, and automatize each of the steps of the process for building and releasing your package products. You can configure the line with a graphical or command-line interface.
As you configure each level, you specify which actions are do on the codification as it moves through CodePipeline.
The pipeline anatomy, tests, and deploys your code consort to a release process model that you define. After activate your pipeline, CodePipeline mechanically advertise any change to your code repository through the set of actions that you ’ ve configured in each stage. Code alteration are consistently and reliably run through a standardized process follow each commit.
Optionally, you can set manual-approval checkpoints at the end of a stage to control that new change don ’ t proceed farther into the pipeline without dominance. Approvers can review and reject any defective updates and preclude any further advance down the pipeline. CodePipeline also stops your pipeline whenever an action betray, such as a unit test failure. Such automation gives you the ability to screen more frequently, and catch bugs when they are minor and easier to fix vs. downstream.
AWS provides a comprehensive line toolset so that you can entirely automate your CodePipeline. For a full list of AWS services and third-party tools presently endorse by AWS CodePipeline, see Product and Service Integrations with AWS CodePipeline.
With tight cohesion and easy setup, you can shortly get to the point at which your team improves the frequency, velocity, and dependability of new feature delivery. You can make out an end-to-end solution with a variety of pre-built plugins for 3rd-party services such as GitHub, Jenkins, and BlazeMeter. In addition, you can integrate your own custom plugins into any CodePipeline phase.
Prerequisites for a CodePipeline
You ’ ll need to completethese steps before you can configure a pipeline in AWS:
- Create an AWS Account
- Create or use an IAM User
- Use an IAM Managed Policy to Assign AWS CodePipeline permissions to the IAM User
- Install the AWS CLI (command-line interface)
- Open the AWS CodePipeline console
A Unproblematic Pipeline with the AWS CodeCommit Repository
The easiest way to explore AWS CodePipeline and find its suitableness for your development squad is to configure a unproblematic pipeline using the Create Pipeline sorcerer in the CodePipeline console. AWS provides a tutorial that guides you through a simple implementation of CodePipeline, in which you ’ ll deploy codification held in an AWS CodeCommit monument into a single Amazon EC2 instance, using AWS CodeDeploy as the deployment service. You can opt for a versioned S3 bucket for the repository by following the guidance yield in Create a Mere Pipeline (Amazon S3 Bucket).
Learn How to Create a Four-Stage Pipeline with a GitHub Repository and Jenkins server
Larger or more mature evolution teams may want to progress and configure elaborate pipelines. Let ’ s look at configuring a four-stage pipeline that involves a GitHub depositary for your source codification, a Jenkins server for build the project, and an AWS CodeDeploy coating to deploy builds into a staging server.
Before you can create a CodePipeline, you ’ ve got to configure the resources that will be put to use in the pipeline. If, for instance, you want to use a GitHub monument to contain the source codification, the repository must be ready prior to adding it to the pipeline. As part of define up, the CodePipeline tutorial walking you through setting up Jenkins on an Amazon EC2 instance for demonstration purposes.
These are the major steps in make a 4-stage pipeline with CodePipeline.
- Set up the prerequisites
- Create a Pipeline in AWS CodePipeline
- Add Another Stage to Your Pipeline
- Clean Up Resources
Set up the prerequisites
For Jenkins, CodePipeline requires you to install the plugin for Jenkins on any illustration of Jenkins that you ’ ll be integrating with the pipeline. It ’ s best practice to configure a dedicated IAM user to provide permit access between your Jenkins project and CodePipeline. Indeed, the easiest way is to install Jenkins on an Amazon EC2 instance that will use an IAM representative role that you create for Jenkins integration—although you can still continue to run Jenkins locally if you prefer.
Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.
For Jenkins actions in the pipeline to successfully connect, you ’ ll need to configure proxy and firewall background on the server or Amazon EC2 instance that will permit inbound connection to the port in use by your Jenkins project. Also, ensure that you configure Jenkins to authenticate users and enforce access control before you permit connective on those port. For more information, see Securing Jenkins.
The prerequisite tasks include the following, which are detail in the CodePipeline docs.
- Copy or knockoff the sample into a GitHub repository
- Create an IAM Role for the Jenkins integration
- Install and configure Jenkins and the CodePipeline plugin for Jenkins
Create a CodePipeline
With your requirement in paw, you ’ re ready to create the pipeline using the Create Pipeline wizard. An AWS tutorial explains how to mix a Jenkins instance with a pipeline. That tutorial directs you to download and use a codification sample and walks you through a configuration that will convert a code sample from Haml to HTML.
Following successful completion of the wizard, the pipeline will start automatically and push the sampling code through the pipeline. You can view progress and success and failure messages as the pipeline builds the Haml sampling to HTML and deploys a web page to each of the Amazon EC2 instances in the AWS CodeDeploy deployment.
Here ’ s an model of input and output artifacts of actions in a pipeline:
Add another stage to your grapevine
Next, you can add a test stage and insert a tryout activity into that stage that will use the Jenkins test that is included in the sample. The exam will find if the web page has any content.
The project are detailed in the CodePipeline tutorial doc:
- Look up the IP address of the Jenkins instance
- Create a Jenkins projection for testing the deployment
- Create a fourth stage that includes the Jenkins test action
The grapevine position will now exhibit the stages and activity in your pipeline and the state of the rescript as it runs through the four stages. The time it takes for the pipeline to traverse all phase will depend primarily on the sizing of the artifacts, the complexity of your build, and the extent of the tryout activeness.
View Pipeline Details and History in AWS CodePipeline
Use the CodePipeline console or the command-line interface to view detail about pipelines on your AWS account. View particular for each pipeline, include which actions ran last, the status of a stage transition, failed actions, and other info. You can likewise catch a story page that shows details for all recorded line performance.
Custom pipeline actions
AWS CodePipeline provides many action that help you configure build, exam, and deployment resources for your automated release operation. Your release process may include activities not found among the default actions—such as an internally-developed soma process or a test suite. Using the AWS command-line interface, you can create a custom activity and include it in your grapevine.
Custom actions include:
- A build action that builds or transforms items.
- A deploy activity that deploys items to multiple servers, site, or depositary.
- A test activity that configures and scarper automated tests.
- An invoke activity that fulfil mapping.
Invoke a Lambda Function in an AWS CodePipeline
AWS Lambda is a Amazon computing service by which you can run code without having to provision and manage servers. You can create Lambda functions and then add them as actions in your pipelines. Because Lambda allows you to write map to do almost any task, you can customize the way your pipeline plant.
These are solely a few of the ways in which you can use Lambda functions in a line:
- Deploy change to your environs by applying an AWS CloudFormation template.
- Using CloudFormation, instantly create imagination in one pipeline point and delete them in another stage.
- Using a Lambda function that swaps CNAME values, deploy application adaptation with no downtime in AWS Elastic Beanstalk.
- Deploy to Amazon ECS Docker instances.
- Back up resource prior to building or deployment by make an AMI shot.
- Integrate 3rd-party products into your line, such as posting substance to an IRC client. & nbsp; Two specific examples which may be utile would be to send Code Deploy events to screen services like which can show exactly when you deployed codification so if any tests fail after the deployment, you can clearly trace them back to the code. & nbsp; Another example would be to send deployment events to a service like AWS CloudTrail which is integrated with product monitoring tools so you can trace production issues backward to encrypt deploy events natively within AWS. & nbsp; & nbsp;
Managing Approval Actions
With CodePipeline, you can add an approval activeness to any stage in a grapevine. You place an approval action at a point where you need the pipeline performance to stop so that someone with sufficient AWS IAM permission can approve or reject the action. Pipeline performance will resume upon approval. If the reviewer rejects the action—or if there is no decision within seven days—pipeline performance will not continue.
Here are some illustration for implementing approval activity:
- A code reexamination or change management reassessment is necessary prior to entry into the following level.
- Manual quality assurance testing is necessary on the latest version of an application—or you necessitate to control the integrity of a particular flesh artifact— prior to release.
- A critique of new or updated text is necessary prior to release on a company website.
Resource cleanup after Testing
When you ’ re done exploring with any of these exemplar, delete those pipelines and any supporting imagination, so that you don ’ t incur charges for continued use of them. & nbsp; Delete the AWS CodeDeploy application, any comparable Amazon EC2 instances, and besides the Amazon S3 bucket that contains the artefact. You may likewise want to delete any GitHub repositories if you won ’ t be using them.
When choosing the testing service for your CI/CD pipeline, try mabl out forfreeto see if it fits your needs!
Quality Engineering Resources
Automate This With SUSA
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.
Try SUSA FreeTest Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free