Skip to content

Instantly share code, notes, and snippets.

@lwoodson
Last active September 15, 2017 15:22
Show Gist options
  • Save lwoodson/50556c7538949d9d62bed8d4cea05c3f to your computer and use it in GitHub Desktop.
Save lwoodson/50556c7538949d9d62bed8d4cea05c3f to your computer and use it in GitHub Desktop.

For quickly iterating on ec2 instance bootstrapping without having to go through the CFN deployment cycle:

  1. Install sshfs or its mac port
  2. Deploy via CFN with minimal userdata script
  3. Mount the ec2-users home directory in your project (we will use a remote directory)
  4. Copy the ops code into the remote directory
  5. Edit files in the remote directory with your editor of choice set up as you have in your local env
  6. Test your changes by executing them as root from an ssh session on the remote host
  7. When things work to your liking, copy the ops code from the remote directory back to its location in your project
  8. Test bootstrapping via cloudformation stack deployment

One time set up for a service (Sodexo example)

If you want to have an easy way to do this in the future for a particular service....

> export SODEXO_HOST=...
> export SODEXO_KEY=...
> alias sshfs-sodexo='sshfs -o IdentityFile=${SODEXO_KEY} ec2-user@${SODEXO_HOST}:'

Mounting your ops code to the remote host

> mkdir remote
> sshfs-sodexo remote
> cp -r deploy/* remote

Editing your ops code on the remote host (install.sh example)

> cd remote
> vim install.sh
# or whatever you want to do.

Testing your ops code on the remote host (install.sh example)

Assumes you've sshed in and have sudoed to root...

> cat /home/ec2-user/install.sh | bash -l
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment