For quickly iterating on ec2 instance bootstrapping without having to go through a cloudformation deployment cycle:
- Install sshfs or its mac port
- Deploy via cloudformation with minimal userdata script
- Mount the
ec2-users
home directory in your project (we will use aremote
directory) - Copy the ops code into the
remote
directory - Edit files in the
remote
directory with your editor of choice set up as you have in your local env - Test your changes by executing them as root from an ssh session on the remote host
- When things work to your liking, copy the ops code from the
remote
directory back to its location in your project - Test bootstrapping via cloudformation stack deployment
If you want to have an easy way to do this in the future for a particular service (we'll call ours Petard), add the following to your ~/.bashrc
or ~/.profile
:
> export PETARD_KEY=...
> alias sshfs-petard='sshfs -o IdentityFile=${PETARD_KEY} ec2-user@${PETARD_HOST}:'
You will need the host name and private key for the ec2 instance you want to work with..
> export PETARD_HOST=....
> mkdir remote
> sshfs-petard remote
> cp -r ops/* remote
> cd remote
> vim install.sh
# or whatever editor you use
Assumes you've sshed in and have sudoed to root...
> cat /home/ec2-user/install.sh | bash -l
You could be rsynching, but not necessary with sshfs. Again, you will likely want to add this to your ~/.bashrc
or ~/.profile
:
> alias sshfs-sync='while true; do sleep ${DELAY:15}; cp ${REMOTE:=remote} ${LOCAL:=ops}; echo "Synched ${REMOTE} to ${LOCAL}"; done'
# osx
> umount mountpoint
# linux
> fusermount -u mountpoint