Use AutoSpotting with AWS CodeDeploy.

CodeDeploy Limitations

  • Doesn’t work on spot instances natively
  • Doesn’t work on instances that aren’t booted by the autoscaling group

Why this method

This method is to allow for AutoSpotting and spot instances to work around the limitations of CodeDeploy and get our code on newly booted spot instances

CodeDeploy Console

  • Setup the AWS CodeDeploy Deployment Groups to use Tag Groups
  • Groups should be based around the autoscaling groups you plan to use
  • For example:
    • Environment:staging
    • Product:nginx
    • Role:web

Instance AMI Scripts


  • This file will be sourced into our deployment script
    • get-meta
    • Save this file to /usr/bin/get-meta on the AMI to be used


  • A simple version of a deployment script that is ran on-boot
  • This file will need to be deployed to the same AMI
  • If you are using Amazon Linux saving this file to /etc/rc3.d/S99deploycode
    • This will make run it after all networking components are available