If you're tired of manually creating AWS resources and spending hours on infrastructure tasks, here is a walkthrough of how you can automate all the tedious work, so you can spend your time on more important tasks.
I've built and launched 5 different micro-SaaS on Product Hunt, and one of the most tedious parts is generating the infrastructure and generating the backend. I'm deploying everything on AWS, so I always have the same set of resources I'm using:
I used to create each resource manually in the AWS dashboard, which took me about ~2 hours. Then I finally switched to infrastructure as code, using YML files with AWS Cloudformation (similar to Terraform but AWS native).
YML files and Cloudformation saved me a whole hour, but it still took me ~1 hour from start to finish.
The biggest problem is not really the hour it takes to add all the resources and deploy. My biggest concern was mainly copying and pasting different resource snippets from different files and always getting a variable wrong and debugging.
So I finally sat down and
1. built a simple frontend for picking all the resources and
2. wrote a script that generates all the code needed.
Some of the most tedious tasks are now fully automated:
- Generating YAML files for all the resources - Creating infrastructure files - Creating repos (GitHub API) - Creating branches (GitHub API) - Creating CI/CD pipelines (GitHub actions) - Adding encrypted secrets (GitHub API) - Creating pull requests (GitHub API) - Merging pull requests (GitHub API)
I went from ~2 hours to ~10 minutes:
I shared this process during two hackathons:
With these replies:
Here are the steps we'll go through in this guide and fully automate with Python scripts:
- Creating YAML files for all the resources
- Creating infrastructure files
- Creating CI/CD pipelines (GitHub actions)
- Creating repos (GitHub API)
- Renaming branches (GitHub API)
- Push to origin (GitHub API)
- Add encrypted secrets (GitHub API)
- Creating branches (GitHub API)
- Making a branch default (GitHub API)
- Creating workflow status listener (GitHub API)
- Creating pull requests (GitHub API)
- Creating pull request status listener (GitHub API)
- Merging pull requests (GitHub API)
Now that we have the background let's look at how I built the system.
This walkthrough is divided into 3 parts: