<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Automation on Cloudy Mountains</title><link>https://cloudymountains.cloud/tags/automation/</link><description>Recent content in Automation on Cloudy Mountains</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Sun, 01 Nov 2026 23:30:23 +0200</lastBuildDate><atom:link href="https://cloudymountains.cloud/tags/automation/index.xml" rel="self" type="application/rss+xml"/><item><title>Enforcing AWS Resource Tags with OPA</title><link>https://cloudymountains.cloud/projects/policy-as-code/enforce-aws-tags-opa/</link><pubDate>Fri, 13 Jun 2025 13:00:44 +0100</pubDate><guid>https://cloudymountains.cloud/projects/policy-as-code/enforce-aws-tags-opa/</guid><description>&lt;p>In &lt;a href="https://cloudymountains.cloud/projects/policy-as-code/policy-as-code-opa-terraform/">Part 1&lt;/a> of this series, we covered the basics of Policy as Code and how the shift-left approach helps catch infrastructure mistakes early. In this post, we’re putting theory into practice—specifically, how to enforce AWS tagging strategy using Open Policy Agent (OPA) during Terraform plan phase/stage.&lt;/p>
&lt;p>This isn’t just about tagging hygiene. Good tagging is foundational for tracking cloud costs, understanding ownership, and avoiding dangerous or expensive mistakes.&lt;/p>
&lt;h2 id="why-tags-matter">Why Tags Matter&lt;/h2>
&lt;p>Tags seem trivial—until you’re staring at a $1M AWS bill and have no idea where it came from.&lt;/p></description></item><item><title>Hugo on S3 and CloudFront with Terraform and GitHub Actions OIDC</title><link>https://cloudymountains.cloud/projects/static-site-s3-cloudfront/</link><pubDate>Fri, 06 Jun 2025 12:20:44 +0100</pubDate><guid>https://cloudymountains.cloud/projects/static-site-s3-cloudfront/</guid><description>&lt;p>When I decided to build my own site, I knew I wanted something fast, scalable, and modern — not just in terms of the tech stack, but also in the way it’s managed and deployed. This post walks you through exactly how my site (Cloudy Mountains) is deployed using &lt;strong>Hugo&lt;/strong>, &lt;strong>AWS (S3 + CloudFront)&lt;/strong>, &lt;strong>Terraform&lt;/strong>, &lt;strong>GitHub Actions&lt;/strong>, and &lt;strong>OIDC&lt;/strong> authentication. I’ll show you the challenges that I had and how to solve them properly.&lt;/p></description></item><item><title>Testing Terraform Plans with OPA and Conftest (and Atlantis)</title><link>https://cloudymountains.cloud/projects/policy-as-code/policy-as-code-opa-terraform/</link><pubDate>Thu, 15 May 2025 23:58:44 +0100</pubDate><guid>https://cloudymountains.cloud/projects/policy-as-code/policy-as-code-opa-terraform/</guid><description>&lt;p>As I mentioned in my &lt;a href="https://cloudymountains.cloud/projects/policy-as-code/intro-opa-terraform/">previous blog post&lt;/a>, my first OPA policy was just to catch one simple parameter, if we have in the S3 Terrafom module set the &lt;code>force_destroy = true&lt;/code>.&lt;/p>
&lt;p>Here&amp;rsquo;s a simple OPA policy that will catch this dangerous configuration:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-rego" data-lang="rego">&lt;span class="line">&lt;span class="cl">&lt;span class="kd">package&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">terraform&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="nx">plan&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="n">deny&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="nx">msg&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">{&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="c"># Find all resources in the plan&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nx">resource&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">:=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nx">input&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="nx">resource_changes&lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="nx">_&lt;/span>&lt;span class="p">]&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> 
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="c"># Check if it&amp;#39;s an S3 bucket&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nx">resource&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="nx">type&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">==&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s2">&amp;#34;aws_s3_bucket&amp;#34;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> 
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="c"># Look for force_destroy in the configuration&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nx">resource&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="nx">change&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="nx">after&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="nx">force_destroy&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">==&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="kc">true&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> 
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nx">msg&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">:=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nf">sprintf&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s2">&amp;#34;S3 bucket &amp;#39;%s&amp;#39; has force_destroy set to true. This is dangerous as it allows bucket deletion even when not empty.&amp;#34;&lt;/span>&lt;span class="o">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">[&lt;/span>&lt;span class="nx">resource&lt;/span>&lt;span class="o">.&lt;/span>&lt;span class="nx">address&lt;/span>&lt;span class="p">])&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">}&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>This policy works by:&lt;/p></description></item><item><title>Shift-Left Cost Checks for Terraform with OPA and Terracost</title><link>https://cloudymountains.cloud/projects/policy-as-code/shift-left-opa-terracost/</link><pubDate>Fri, 31 May 2024 13:00:44 +0100</pubDate><guid>https://cloudymountains.cloud/projects/policy-as-code/shift-left-opa-terracost/</guid><description>&lt;h2 id="introduction">Introduction&lt;/h2>
&lt;p>In the fast-evolving world of cloud computing, managing costs effectively has become a crucial aspect of maintaining a sustainable and profitable business. The &amp;ldquo;Shift left&amp;rdquo; paradigm, originally a concept in software development, emphasizes the importance of addressing potential issues early in the development process. When applied to AWS cost optimization and management, this approach ensures that cost considerations are integrated into the earliest stages of the development lifecycle.&lt;/p>
&lt;p>By shifting cost management left, organizations can avoid unexpected expenses and optimize their cloud spending proactively. This blog post explores the application of the &amp;ldquo;Shift left&amp;rdquo; paradigm to AWS cost optimization, focusing on tools like Open Policy Agent (OPA) policies, Infracost, and Terracost. We will delve into how these tools can help estimate and control costs efficiently, ensuring that your AWS resources are both cost-effective and aligned with your financial goals.&lt;/p></description></item></channel></rss>