- Create a cloudformation template that provisions the following AWS resources:
- VPC
- Subnet
- Internet gateway (with route table entry)
- Security Group (to allow your IP in for SSH)
- IAM role that allows full AWS Route53 access
- Write an Ansible playbook that
- Runs the cloudformation template
- Provisions a Debian Stretch EC2 instance:
- In to the VPC created by cloudformation
- Using the official Debian Stretch AMI for your region of choice
- Has the IAM role created by cloudformation
- Write another Ansible playbook that sets up the EC2 instance Debian install:
- Adds a new user
- Installs docker and adds the new user to the docker group - Use the
tekniqueltd.docker
ansible role via ansible galaxy (also available on github)
- Create a Route53 domain for a domain or subdomain
- If you don't already have a domain, you can either register a new domain or grab a free subdomain (google free subdomains)
- Write a python script that updates an A record (under your domain) with the current public IP of the EC2 instance (diy dynamic DNS)
- Use the 'boto' library for AWS calls
- Use the 'requests' library with https://ifconfig.co/ (or similar) to get your current public IP
- Put it in a public git repository on github (create yourself an account if you don't have one)
- Write a Dockerfile to build a docker image that runs the above python script
- Use debian:stretch as the base image
- Dockerfile should be stored/versioned in the same git repository as the python logic
- Write a docker-compose file:
- Creates a docker bridge network
- Creates a docker storage volume
- Runs jenkins as a docker container
- With all jenkins data being stored in the storage volume
- On the bridge network
- Listening on TCP 80 (or ideally 443 with valid TLS provided by letsencrypt)
- Create a Jenkins job for the python script docker image
- Clones the python script repo
- Builds a docker image from the Dockerfile and tags it
- Pushes the docker image with the tag to a hub.docker.com docker repository (create one)
- Create another Jenkins job for the python script docker image
- Pulls the latest python script docker image
- Runs it
- Runs on a cron every minute
- Get the python script running using AWS Lambda (for a different A record)