I did something very similar.
Create/start/stop/terminate EC2.
https://github.com/redoapp/fast-actions-runner-ec2