ferricoxide<p><span>I love </span><a href="https://evil.social/tags/regex" rel="nofollow noopener" target="_blank">#regex</a><span> based tools like </span><code>sed</code><span>.<br><br>Customer wanted me to set up some automation to capture what it was they had previously been doing by hand. One of those hand-jammed components was a custom </span><a href="https://evil.social/tags/RDS" rel="nofollow noopener" target="_blank">#RDS</a><span> parameter-group that they'd attached to their reference (</span><a href="https://evil.social/tags/postgresql" rel="nofollow noopener" target="_blank">#postgresql</a><span>) database. There were a couple-hundred settings in it, so I wasn't jazzed about trying to hand-capture that into a </span><a href="https://evil.social/tags/Terraform" rel="nofollow noopener" target="_blank">#Terraform</a><span> or </span><a href="https://evil.social/tags/Ansible" rel="nofollow noopener" target="_blank">#Ansible</a><span> workflow. <br><br>However, I was able to automate ganking their hand-jammed content and replicate it in a </span><a href="https://evil.social/tags/Terraform" rel="nofollow noopener" target="_blank">#Terraform</a><span> template. First, I combined a couple, nested </span><code>aws rds …</code><span> queries to fetch the data. The I wrote a multi-line </span><code>sed</code><span> filter to reformat the </span><code>aws rds …</code><span> queries' JSON output into TF-compatible config stanzas. Ran the resulting TF module through </span><code>terraform fmt</code><span>, </span><code>terraform validate</code><span> and then a </span><code>terraform apply</code><span> and I suddenly had a new RDS parameter-group in my dev-account that seemingly mirrors what was in the customer's production account. All told, took about half an hour to get the </span><code>aws</code><span> queries and, especially, the </span><code>sed</code><span> commands worked out. It had initially looked like it might have taken me all day (had I not been able to pipeline it).</span></p>