rifaterdemsahin / awscodedeploy

Aws code deploy creating a Redis using Ansible
1 stars 1 forks source link

Step by Step Documentation about how to implement #1

Closed rifaterdemsahin closed 6 years ago

rifaterdemsahin commented 6 years ago

STEP 1 Create code deploy ( Screenshots ) STEP 2

Also include the necessary links for the reader to be able to go deep dive to the information

madhavisringarapu commented 6 years ago

AWS CODEDEPLOY CREATING REDIS USING ANSIBLE Step by step documentation about how to implement this:

Please make sure that you add the following files to your project for this to work appspec.yml the entire scripts folder

Step1:

  1. Create IAM Roles CodeDeploy & EC2CodeDeploy • Sign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/. Create role with CodeDeploy name.

Create CodeDeploy role attach the following policy(codedeployec2) in permissions: // Policy Role for Code Deploy { "Version": "2012-10-17", "Statement": [ { "Action": [ "autoscaling:PutLifecycleHook", "autoscaling:DeleteLifecycleHook", "autoscaling:RecordLifecycleActionHeartbeat", "autoscaling:CompleteLifecycleAction", "autoscaling:DescribeAutoscalingGroups", "autoscaling:PutInstanceInStandby", "autoscaling:PutInstanceInService", "ec2:Describe" ], "Effect": "Allow", "Resource": "" } ] } Attach the following policy in edit trust relationship. // Policy Trust for Code Deploy { "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": [ "codedeploy.us-west-2.amazonaws.com", "codedeploy.us-east-1.amazonaws.com" ] }, "Action": "sts:AssumeRole" } ] } Create EC2CodeDeploy role like the above role and attach the following policy. // Instance Role for EC2 Instance { "Version": "2012-10-17", "Statement": [
{
"Action": [
"s3:Get",
"s3:List
"
],
"Effect": "Allow",
"Resource": "*"
} ] } Step2:

Create EC2 instance with following categories

 a. Choose AMI: Amazon Linux AMI 

 b. Choose Instance type: t2.micro 

 c. Configure Instance: Choose EC2CodeDeploy IAM role 

 d. Tag Instance: Name it what you please 

 e. Configure Security Group: 

     HTTP TCP 80 0.0.0.0/0 

     HTTP TCP 80 ::/0 

     SSH TCP 22 (YOUR IP ADDRESS) 

     HTTPS TCP 443 0.0.0.0/0 

     HTTPS TCP 443 ::/0 

 f. LAUNCH INSTANCE 
  1. SSH into EC2 instance

  2. Command line of Amazon Linux AMI

    a. When server is booted

      sudo su 
    
      yum -y update 
    
      yum install -y aws-cli 
    
      cd /home/ec2-user 

    b. Here you will setup your AWS access, secret, and region.

      aws configure 
    
      aws s3 cp s3://aws-codedeploy-us-east-1/latest/install . --region us-east-1 (if in east AWS) 
    
      aws s3 cp s3://aws-codedeploy-us-west-2/latest/install . --region us-west-2 (if in west AWS) 
    
      chmod +x ./install 

    c. This is simply a quick hack to get the agent running faster.

      sed -i "s/sleep(.*)/sleep(10)/" install 
    
      ./install auto 

    d. Verify it is running.

      service codedeploy-agent status

    After successful completion of the above process we will get the code deploy agent status as below.

Step3: Open CodeDeploy service in AWS console and create a application and deployment group as following.

Choose the EC2 instance on which you want to deploy your application by selecting the instance tags .

After successful deployment of application you will get the page like below.

After deployment of the application we will get the following page.

Open the ec2 instance by using public ip of the instance in browser you will get the webpage which I have deployed using the code deploy.I have deployed web application using code deploy so I am getting this webpage.

Now our application is deploy,I want to install a redis server on this instance using a ansible playbook. Install Ansible locally and run the redis.yml which I have put in my github account. To run the playbook run the command: $ansible-plabook redis.yml Redis server will be installed on our instance.

madhavisringarapu commented 6 years ago

iam role

madhavisringarapu commented 6 years ago

This is the aws iam role creation.

madhavisringarapu commented 6 years ago

ec2 create codedeploy policy application codedeploy deploy envirnment service arn application success codedeploy success codedeploy webpage

madhavisringarapu commented 6 years ago

HI,i have attached screenshots and step by step procedure