This is just plain a bad idea. Bash is the worst possible language. Yes, it can do it, but the syntax is awful. The problem of single quotes in double quotes in escaped double quotes.
I replaced a home grown, written by someone else, bash configuration management tool with Salt. The difference was huge.
Configuration management tools give you built-in logging, state checking, return codes, template libraries, and access to very mature models to access things like the AWS api.
I realize people don't like the steep learning curve, but there is a reason for it.