Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Create and Deploy Applications Using CodeDeploy and CodePipeline

cicd

Uploaded by

aqui.ti.mdw
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Create and Deploy Applications Using CodeDeploy and CodePipeline

cicd

Uploaded by

aqui.ti.mdw
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

Home / AWS / Guided Lab / Create and Deploy applications using CodeDeploy and CodePipeline

Create and Deploy applications using CodeDeploy and CodePipeline


Level: Intermediate

Amazon EC2 Amazon S3 AWS CodeDeploy Amazon Web Services AWS CodePipeline

e 1h 8m 39s left
End Lab

Open Console

Validation

Lab Credentials

User Name x
Whiz_User_16857.53640216 w
Password x
0b9035fb-4100-4c4c-8eee-26ecea010562 w
Access Key x
AKIA5ZDWWD72UWOJJ2I7 w
Secret Key x
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 w
Lab Resources

No Lab Resources Found

Support Documents

Privacy - Terms

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 1/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

1. FAQs and Troubleshooting

2. SSH into EC2 Instance

3. Labs - Instructions and Guidelines

4. SSH into EC2 Instance using Putty

5. Understanding CodeDeploy

Need help?

How to use Hands on Lab

Troubleshooting Lab

FAQs

Submit Feedback Share

Lab Overview Lab Steps Lab Validation

Cloud Developer, Cloud DevOps Engineer

Compute, Developer Tools

Lab Steps
Task 1: Sign in to AWS Management Console

1. Click on the Open Console button, and you will get redirected to AWS Console in a
new browser tab.

2. On the AWS sign-in page,

Leave the Account ID as default. Never edit/remove the 12-digit Account ID


present in the AWS Console. Otherwise, you cannot proceed with the lab.

Now copy your Username and Password in the Lab Console to the IAM
Username and Password in AWS Console and click on the Sign in button.

3. Once Signed In to the AWS Management Console, make the default AWS Region
as US East (N. Virginia) us-east-1.

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 2/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

Note: If you face any issues, please go through FAQs and Troubleshooting for Labs.

Task 2: Launching an EC2 Instance

1. Make sure you are in US East (N. Virginia) us-east-1 Region.

2. Navigate to EC2 by clicking on the Services menu in the top, then click on EC2 in the
Compute section.

3. Click on Instances from the left sidebar and then click on Launch Instances

4. Name : Enter MyEC2Instance

5. For Amazon Machine Image (AMI): In Quick Start menu, Select Amazon Linux

6. For Instance Type: select t2.micro

7. For Key pair: Select Create a new key pair Button

Key pair name: MyEC2Key

Key pair type: RSA

Private key file format: .pem

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 3/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

8. Select Create key pair Button.

9. In Network Settings, Click on Edit:

Auto-assign public IP: Enable

Select Create new Security group

Security group name: CodePipeline-SG

Description: Security group for CodePipeline

To add SSH

Choose Type: SSH

Source: Anywhere
For HTTP,

Click on Add security group rule

Choose Type: HTTP

Source: Anywhere

10. Scroll down and expand on Advanced Details

IAM Instance profile: Select EC2_Role_<RANDOM_NUMBER>

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 4/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

11. Click on Launch Instance.

12. Launch Status: Your instance is now launching, Click on the instance ID and wait for
complete initialization of instance state till status change to Running

13. Note down the sample IPv4 Public IP Address of the EC2 instance. A sample is shown
in the screenshot below.

Task 3: SSH into EC2 Instance


Please follow the steps in SSH into EC2 Instance.

Task 4: Install AWS CLI, and CodeDeploy Agent

In this task, we are going to prepare the environment for deploying and managing
applications using AWS CodeDeploy

1. Switch to root user: This command switches the user to the root user. By switching to
the root user, you gain administrative privileges and can perform system-level tasks.

sudo su
w

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 5/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

2. Run the updates: This command updates the software packages installed on the EC2
instance to their latest versions. It ensures that the instance has the latest security
patches and bug fixes.

yum -y update
w
3. Install the CodeDeploy agent:

Install the prerequisite i.e., ruby and wget : This command installs the Ruby
programming language and the wget utility. Ruby is a prerequisite for installing
the CodeDeploy agent, and wget is used to download the agent's installer.

yum install ruby wget -y


w
Download the CodeDeploy agent's installer : This command uses wget to download
the CodeDeploy agent's installer from the specified URL. The installer is a script that sets
up the CodeDeploy agent on the EC2 instance.

wget https://aws-codedeploy-us-east-1.s3.us-east-
1.amazonaws.com/latest/install
w
Change the permission of the installer : This command changes the permissions of the
installer script, making it executable. It allows the script to be run and installed on the
EC2 instance.

chmod +x ./install
w
Install the latest version of the CodeDeploy agent : This command runs the CodeDeploy
agent's installer script in auto mode. The auto mode automatically detects the
instance's operating system and installs the agent accordingly.

sudo ./install auto


w
Check that the service is running : This command checks the status of the CodeDeploy
agent service. It confirms whether the agent is running or not. If the output shows that
the agent is running, it indicates that the installation was successful.

service codedeploy-agent status


w
Note: If the output is “The AWS CodeDeploy agent is running as PID 785” or any other PID.
It means codedeploy agent is running fine.

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 6/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

If the output says, “error: No AWS CodeDeploy agent running”, then start the agent by
running the below command and check the status again.

Start the agent: This command starts the CodeDeploy agent service. If the agent is not
running, this command starts it.

service codedeploy-agent start


w
check the status again:

service codedeploy-agent status


w
Task 5: Copy the S3 Bucket's key

In this task, we are going to obtain the object key, which is required for configuring the source
stage in AWS CodePipeline.

1. Navigate to the Services menu at the top. Click on S3 in the Storage section.

2. Open the bucket starting with the name Whizlabs.

3. Click on the object present to see its properties.

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 7/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

4. Copy the object Key, and save it to notepad. We'll need this in further steps.

Task 6: Create a CodeDeploy application and Deployment group

1. Navigate to CodeDeploy by clicking on the Services menu at the top, then click on
CodeDeploy in the Developer Tools section.

2. Click on the Applications present on the left sidebar under CodeDeploy option.

3. To create a CodeDeploy application, click on the Create application button.

4. In Application configuration, Enter the application name as Whiz_App.

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 8/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

5. Select the EC2/On-Premises as Compute platform.

6. And, click on the Create application button.

7. The application is now created.

8. To create a deployment group, click on the Create deployment group button.

9. Deployment group name: Whiz_DepGroup

Enter a service role : Select the service role from the dropdown.

Deployment type: Select In-place deployment

Environment configuration: Select Amazon EC2 Instances

In Tag Group 1, use the following tags to select the EC2 Instance for
deployment:

Note: The value should be the same as the tag defined while creation of EC2
Instance.

Key: Name

Value: MyEC2Instance

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 9/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

Matching instances will show the record as 1 unique matched instance.

Agent configuration with AWS Systems Manager: Never

Deployment settings: Select CodeDeployDefault.AllAtOnce

Enable load balancing: Uncheck

10. Click on the Create deployment group button.

11. A deployment group is now created.

Task 7: Create a CodePipeline pipeline and deploy the application on the


instance

1. Navigate to CodePipeline by clicking on the Services menu at the top, then click on
CodePipeline in the Developer Tools section.

2. Click on Pipelines from the left sidebar and then click on the Create pipeline

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 10/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

3. For the Step-1, Choose pipeline settings :

Pipeline name: Whiz_Pipeline

Service role: New service role

Check the option of creating a new service role (Default)

Expand the option of Advanced settings

Artifact store: Select Custom location

Bucket: Select the Bucket name starting with Whizlabs

click on the Next button.

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 11/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

4. For the Step-2, Add source stage :

Source provider: Select Amazon S3 from dropdown

Bucket: Select whizlabs[followed by a number that is autogenerated].

S3 object key: Enter SampleApp_Linux.zip

Change detection options: Select AWS CodePipeline

Click on the Next button.

5. For the Step-3, Add build stage :

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 12/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

Click on the Skip build stage.

confirm to skip by clicking on the Skip button in the confirmation popup

6. For the Step-4, Add deploy stage :

Deploy provider: Select AWS CodeDeploy from dropdown

Region: US East (N. Virginia)

Application name: Select Whiz_App

Deployment group: Select Whiz_DevGroup

Click on the Next button.

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 13/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

7. For the Step-5, Review :

Review everything and click on the Create pipeline button.

8. The pipeline is now created.

9. CodePipeline has started to run and will succeed.

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 14/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

Task 8: Test the application using EC2 Instance Public IPv4 DNS

1. Navigate to EC2 by clicking on the Services menu in the top, then click on EC2 in
the Compute section.

2. On the dashboard, click on the Instances (running).

3. To view the metadata of an EC2 Instance, click on the Instance ID for the instance
named MyEC2Instance.

4. Copy the Public IPv4 DNS of the Instance.

5. Open the new tab in the browser and paste the public IP.

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 15/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

Do you Know?
AWS CodePipeline has announced the general availability of AWS CodePipeline for
Containers. This new feature allows developers to easily build, test, and deploy container
images to any container registry or Kubernetes cluster using CodePipeline.With
CodePipeline for Containers, developers can now use familiar container tools and
workflows to manage their CI/CD pipelines for containerized applications. They can
define the build and test stages of their pipeline using Dockerfiles and container images,
and then deploy those images to their container orchestration platform of choice, such
as Amazon Elastic Kubernetes Service (EKS) or Amazon Elastic Container Service (ECS).This
new feature provides developers with a more streamlined and efficient way to manage
their container deployments, making it easier to build and release containerized
applications with greater speed and agility.

Task 9: Validation of the lab

1. Once the lab steps are completed, please click on the Validation button on the right
side panel.

2. This will validate the resources in the AWS account and displays whether you have
completed this lab successfully or not.

3. Sample output :

Task 10: Cleanup resources

1: Delete the CodeDeploy application

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 16/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

1. Navigate to CodeDeploy by clicking on the Services menu at the top, then click
on CodeDeploy in the Developer Tools section.

2. Click on the Application, present on the left sidebar

3. Created application is present there, click on the Application name, Whiz_App.

4. To delete the application, click on the Delete application button.

5. In the confirmation pop-up, type delete to complete the deletion of the application.

2: Terminate the EC2 instance


1. Navigate to EC2 by clicking on the Services menu in the top, then click on EC2 in
the Compute section.

2. Click on the Instances, present on the left sidebar below Instances.

3. To terminate the EC2 instance, perform the following task:

Select the EC2 Instance

Click on the Instance state

Choose Terminate instance

4. Confirm the termination of EC2 Instance, by clicking on the Terminate button.

Completion and Conclusion


1. You have successfully created and launched Amazon EC2 Instance.

2. You have successfully logged into the EC2 instance by SSH.

3. You have successfully installed AWS CLI and CodeDeploy Agent.

4. You have successfully created a CodeDeploy application and Deployment group.

5. You have successfully created a CodePipeline pipeline deployed the application on


the instance with the help of CodeDeploy.

6. You have successfully tested the application using Public IPv4 DNS of the EC2
Instance.

End Lab
1. Sign out of AWS Account.

2. You have successfully completed the lab.

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 17/18
8/29/23, 8:28 PM Create and Deploy applications using CodeDeploy and CodePipeline

3. Once you have completed the steps, click on End Lab from your whizlabs dashboard.

About Us Subscription Instructions and Guidelines FAQ’s Contact Us

© 2023, Whizlabs Software Pvt. Ltd. a f h

https://www.whizlabs.com/labs/create-and-deploy-applications-using-codedeploy-and-codepipeline 18/18

You might also like