Published in


CI/CD Hands-On: Github (Actions) + AWS (EC2, CodeDeploy, S3) — Part 2

Table of Contents

  1. (Basic) CI/CD Hands-on: Github Actions+Docker Hub+AWS EC2

2. (Intermediate) CI/CD Hands-on : Github (Actions) + AWS (EC2, CodeDeploy, S3)— Part 1

3. (Intermediate) CI/CD Hands-on : Github (Actions) + AWS (EC2, CodeDeploy, S3) — Part 2

Set IAM Role For CodeDeploy

In the previous story, we gave permission to EC2 for getting access to CodeDeploy resources. The target instance is now able to use CodeDeploy services to deploy an application. Next, we need to set up proper IAM roles for CodeDeploy to fetch source from a bucket and deploy the source file to EC2 instance — 3 & 4 steps on the image above.

Go to IAM > Roles and click click roles .

On the next page, choose CodeDeploy as the use case and fill out the role details, skipping permissions that we do not have now.

I just added the role name and finished it. Then, you’ll see the role you made on the list. Switch back to CodeDeploy now to make an instance and hand the role over it.

Application Setting

First, create an application in CodeDeploy. Its compute platform should be EC2/On-premises. Be aware not to choose other platforms.

Once an application is made, go ahead create development group since the CodeDeploy application requires at least one development group. Make a group name and assign the IAM role to its service role.

Choose In-placeas deployment type to update your instance with the latest application revisions. If you want zero downtime deployment, you need to select Blue/green .

Environment configuration is in regard to selecting the instance target to deploy so that we choose Amazon EC2 Instance with Name key. Its value is the name of the EC2 instance we’ve made before.

Lastly, select deployment settings and load balancer, which are left with the default here.

Now you see one group created and named as what we have added like below. CodeDeploy settings get done! Let’s move on to S3 settings 👏

Make an S3 bucket

Move on to AWS S3 and create a new bucket, in which an application build file will be uploaded and transferred to the target instance for deployment.

Create an IAM user for AWS CLI

Now that we have all the instances we need to deploy an application, create an IAM user for AWS CLI(Command Line Interface), which is an entity that you create in AWS to represent the person or application that uses to interact with AWS. A user in AWS consists of a name and credentials. (see this for more information about IAM users)

Go to AWS IAM and click Add users on the right side in the Users tab.

Set user name and select AWS credential type as Access key — Programmatic access . Click and go to Permissions.

We will attach existing policies directly unless you already have your own group. Search S3FullAccess and CodeDeployFullAccess , and click both to add.

Review what you set before confirming creating the user. Once you create it, AWS provides its credentials as a CSV file, which you need to download and keep in a private space so as not to forget.

Great! AWS Setups done 👊 . You did a very good job! We will see how it works through a Github action script in the next story.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Minho Jang

Minho Jang

Backend Developer, Writer, and Lifelong Learner