Open phildini opened 1 year ago
Ok, this did not take long, but I'm already vaguely annoyed at bookwyrm's docker-compose.yml, specifically because of:
db:
build: postgres-docker
env_file: .env
entrypoint: /bookwyrm-entrypoint.sh
command: cron postgres
volumes:
- pgdata:/var/lib/postgresql/data
- backups:/backups
networks:
- main
Because they're defining their own postgres container, we don't get to take easy advantage of "knowing" this should actually be an RDS.
Although! Detecting that there's a volume called pgdata
might be enough?
Ok, so using https://sourceforge.net/projects/ruamel-yaml/ (Sourceforge! What a rush!) I was able to parse the takahe docker-compose.yml.
It is annoying to me that this library strictly deals in orderedDicts
, so my common repl tools are useless, but on the bright side ruamel/PyYaml auto-includes anchors.
So now I have rough parsing of the docker-compose, and I need to figure out what to do with it.
My first thought was cookiecutter, but I think that might be too heavy-weight? I think what I'm going to do instead is use jinja-fied versions of a standard terraform, and see how far I can get with that.
TODO added: look into how much flexibility there is in terraform resource naming
This ticket is designed to be a long-form research ticket, with me working in public as I work out the first version of python script to convert a specific docker-compose file (ideally, the one from https://github.com/bookwyrm-social/bookwyrm) into a set of terraform files that I actually believe will do the thing.
Here's the steps as I see them: