This labs walks through a process of creating a two-stage pipeline that uses sample application.
- Amazon EC2
This labs walks through a process of creating a two-stage pipeline that uses sample application. Process includes launching an EC2 Instance, installing a CodeDeploy Agent, creating CodeDeploy application and Deployment and then creating a CodePipeline pipeline to initiate the process.
- Launch EC2 Instance
- SSH to Instance, install CodeDeploy Agent
- Create CodeDeploy application and Deployment
- Create a CodePipeline pipeline and test application
- AWS account
- putty for SSH connection
- Start with launching an EC2 Instance of type t2.micro with Amazon Linux. It will need a IAM Role that will allow CodeDeploy to perform a action on it and access to S3. Create a new Security Group and allow HTTP connections from anywhere. When the instance’s status changes to Running note down its the IPv4 Public IP Address.
- SSH into EC2 Instance. Instal AWS CLI and CodeDeploy Agent. Switch to root user:
yum -y update
To install Codedeploy agent we need Ruby:
yum install ruby wget -y
Change the permission of the installer and install agent
chmod +x ./install
sudo ./install auto
To check agents status run:
service codedeploy-agent status
- Upload a sample app to a S3 bucket.
- Create a CodeDeploy application and Deployment group. Start with creating application and choose EC2/On-premises as platform. Create a deployment group and choose the service role from drop-down menu. In Environment configuration choose Amazon EC2 instances and since CodeDeploy Agent is already install choose Never in Agent configuration. And uncheck Load balancer.
- Create a pipeline and deploy application on the instance in CodePipeline. In pipeline settings choose New service role in Advanced settings in Artifact store choose Custom location and provide name of the bucket with sample application. In next step choose Amazon S3 as a source provider and uploaded zip file. Skip the build stage, and as Deploy provider choose AWS CodeDeploy, created app and Deployment. Click on Create, this will run the pipeline.
- Time for testing. Go back to EC2 Instance and visit the Public IPv4 DNS address.
- Time for clean-up. Delete the CodeDeploy application, terminate the EC2 Instance.