Elastigroup Integrates With AWS CodeDeploy

Aharon Twizer

AWS CodeDeploy is a service that automates code deployments to any instance, including Amazon EC2 instances and instances running on-premises. AWS CodeDeploy makes it easier for you to rapidly release new features, helps you avoid downtime during application deployment, and handles the complexity of updating your applications.

Spotinst Elastigroup makes AWS CodeDeploy even more powerful! Save 90% of the infrastructure costs and increase performance.

In order to get Spotinst Elastigroup and AWS CodeDeploy integrated, please follow these steps.

  1. Create The Following IAM Role

    Associate the Elastigroup with your CodeDeploy IAM Instance Role. The Instance Role should have the following policy:

    {
        "Version": "2012-10-17",
        "Statement": [
             {
                            "Resource": "*",
                            "Action": [
                                    "autoscaling:Describe*",
                                    "cloudformation:Describe*",
                                    "cloudformation:GetTemplate",
                                    "s3:Get*",
                                    "codedeploy:*",
                                    "ec2:CreateTags",
                                    "ec2:DeleteTags",
                                    "ec2:TerminateInstances",
                                    "iam:PassRole"
                            ],
                            "Effect": "Allow"
                   }
             ]
    }

     

  2. User Data Startup Script

    #!/usr/bin/env bash
    curl -fsSL https://s3.amazonaws.com/spotinst-labs/aws-codedeploy/spotinst_aws_codedeploy.sh | \
    CODEDEPLOY_APPLICATION="myApplication" \
    CODEDEPLOY_DEPLOYMENT_GROUP="myDeploymentGroup" \
    CODEDEPLOY_CLEANUP_ON_FAILURE="1" \
    CODEDEPLOY_TERMINATE_INSTANCE_ON_FAILURE="1" \
    bash

     

    Note: Before using this user-data shell script, please set the following parameters:
    CODEDEPLOY_APPLICATION=”myApplication
    CODEDEPLOY_DEPLOYMENT_GROUP=”myDeploymentGroup

     

  • Pingback: AWS Week in Review – February 8, 2016 | wart1949()

  • Pingback: AWS Week in Review – February 8, 2016 – SMACBUZZ()

  • Probably there is no need in this – “yum update -y aws-cfn-bootstrap”.

    Article title is wrong (Elatigroup).

  • Spotinst

    Hello Anton,

    Thanks for your feedback!

    The aws-cfn-bootstrap is indeed not required.
    The blog title has been updated, and we also added an alternative way of getting the region from the instance meta-data service.

  • Pedro Vilaça

    Hi,

    I understand that you need that CodeDeploy is configured to use Tags instead of the ASG, because probably spotinst will create multiple ASG (I’m just guessing.. don’t know exactly what you do under the hood), but by doing that, we’re losing the ASG integration of CodeDeploy, that listens to ASG events and trigger a new deployment if an instance is added. Right?

    • Spotinst

      Hi Pedro,

      You won’t lose anything. Spotinst will do it for you out of the box without any life-cycle hooks. Our platform automatically starts a new deployment for every new instance that is added to your Elastigroup.