Amazon Web Services (AWS) CodePipeline Team has simplified Developer, DevOps engineers operational overhead and streamlined the Deployment process to EC2 by introducing an CodePipeline action to deploy directly to your EC2 instances.

Why does it matter to you?

Previously, if you wanted to deploy to EC2 instances, you had to use CodeDeploy with an AppSpec file to configure the deployment. After this update NO NEED TO MANAGE CODEDEPLOY RESOURCE AND APPSPEC FILE.

I tried this out today so let me show you how you can simplify your deployment pipeline by 90% and remove all the complex process and scripts!!!

Architecture

Prerequisites

Behind the Scenes

This action performs a send-command using SSM to execute the script in the instance.

Create an EC2 instance with Apache

Note: If you are creating an instance then you need to create a role with AmazonSSMManagedInstanceCore, AmazonS3ReadOnlyAccess and attach to ec2 instance.

I have created EC2 with Apache web server for the brevity of the blog.

sudo su
yum update -y
yum install httpd -y
service httpd start
chkconfig httpd on
echo "codepipeline ec2 deployment action" > /var/www/html/index.html

Create pipeline with Ec2 deployment action

Note: Once pipeline is created you need to edit the pipeline service role and add the following permissions to avoid error.

        {
            "Effect": "Allow",
            "Action": [
                "ssm:CancelCommand",
                "ssm:DescribeInstanceInformation",
                "ssm:ListCommandInvocations",
                "ssm:SendCommand"
            ],
            "Resource": "*"
        }

Run the pipeline

I am using the source as GitHub using code start connection and code resides in this repo.

Note: The aws guide mentioned about adding AWSSystemsManagerDefaultEC2InstanceManagementRoleeployAction to the ec2 instance role but in my environment I didn’t needed that permission

Some advanced options for this action

From Developer, DevOps perspective

After reading this, do you wish to migrate to this action and simplifying your deployment process?

I share such amazing AWS updates on DevOps, Kubernetes and GenAI daily over Linkedin, X. Follow me over there so that I can make your life more easy.

このウェブサイトでは、よりよいユーザー体験のためにCookieを使用しています。詳細は、Cookieに関する方針をご参照ください。OK をクリックまたは本サイトの利用を続行することで、我々がCookieを使用することに同意したとみなされます。