Wilson Mar bio photo

Wilson Mar

Hello. Hire me!

Email me Calendar Skype call 310 320-7878

LinkedIn Twitter Gitter Google+ Youtube

Github Stackoverflow Pinterest

https://wilsonmar.github.io/aws-devops/

Developer Operations for you


Overview

This tutorial focuses on continuous integration and deployment.


Amazon defines “DevOps is the combination of cultural philosophies, practices, and tools that increases an organization’s ability to deliver applications and services at high velocity.”

CodeCommit, CodePipeline, Code Deploy

aws devops 201606-650x209-i11

Setup instances

  1. In IAM Service, create Role “codedeploy”.

  2. Create CDInstanceRole

  3. In Compute EC2 service, launch Amazon Linux, t2.micro, 2 instances, using the role created above. In Advanced Details, paste script from https://gist.github.com/mikepfeiffer/4d9386afdcceaf29493a

    EC2 UserData script to install CodeDeploy agent:

    #!/bin/bash
    yum install -y aws-cli
    cd /home/ec2-user/
    aws s3 cp 's3://aws-codedeploy-us-east-1/latest/codedeploy-agent.noarch.rpm' . --region us-east-1
    yum -y install codedeploy-agent.noarch.rpm
    

    CUSTOMIZE folder, region mentionedtwice.

  4. Tag instances with name “Dev” for Development.
  5. Add a Security Group Role for HTTP. No SSH.

AWS CodeDeploy Setup

  1. Got to AWS CodeDeploy service, Get Started Now.
  2. Custom deployment.
  3. Specify an Application Name and Deployment Group Name according to your organization’s naming standards.
  4. Select Tag Type “Amazon EC2” value “Dev” specified for 2 instances in a step above.
  5. Deployment Config - AllAtOnce (instead of Half at a time).
  6. No Triggers.
  7. Select a Service Role ARN defined in a prior step. Create Application.

    The Console provides code to deploy from a S3 bucket.

AWS CodePipeline

  1. Go to AWS CodePipeline service, Get Started.
  2. Specify a Pipeline name according to your organization’s naming standards. (“Pipeline1”)
  3. Select Source Provider: GitHub (NOT Amazon S3). Click Connect to GitHub.
  4. Select a Repository and Branch from the GitHub account authenticated.
  5. Select Deployment provider AWS CodeDeploy (NOT AWS Elastic Beanstalk).
  6. Supply AWS CodeDeploy Application Name and Deployment group from earlier.
  7. Do not define Build Stage (until we have a build).
  8. Create Service Role using default name “AWS-CodePipeline-Service”. View Policy Document to review Actions allowed the role:
  9. Review Pipeline summary.

View app deployed

  1. In EC2, get the Public DNS address (such as “ec2-11-222-177-132-us-west-2-compute.amazonaws.com”).
  2. Paste URL in an internet browser.

    It should respond with “Congratualations”.

Make Change

  1. Commit.
  2. Detect a change.
  3. View app deployed again.

  4. Create a Deployment Group or Autoscaling Group
  5. CodePipeline

  6. appspec.yml file in the root folder in source code repo

    version: 0.0
    os: linux
    files:
             - source: /index.html
     destination: /var/www/html/
    hooks:
      BeforeInstall:
     - location: scripts/install_dependencies
       timeout: 300
       runas: root
     - location: scripts/start_server
       timeout: 300
       runas: root
      ApplicationStop:
     - location: scripts/stop_server
       timeout: 300
       runas: root
    
  7. For sample application, it’s just a single index.html file containing CSS, no JavaScript.

    https://github.com/mikepfeiffer/aws-codedeploy-linux/blob/master/index.html

  8. Install dependencies

    #!/bin/bash
    yum install -y httpd
    
  9. Start server

    #!/bin/bash
    service httpd start
    
  10. Stop server:

    #!/bin/bash
    isExistApp = `pgrep httpd`
    if [[ -n  $isExistApp ]]; then
        service httpd stop        
    fi
    

using AWS Code Services

CodeDeploy agent in EC2 Deploy Group

  • Amazon Route 53 globomantics.com

  • https://github.com/mikepfeiffer/PowerShell

AMIs

Netflix/aminator open-sourced their Python tool for creating EBS-backed AMIs. It’s described in this blog from 2013.

“We knew that application startup latency would be very important, especially during scale-up operations.”

Building a server from installers in S3 can be time-consuming because it take so much I/O.

To save time, their strategy is to create a Base AMI by taking a snapshot of the root volume and make it available as an EBS volume that can be used to launch an EC2 instance.

This is simpler than Packer from Hashicorp.

More on Amazon

This is one of a series on Amazon:

More resources

Justin Manga (@jmenga, pseudo.co.de) in video course Continuous Delivery using Docker and Ansible shows learners how to create a Python app, then Jenkins 2 Pipeline plugin in a container using Cloud Formation files. deploy to a EC2 Container Services holding Debian instances.

Since ECS has Group of 497:

ARG DOCKER_GID=497
RUN groupadd -g ${DOCKER_GID:-497} docker
ARG DOCKER_ENGINE=1.10.2
ARG DOCKER_COMPOSE=1.6.2
   
  • http://blog.serverbooter.com/blog/2013/10/24/simple-clouformation-with-multiple-aws-accounts/

More on DevOps

This is one of a series on DevOps:

  1. DevOps_2.0
  2. User Stories for DevOps

  3. Choices for DevOps Technologies
  4. Java DevOps Workflow
  5. AWS DevOps (CodeCommit, CodePipeline, CodeDeploy)
  6. AWS server deployment options

  7. Digital Ocean
  8. Cloud regions
  9. AWS Virtual Private Cloud
  10. Azure Cloud Powershell

  11. Git and GitHub vs File Archival
  12. Git Commands and Statuses
  13. Data Security GitHub
  14. Git Commit, Tag, Push
  15. Git Utilities
  16. GitHub API

  17. TFS vs. GitHub

  18. Jenkins Server Setup
  19. Jenkins Plug-ins
  20. Jenkins Freestyle jobs
  21. Jenkins2 Pipeline jobs using Groovy code in Jenkinsfile

  22. Dockerize apps
  23. Docker Setup
  24. Docker Build

  25. Maven on MacOSX

  26. Powershell Ecosystem
  27. Powershell on MacOS
  28. Powershell Desired System Configuration

  29. Ansible

  30. MySQL Setup

  31. SonarQube static code scan

  32. API Management Microsoft
  33. API Management Amazon

  34. Scenarios for load