AWS Automation Cookbook

Book description

Automate release processes, deployment, and continuous integration of your application as well as infrastructure automation with the powerful services offered by AWS

About This Book

  • Accelerate your infrastructure's productivity by implementing a continuous delivery pipeline within your environment
  • Leverage AWS services and Jenkins 2.0 to perform complete application deployments on Linux servers
  • This recipe-based guide that will help you minimize application deployment downtime

Who This Book Is For

This book is for developers and system administrators who are responsible for hosting their application and managing instances in AWS. It's also ideal for DevOps engineers looking to provide continuous integration, deployment, and delivery. A basic understanding of AWS, Jenkins, and some scripting knowledge is needed.

What You Will Learn

  • Build a sample Maven and NodeJS Application using CodeBuild
  • Deploy the application in EC2/Auto Scaling and see how CodePipeline helps you integrate AWS services
  • Build a highly scalable and fault tolerant CI/CD pipeline
  • Achieve the CI/CD of a microservice architecture application in AWS ECS using CodePipeline, CodeBuild, ECR, and CloudFormation
  • Automate the provisioning of your infrastructure using CloudFormation and Ansible
  • Automate daily tasks and audit compliance using AWS Lambda
  • Deploy microservices applications on Kubernetes using Jenkins Pipeline 2.0

In Detail

AWS CodeDeploy, AWS CodeBuild, and CodePipeline are scalable services offered by AWS that automate an application's build and deployment pipeline. In order to deliver tremendous speed and agility, every organization is moving toward automating an entire application pipeline. This book will cover all the AWS services required to automate your deployment to your instances.

You'll begin by setting up and using one of the AWS services for automation ? CodeCommit. Next, you'll learn how to build a sample Maven and NodeJS Application using CodeBuild. After you've built the application, you'll see how to use CodeDeploy to deploy the application in EC2/Autoscaling. You'll also build a highly scalable and fault tolerant continuous integration (CI)/continuous deployment (CD) pipeline using some easy-to-follow recipes.

Following this, you'll achieve CI/CD for Microservices application and reduce the risk within your software development lifecycle. You'll also learn to set up an infrastructure using CloudFormation Template and Ansible, and see how to automate AWS resources using AWS Lambda.

Finally, you'll learn to automate instances in AWS and automate the deployment lifecycle of applications.By the end of this book, you'll be able to minimize application downtime and implement CI/CD, gaining total control over your software development lifecycle.

Style and approach

This book takes a "How to do it" approach, providing with easy solutions to automate common maintenance and deployment tasks.

Publisher resources

View/Submit Errata

Table of contents

  1. Title Page
  2. Copyright
    1. AWS Automation Cookbook
  3. Credits
  4. About the Author
  5. Acknowledgments
  6. About the Reviewer
  7. www.PacktPub.com
    1. Why subscribe?
  8. Customer Feedback
  9. Preface
    1. What this book covers
    2. What you need for this book
    3. Who this book is for
    4. Sections
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Conventions
    6. Reader feedback
    7. Customer support
      1. Errata
      2. Piracy
      3. Questions
  10. Using AWS CodeCommit
    1. Introduction
    2. Introducing VCS and Git
      1. What is VCS?
        1. Why VCS ?
        2. Types of VCS
      2. What is Git?
        1. Why Git over other VCSs?
        2. Features of Git
      3. How to do it...
        1. Installation of Git and its implementation using GitHub
    3. Introducing AWS CodeCommit - Amazon managed SaaS Git
      1. How to do it...
    4. Getting started with CodeCommit for HTTP users
      1. How to do it...
    5. Setting up CodeCommit for SSH users using AWS CLI
      1. Getting ready
      2. How to do it...
    6. Applying security and restrictions
      1. Getting ready
      2. How to do it...
    7. Migrating a Git repository to AWS CodeCommit
      1. How to do it...
  11. Building an Application using CodeBuild
    1. Introduction
    2. Introducing AWS CodeBuild
      1. How to do it...
      2. How it works...
        1. Pricing
    3. Building a Java application using Maven
      1. Getting ready
        1. Install Java and verify
        2. Install Apache Maven and verify
      2. How to do it...
    4. Building a NodeJS application using yarn
      1. Getting ready
        1. Install NodeJS and verify
        2. Install Yarn and verify
      2. How to do it...
        1. Installing dependencies
      3. How it works...
    5. Building a Maven application using AWS CodeBuild console
      1. Getting ready
      2. How it works...
    6. Building a sample NodeJS application using AWS CodeBuild via Buildspec.yml
      1. Buildspec.yml
        1. Syntax
      2. Getting ready
      3. How to do it...
  12. Deploying Application using CodeDeploy & CodePipeline
    1. Introduction
    2. The Deployment strategy in AWS CodeDeploy
      1. In-place deployment
      2. Blue-green deployment
      3. How to do it...
    3. Writing an application-specific file
      1. How to do it...
    4. Deploying a static application in an EC2 instance from the S3 Bucket using AWS CodeDeploy
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Introducing AWS CodePipeline and its working
      1. How to do it...
      2. How it works...
    6. Continuous Deployment of static application to AWS S3 using AWS CodePipeline
      1. How to do it...
  13. Building Scalable and Fault-Tolerant CI/CD Pipeline
    1. Introduction
      1. Benefits of using the CI/CD pipeline
        1. How to achieve the benefits?
        2. The scenario
        3. The challenges
    2. CI/CD pipeline workflow
      1. Getting ready
      2. How to do it...
    3. Setting up AWS CodeCommit
      1. Getting ready
      2. How to do it...
    4. Creating the S3 bucket and enabling versioning
      1. Getting ready
      2. How to do it...
    5. Creating the launch configuration and Auto Scaling group
      1. Getting ready
      2. How to do it...
    6. Creating AWS CodeDeploy application using the Auto Scaling group
      1. Getting ready
      2. How to do it...
    7. Setting up the Jenkins Server and installing the required plugins
      1. Getting ready
      2. How to do it...
    8. Integrating Jenkins with all of the AWS developers tools
      1. Getting ready
      2. How to do it...
  14. Understanding Microservices and ECS
    1. Introduction
    2. Understanding microservices and their deployment
      1. Designing microservices
      2. Deployment of microservices
    3. Playing around with Docker containers
      1. Containers
      2. Docker
        1. Images
        2. Registry
        3. Containers
      3. Getting ready
        1. Installation of Docker engine
        2. Run Docker as a non-root user
      4. How to do it...
        1. Running a container
        2. Starting the stopped container
        3. Assigning a Name to a container
        4. Creating daemonized containers
        5. Exposing ports of a container
        6. Managing persistent storage with Docker
        7. Adding a data volume
        8. Getting details of a container
        9. Containerize your application using Dockerfile
        10. Push the image to Dockerhub
    4. Setting up AWS ECR and pushing an image into it
      1. Getting ready
      2. How to do it...
        1. To authenticate Docker client with ECR
        2. Tagging your Docker Image with the repository details
        3. Pushing the image to ECR
    5. Understanding ECS and writing task definitions and services
      1. Getting ready
      2. How to do it...
        1. Verifying containers inside the Container instance
  15. Continuous Deployment to ECS Using Developer Tools and CloudFormation
    1. Introduction
    2. Understanding the architecture and workflow
      1. How to do it...
      2. How it works...
    3. Setting up the infrastructure to host the application
      1. Getting ready
      2. How to do it...
        1. Creating an ECS cluster
        2. Creating a Load Balancer (Classic ELB)
        3. Register Auto Scaling with Load Balancer
        4. Creating an Amazon ECR
    4. Setting Up CodeCommit for our application source
      1. Getting ready
      2. How to do it...
    5. Creating a CodeBuild project for the build stage
      1. Getting ready
      2. How to do it...
    6. Understanding the inside content of helper files (BuildSpec.yml, Dockerfile, and CF template)
      1. How to do it...
    7. Creating a CodePipeline using CodeCommit, CodeBuild, and CloudFormation
      1. Getting ready
      2. How to do it...
  16. IaC Using CloudFormation and Ansible
    1. Introduction
    2. AWS CloudFormation and writing the CloudFormation template
      1. Terms and concepts related to AWS CloudFormation
        1. For YAML
        2. For JSON
      2. How to do it...
        1. Writing a CF template
          1. Defining parameters
          2. Using parameters
        2. Creating stack using the CF template
    3. Creating a production-ready web application infrastructure using CloudFormation
      1. Getting ready
      2. How to do it...
    4. Automation with Ansible
      1. Workflow
      2. Installation
      3. How to do it...
        1. File structure and syntax
        2. Deploying a web server using Ansible
    5. Creating an AWS infrastructure using the Ansible EC2 dynamic inventory
      1. Getting ready
      2. How to do it...
  17. Automating AWS Resource Control Using AWS Lambda
    1. Introduction
    2. Creating an AMIs of the EC2 instance using AWS lambda and CloudWatch
      1. Getting ready
      2. How to do it...
    3. Sending notifications through SNS using Config and Lambda
      1. Getting ready
      2. How to do it...
        1. Configuring the AWS Config service for AWS resources
        2. Creating a Lambda function
        3. Creating a trigger
    4. Streaming and visualizing AWS CloudTrail logs in real time using Lambda with Kibana
      1. Workflow
      2. Getting ready
      3. How to do it...
        1. Enabling CloudTrail logs
        2. Configuring CloudWatch
        3. Creating Elasticsearch
        4. Enabling the streaming of CloudWatch logs in Elasticsearch
        5. Configuring Kibana to visualize your data
  18. Microservice Applications in Kubernetes Using Jenkins Pipeline 2.0
    1. Introduction
      1. K8s architecture
        1. Master components
        2. Node components
    2. Deploying multinode clusters on AWS using the Ansible playbook
      1. Getting ready
      2. How to do it...
    3. Deploying a multinode production-ready cluster on AWS using Kops
      1. Getting ready
      2. How to do it...
        1. Creating bucket
        2. DNS configuration
        3. Creating a cluster
        4. Kubernetes dashboard (UI)
        5. Clean up
    4. Deploying a sample application on Kubernetes
      1. Getting ready
      2. How to do it...
        1. Configuration file
          1. Deployment configuration file
          2. Service configuration file
    5. Working with Kubernetes on AWS using AWS resources
      1. Getting ready
      2. How to do it...
        1. Creating a persistent volume claim
        2. Deployment configuration file (includes ECR image and PVC )
        3. Service configuration file (type Loadbalancer)
    6. Jenkins pipeline 2.0 (Pipeline as Code) using Jenkinsfile
      1. How to do it...
        1. Declarative pipeline
          1. Sections
    7. Application deployment using Jenkinsfile
      1. Getting ready
      2. How to do it...
        1. Create a pipeline in the BlueOcean
        2. Clean Up
        3. Creating a Pipeline using existing Jenkinsfile
    8. Deploying microservices applications in Kubernetes using Jenkinsfile
      1. Getting ready
      2. How to do it...
        1. Workflow
  19. Best Practices and Troubleshooting Tips
    1. Best practices with AWS CodeCommit
    2. Troubleshooting with CodeCommit
    3. Troubleshooting with CodeBuild

Product information

  • Title: AWS Automation Cookbook
  • Author(s): Nikit Swaraj
  • Release date: November 2017
  • Publisher(s): Packt Publishing
  • ISBN: 9781788394925