Description:
AWS Code Pipeline is a continuous delivery service you can use to model, visualize, and automate the steps required to release your software. The service divides the entire workflow into individual stages.
Each pipeline contains at least one action (action performed on the artifact). Pipeline activities are performed in a specific order; sequentially or in parallel – according to the configuration at a given stage. A detailed description of how the AWS Code Pipeline works can be found in the runbook.
Rationale:
In general terms the process of implementing an architecture for the needs of the deployment process. The first phase is loading the latest version of the application code into the Amazon S3 service. Each new update loaded into the bucket starts the AWS Code Pipeline service.
Impact:
For each Code Pipeline Action in AWS Code Deploy, the application code from Amazon S3 is replicated to the artifact store in the region for the given action. Each action implements the latest version of the application to the Amazon EC2 instance in the region.
Default Value:
Code Pipeline is not enabled by default.
Pre-Requisite:
The first step is to install the AWS Code Deploy agent on the instances. The agent is a software package enabling deployments. At this stage you need to do 2 things:
create Amazon EC2 instances and install the AWS Code Deploy agent,
create AWS Code Deploy applications.
To improve this performance, you can use the AWS Cloud Formation template.
Remediation:
Test Plan:
To create a pipeline in many regions, follow these steps:
Configure the resources that will be needed for implementation with the help of AWS Code Deploy.
Configure “artifact stores” (S3 buckets) for AWS Code Pipeline in each region.
Create an AWS Cloud Formation for AWS Code Pipeline.
Check deployments carried out by pipeline in the AWS Management Console.
Check the correctness of implemented deployments.
Implementation Steps:
Phase 1:
To run Amazon EC2 and AWS Code Deploy instances, you can use AWS Cloud Formation templates prepared by AWS, In the AWS console, on the Specify Details page, do the following:
In Stack name, enter a name for the stack (for example, USEast1CodeDeploy).
In Application Name, enter a name for the application (for example, Cross Region Action Support).
In Deployment Group Name, enter a name for the deployment group (for example, Cross Region Action Support Deployment Group).
In EC2KeyPairName, if you already have a key pair to use with Amazon EC2 instances in that region, choose an existing key pair, and then select your key pair. For more information
In EC2TagKeyName, enter Name.
In EC2TagValue, enter N Virginia Cross Region Instance.
Choose Next.
Creating resources can take several minutes. Progress can be observed in the console in the Events tab. When the stack is created, the “CREATE_COMPLETE” message will appear in the Status column.
Phase 2
Configure artifact stores for AWS Code Pipeline. Amazon S3 uses buckets as storage for artifacts. Buckets are regional and versioned. All artifacts are copied to the region where the pipeline action is to be performed.
To create such storage using AWS Cloud Formation, you must download a template for each region.
On the Specify Details page, do the following:
In Stack name, enter a name for the stack (for example, artifact store).
In Artifact Store Bucket Name Prefix, enter a prefix string of up to 30 characters. Use only lowercase letters, numbers, periods, and hyphens (for example, useast1).
Choose Next.
As before, the creation of resources may take several minutes, and the progress of the operation is visible in the Events tab in the AWS console.
Phase 3
Use the AWS Cloud Formation template to define resources:
Amazon S3 Bucket (source bucket for application source code),
AWS Code Pipeline for which you must define the appropriate actions within the pipeline phases: Source action (S3) and the appropriate number of Deploy action (Code Deploy type) for each region.
To create a new bucket S3, you must start the console, and then select the AWS Cloud Formation service, download the template and run it in the main region.
On the Specify Details page, do the following:
In Stack name, enter a name for the stack (for example, code-pipeline-us-west2-source-bucket).
In Source Code Bucket Name Prefix, enter a prefix string of up to 30 characters. Use only lowercase letters, numbers, periods, and hyphens (for example, uswest2).
Choose Next.
Creating resources can take several minutes, and progress is visible in the Events tab of the AWS console.
Note: When the creation process is completed, download the sample application from s3-app-linux.zip and load it into the source code bucket.
Phase 4
We can now check the deployments carried out by the prepared pipeline in the AWS console. In the S3 console, go to the source bucket and copy the version ID.
Then go to AWS Code Pipeline and go to the pipeline that has just been created. Note that the version ID is the same in all regions, both in source action and all deploy actions. Deployment has been successfully completed.
Back out Plan:
As part of the deployment process, the Code Deploy agent removes from each instance all the files installed by the most recent deployment. If files that weren’t part of a previous deployment appear in target deployment locations, you can choose what Code Deploy does with them during the next deployment:
Fail the deployment — An error is reported and the deployment status is changed to Failed.
Overwrite the content — The version of the file from the application revision replaces the version already on the instance.
Retain the content — The file in the target location is kept and the version in the application revision is not copied to the instance.
Reference:
https://docs.aws.amazon.com/config/latest/developerguide/codepipeline-deployment-count-check.html
https://docs.aws.amazon.com/codedeploy/latest/userguide/welcome.html