-
Notifications
You must be signed in to change notification settings - Fork 1
CICD Setup for EC2
Juhi edited this page May 25, 2020
·
14 revisions
Below is the process to setup continuous deployment to AWS EC2 instance with source code in github.
-
Create IAM roles (if not already created)
-
CodeDeploy Service Role -- This role gives codedeploy access to target instances (EC2 / lambda). It also provides cloudwatch, SNS access for alerts & notification
- Go to IAM roles and click on create role
- Select CodeDeploy service and CodeDeploy use case for deployment to EC2
- Add tags if required, give appropriate name and create the role
-
EC2 Role -- This role gives code deploy agent installed on EC2 instance, access to read S3 srtifacts
- To understand where S3 came into picture, we need to understand how codedeploy works. Check this page for a short brief. <>
- Create a new role selecting EC2 service with AmazonS3ReadOnlyAccess policy
- Add tags if required, give appropriate name and create the role
-
CodeDeploy Service Role -- This role gives codedeploy access to target instances (EC2 / lambda). It also provides cloudwatch, SNS access for alerts & notification
-
Create / attach the target EC2 instance with the IAM role #2
-
ssh into the EC2 instance and run following code
#!/bin/bash # Installing CodeDeploy Agent sudo yum update sudo yum install ruby # Download the agent (replace the region) wget https://aws-codedeploy-eu-west-3.s3.eu-west-3.amazonaws.com/latest/install chmod +x ./install sudo ./install auto sudo service codedeploy-agent statusThe status should look something like this --
The AWS CodeDeploy agent is running with pid xxxx
Refer FAQ if you get 0 pid