You actually don't need to write that AWS script - Docker has done that for you already, it's called "Docker Machine".
After you install docker machine and set up your credentials, it's really easy to create a new instance with docker installed - see amazonec2 driver.
docker-machine create --driver amazonec2 --amazonec2-region us-west-2 --amazonec2-ami $AMI_WITH_NVIDIA_DRIVERS --amazonec2-instance-type p2.xlarge my_awesome_machine_name
You may also want to change some of the other parameters (e.g. root hard drive size, zone, etc). Full AWS driver info
It will set up your VPC and security credentials automatically (default is a "docker-machine" security group whose permissions you can tweak on the AWS console or via command line).
As far as I can tell, there's no way to get it automatically to associate an elastic IP but it will recognize the new IP once you associate it.
After creating your instance, accessing it is easy, e.g.
docker-machine ssh my_awesome_machine_name
There are several other useful commands too (start, stop, status, ls, ip, env, regenerate-certs, etc).
In case things get messed up, the ssh keys are stored in ~/.docker/machine/machines/my_awesome_machine_name.