<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
      <title>Strafo - openbao</title>
      <link>https://strafo.net</link>
      <description>Personal blog of a cat disguised as a human</description>
      <generator>Zola</generator>
      <language>en</language>
      <atom:link href="https://strafo.net/tags/openbao/rss.xml" rel="self" type="application/rss+xml"/>
      <lastBuildDate>Sat, 05 Dec 2026 00:00:00 +0000</lastBuildDate>
      <item>
          <title>Moving my homelab&#x27;s secrets out of GitLab using OpenBao and KMS on GCP</title>
          <pubDate>Sat, 05 Dec 2026 00:00:00 +0000</pubDate>
          <author>Andrea Straforini</author>
          <link>https://strafo.net/blog/openbao-iac-secrets/</link>
          <guid>https://strafo.net/blog/openbao-iac-secrets/</guid>
          <description xml:base="https://strafo.net/blog/openbao-iac-secrets/">&lt;p&gt;In &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;strafo.net&#x2F;blog&#x2F;iac-homelab&#x2F;&quot;&gt;&lt;em&gt;One-click homelab&lt;&#x2F;em&gt;&lt;&#x2F;a&gt; every piece of the homelab became a tag away from being rebuilt. The pipelines that do the rebuilding need secrets. They all lived where GitLab tells you to put them: masked, protected CI&#x2F;CD variables.&lt;&#x2F;p&gt;
&lt;p&gt;That&#x27;s fine, right up until you ask &lt;em&gt;who can decrypt them&lt;&#x2F;em&gt;.&lt;&#x2F;p&gt;
&lt;p style=&quot;text-align:center&quot;&gt;&lt;em&gt;Fair warning: this post was written wearing the hat below.&lt;&#x2F;em&gt;&lt;&#x2F;p&gt;
&lt;p style=&quot;text-align:center&quot;&gt;&lt;img src=&quot;tinfoil-hat.png&quot; alt=&quot;A man in a tinfoil hat: Are you ready?&quot; style=&quot;display:block;margin:25px auto;width:320px;max-width:100%;height:auto&quot;&gt;&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-problem&quot;&gt;The problem&lt;a class=&quot;post-anchor&quot; href=&quot;#the-problem&quot; aria-label=&quot;Anchor link for: the-problem&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;GitLab encrypts CI variables at rest, but the key lives on GitLab&#x27;s own application servers. That protects against a stolen database disk, not against a breach of GitLab itself: the attacker gets the ciphertext and the key together.&lt;&#x2F;p&gt;
&lt;p&gt;So the threat model is deliberately narrow: a platform-wide breach of GitLab, or of the cloud the secrets end up in. Nobody is targeting my homelab specifically (I hope!), so the heavyweight answers (keys split between several people, encrypted VMs, dedicated hardware) would guard against an adversary I don&#x27;t have (again, I hope). And if one shows up, the design is built from the same pieces enterprises use (KMS, IAP, workload identity), so breaking in would cost far more than my homelab&#x27;s secrets are worth.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-design&quot;&gt;The design&lt;a class=&quot;post-anchor&quot; href=&quot;#the-design&quot; aria-label=&quot;Anchor link for: the-design&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;The vault is &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;openbao.org&#x2F;&quot;&gt;OpenBao&lt;&#x2F;a&gt; on a single free-tier &lt;code&gt;e2-micro&lt;&#x2F;code&gt; in its own GCP project.&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;No public IP, no internet access.&lt;&#x2F;strong&gt; The VM reaches Google APIs through Private Google Access and nothing else. The OpenBao package is served from a bucket in the same project.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;One way in: IAP.&lt;&#x2F;strong&gt; Both I and CI reach port 8200 through Google&#x27;s Identity-Aware Proxy tunnel. There&#x27;s no SSH bastion, no VPN, no open port.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Unlocks itself with KMS.&lt;&#x2F;strong&gt; OpenBao starts locked after every restart and asks Google KMS to unlock it, so a reboot or a brand-new VM needs nothing from me. That&#x27;s how OS updates work: every apply replaces the VM with the latest Debian image and reattaches the data disk.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;A verified boot.&lt;&#x2F;strong&gt; The VM runs Debian&#x27;s official cloud image as a Shielded VM: it only boots a signed bootloader and kernel, and Google flags it if the boot ever looks different from the first good one. That catches a tampered OS, but not someone reading memory from Google&#x27;s side of the host. That would take a Confidential VM (see below).&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Only Google-signed identities can log in.&lt;&#x2F;strong&gt; OpenBao&#x27;s JWT auth method trusts Google&#x27;s signing keys and nothing else. I log in with my own identity token; each pipeline logs in as its own service account.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Everything is OpenTofu&lt;&#x2F;strong&gt;, applied from my laptop, never from CI. The thing that guards CI&#x27;s secrets shouldn&#x27;t be deployable by CI.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Secrets are laid out per component, named after the tag prefixes the IaC repo already uses (&lt;code&gt;exit-node&#x2F;1.0.12&lt;&#x2F;code&gt;, &lt;code&gt;sre-agent&#x2F;2.3.0&lt;&#x2F;code&gt;): &lt;code&gt;iac&#x2F;&amp;lt;component&amp;gt;&#x2F;*&lt;&#x2F;code&gt;, plus a small &lt;code&gt;iac&#x2F;shared&#x2F;&lt;&#x2F;code&gt; for the rare secret two components need. A single JSON file lists the components, and both sides of the system are generated from it.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;cost&quot;&gt;Cost&lt;a class=&quot;post-anchor&quot; href=&quot;#cost&quot; aria-label=&quot;Anchor link for: cost&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;About &lt;strong&gt;$0.15 a month&lt;&#x2F;strong&gt;, almost all of it KMS:&lt;&#x2F;p&gt;
&lt;table&gt;&lt;thead&gt;&lt;tr&gt;&lt;th&gt;&lt;&#x2F;th&gt;&lt;th&gt;Monthly&lt;&#x2F;th&gt;&lt;&#x2F;tr&gt;&lt;&#x2F;thead&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td&gt;&lt;code&gt;e2-micro&lt;&#x2F;code&gt; VM in us-central1&lt;&#x2F;td&gt;&lt;td&gt;$0 (Free Tier)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Boot and data disk, 10 GB &lt;code&gt;pd-standard&lt;&#x2F;code&gt; each&lt;&#x2F;td&gt;&lt;td&gt;$0 (in the 30 GB free)&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Public IP&lt;&#x2F;td&gt;&lt;td&gt;none: access is IAP only&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;Two KMS keys (unseal, OpenTofu state)&lt;&#x2F;td&gt;&lt;td&gt;~$0.12&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;tr&gt;&lt;td&gt;KMS calls, snapshot bucket, logs, IAP&lt;&#x2F;td&gt;&lt;td&gt;a few cents at most&lt;&#x2F;td&gt;&lt;&#x2F;tr&gt;
&lt;&#x2F;tbody&gt;&lt;&#x2F;table&gt;
&lt;p&gt;The same setup on a Spot VM in Paris with a public IP would be around $9.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;how-a-pipeline-gets-its-secrets&quot;&gt;How a pipeline gets its secrets&lt;a class=&quot;post-anchor&quot; href=&quot;#how-a-pipeline-gets-its-secrets&quot; aria-label=&quot;Anchor link for: how-a-pipeline-gets-its-secrets&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;div class=&quot;pipeline-diagram&quot; style=&quot;margin:25px 0&quot;&gt;
&lt;svg viewBox=&quot;0 0 760 520&quot; role=&quot;img&quot; aria-label=&quot;A GitLab job gets a JWT, impersonates ci-component through Workload Identity Federation, opens an IAP tunnel, logs in to OpenBao with a Google ID token and gets a 10-minute token that reads only its own secrets&quot; style=&quot;width:100%;height:auto;font-family:inherit;font-size:15px&quot;&gt;
&lt;defs&gt;&lt;marker id=&quot;pa&quot; viewBox=&quot;0 0 10 10&quot; refX=&quot;9&quot; refY=&quot;5&quot; markerWidth=&quot;7&quot; markerHeight=&quot;7&quot; orient=&quot;auto-start-reverse&quot;&gt;&lt;path d=&quot;M0,0 L10,5 L0,10 z&quot; style=&quot;fill:var(--accent-color,#ffa86a)&quot;&#x2F;&gt;&lt;&#x2F;marker&gt;&lt;&#x2F;defs&gt;
&lt;g style=&quot;fill:none;stroke:currentColor;stroke-opacity:.35;stroke-dasharray:6 5&quot;&gt;
&lt;rect x=&quot;10&quot; y=&quot;10&quot; width=&quot;240&quot; height=&quot;500&quot; rx=&quot;4&quot;&#x2F;&gt;
&lt;rect x=&quot;280&quot; y=&quot;10&quot; width=&quot;470&quot; height=&quot;500&quot; rx=&quot;4&quot;&#x2F;&gt;
&lt;&#x2F;g&gt;
&lt;g style=&quot;fill:currentColor;fill-opacity:.6;font-size:14px&quot;&gt;
&lt;text x=&quot;26&quot; y=&quot;36&quot;&gt;GITLAB&lt;&#x2F;text&gt;
&lt;text x=&quot;296&quot; y=&quot;36&quot;&gt;GOOGLE CLOUD · strafonet-vault&lt;&#x2F;text&gt;
&lt;&#x2F;g&gt;
&lt;g style=&quot;fill:currentColor;fill-opacity:.06;stroke:currentColor;stroke-opacity:.7&quot;&gt;
&lt;rect x=&quot;30&quot; y=&quot;60&quot; width=&quot;200&quot; height=&quot;70&quot; rx=&quot;4&quot;&#x2F;&gt;
&lt;rect x=&quot;30&quot; y=&quot;360&quot; width=&quot;200&quot; height=&quot;70&quot; rx=&quot;4&quot;&#x2F;&gt;
&lt;rect x=&quot;310&quot; y=&quot;60&quot; width=&quot;190&quot; height=&quot;70&quot; rx=&quot;4&quot;&#x2F;&gt;
&lt;rect x=&quot;550&quot; y=&quot;60&quot; width=&quot;180&quot; height=&quot;70&quot; rx=&quot;4&quot;&#x2F;&gt;
&lt;rect x=&quot;310&quot; y=&quot;230&quot; width=&quot;190&quot; height=&quot;70&quot; rx=&quot;4&quot;&#x2F;&gt;
&lt;&#x2F;g&gt;
&lt;rect x=&quot;550&quot; y=&quot;215&quot; width=&quot;180&quot; height=&quot;140&quot; rx=&quot;4&quot; style=&quot;fill:var(--accent-color,#ffa86a);fill-opacity:.1;stroke:var(--accent-color,#ffa86a);stroke-width:1.5&quot;&#x2F;&gt;
&lt;g style=&quot;fill:currentColor;text-anchor:middle&quot;&gt;
&lt;g style=&quot;font-weight:bold;font-size:17px&quot;&gt;
&lt;text x=&quot;130&quot; y=&quot;90&quot;&gt;CI job&lt;&#x2F;text&gt;
&lt;text x=&quot;130&quot; y=&quot;390&quot;&gt;TF_VAR_*&lt;&#x2F;text&gt;
&lt;text x=&quot;405&quot; y=&quot;90&quot;&gt;Workload Identity&lt;&#x2F;text&gt;
&lt;text x=&quot;640&quot; y=&quot;90&quot;&gt;ci-&amp;lt;component&amp;gt;&lt;&#x2F;text&gt;
&lt;text x=&quot;405&quot; y=&quot;260&quot;&gt;IAP tunnel&lt;&#x2F;text&gt;
&lt;text x=&quot;640&quot; y=&quot;245&quot;&gt;OpenBao&lt;&#x2F;text&gt;
&lt;&#x2F;g&gt;
&lt;g style=&quot;fill-opacity:.7;font-size:14px&quot;&gt;
&lt;text x=&quot;130&quot; y=&quot;113&quot;&gt;tag + own runner&lt;&#x2F;text&gt;
&lt;text x=&quot;130&quot; y=&quot;413&quot;&gt;tofu plan&#x2F;apply&lt;&#x2F;text&gt;
&lt;text x=&quot;405&quot; y=&quot;113&quot;&gt;checks the JWT&lt;&#x2F;text&gt;
&lt;text x=&quot;640&quot; y=&quot;113&quot;&gt;service account&lt;&#x2F;text&gt;
&lt;text x=&quot;405&quot; y=&quot;283&quot;&gt;port 8200 only&lt;&#x2F;text&gt;
&lt;text x=&quot;640&quot; y=&quot;267&quot;&gt;no public IP&lt;&#x2F;text&gt;
&lt;&#x2F;g&gt;
&lt;g style=&quot;font-size:14px&quot;&gt;
&lt;text x=&quot;640&quot; y=&quot;305&quot;&gt;role &amp;lt;component&amp;gt;&lt;&#x2F;text&gt;
&lt;text x=&quot;640&quot; y=&quot;327&quot;&gt;iac&#x2F;&amp;lt;component&amp;gt;&#x2F;*&lt;&#x2F;text&gt;
&lt;&#x2F;g&gt;
&lt;&#x2F;g&gt;
&lt;g style=&quot;fill:none;stroke:var(--accent-color,#ffa86a);stroke-width:1.75&quot; marker-end=&quot;url(#pa)&quot;&gt;
&lt;path d=&quot;M230,95 H306&quot;&#x2F;&gt;
&lt;path d=&quot;M500,95 H546&quot;&#x2F;&gt;
&lt;path d=&quot;M130,130 V265 H306&quot;&#x2F;&gt;
&lt;path d=&quot;M500,265 H546&quot;&#x2F;&gt;
&lt;path d=&quot;M640,130 V211&quot;&#x2F;&gt;
&lt;path d=&quot;M640,355 V395 H234&quot;&#x2F;&gt;
&lt;&#x2F;g&gt;
&lt;g style=&quot;fill:var(--accent-color,#ffa86a);font-size:15px&quot;&gt;
&lt;text x=&quot;240&quot; y=&quot;84&quot;&gt;1. JWT&lt;&#x2F;text&gt;
&lt;text x=&quot;140&quot; y=&quot;200&quot;&gt;2. tunnel&lt;&#x2F;text&gt;
&lt;text x=&quot;630&quot; y=&quot;168&quot; style=&quot;text-anchor:end&quot;&gt;3. ID token&lt;&#x2F;text&gt;
&lt;text x=&quot;630&quot; y=&quot;188&quot; style=&quot;text-anchor:end;fill:currentColor;fill-opacity:.7;font-size:13px&quot;&gt;aud=openbao&lt;&#x2F;text&gt;
&lt;text x=&quot;290&quot; y=&quot;385&quot;&gt;4. 10-min token + values&lt;&#x2F;text&gt;
&lt;text x=&quot;26&quot; y=&quot;462&quot;&gt;5. revoke token,&lt;&#x2F;text&gt;
&lt;text x=&quot;53&quot; y=&quot;482&quot;&gt;kill tunnel,&lt;&#x2F;text&gt;
&lt;text x=&quot;53&quot; y=&quot;502&quot;&gt;wipe temp dir&lt;&#x2F;text&gt;
&lt;&#x2F;g&gt;
&lt;&#x2F;svg&gt;
&lt;&#x2F;div&gt;
&lt;p&gt;Step by step:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;GitLab mints a JWT&lt;&#x2F;strong&gt; for the job. The Workload Identity Federation provider only accepts it if it comes from the IaC project, from a &lt;strong&gt;protected tag&lt;&#x2F;strong&gt;, on one of &lt;strong&gt;my own runners&lt;&#x2F;strong&gt;. The tag prefix becomes an attribute, and only jobs whose tag starts with &lt;code&gt;exit-node&#x2F;&lt;&#x2F;code&gt; may impersonate &lt;code&gt;ci-exit-node&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;The job opens the IAP tunnel&lt;&#x2F;strong&gt; as that service account, which is allowed to tunnel to port 8200 and nothing else.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;It asks Google for an ID token&lt;&#x2F;strong&gt; for &lt;code&gt;ci-&amp;lt;component&amp;gt;&lt;&#x2F;code&gt;, with audience &lt;code&gt;openbao&lt;&#x2F;code&gt;.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;OpenBao checks the token&lt;&#x2F;strong&gt; against Google&#x27;s keys, matches the email to the role, and hands back a token valid for &lt;strong&gt;10 minutes&lt;&#x2F;strong&gt;, whose policy reads &lt;code&gt;iac&#x2F;&amp;lt;component&amp;gt;&#x2F;*&lt;&#x2F;code&gt; and nothing more.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;The values become &lt;code&gt;TF_VAR_*&lt;&#x2F;code&gt; variables&lt;&#x2F;strong&gt; for the plan or apply, the token is revoked, the tunnel is killed, and the temp directory is deleted. That happens on every exit path, including failures.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;h2 id=&quot;wiring-it-into-the-iac-repo&quot;&gt;Wiring it into the IaC repo&lt;a class=&quot;post-anchor&quot; href=&quot;#wiring-it-into-the-iac-repo&quot; aria-label=&quot;Anchor link for: wiring-it-into-the-iac-repo&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;The IaC repo gets one include, &lt;code&gt;.gitlab&#x2F;ci&#x2F;openbao.yml&lt;&#x2F;code&gt;, with a hidden &lt;code&gt;.openbao&lt;&#x2F;code&gt; job. It asks GitLab for the JWT and sources a small shell script before the job runs.&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #F8F8F2; background-color: #272822;&quot;&gt;&lt;code data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;.openbao&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;  id_tokens&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;    OPENBAO_GITLAB_JWT&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;      aud&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt; https:&#x2F;&#x2F;iam.googleapis.com&#x2F;projects&#x2F;&amp;lt;project-number&amp;gt;&#x2F;locations&#x2F;global&#x2F;workloadIdentityPools&#x2F;gitlab&#x2F;providers&#x2F;gitlab-com&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;  before_script&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;    -&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt; . &amp;quot;$CI_PROJECT_DIR&#x2F;.gitlab&#x2F;ci&#x2F;openbao.sh&amp;quot; &amp;amp;&amp;amp; openbao_load&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;A component opts in by adding it next to the OpenTofu templates it already uses, and by saying which secrets go into which variables:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #F8F8F2; background-color: #272822;&quot;&gt;&lt;code data-lang=&quot;yaml&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;opentofu-plan-production-sre-agent&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;  extends&lt;&#x2F;span&gt;&lt;span&gt;: [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt;.opentofu:plan&lt;&#x2F;span&gt;&lt;span&gt;,&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt; .openbao&lt;&#x2F;span&gt;&lt;span&gt;]&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;  variables&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;    OPENBAO_COMPONENT&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt; &amp;quot;sre-agent&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;    OPENBAO_ENV&lt;&#x2F;span&gt;&lt;span&gt;:&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F92672;&quot;&gt; |&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt;      TF_VAR_sre_agent_telegram_bot_token=sre-agent&#x2F;telegram#bot_token&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt;      TF_VAR_sre_agent_gatus_token=shared&#x2F;gatus&#x2F;sre-agent#token&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Each line is &lt;code&gt;TF_VAR_name=path#field&lt;&#x2F;code&gt;, read from &lt;code&gt;iac&#x2F;&amp;lt;path&amp;gt;&lt;&#x2F;code&gt;. The OpenTofu code doesn&#x27;t change at all: it still gets the same &lt;code&gt;TF_VAR_*&lt;&#x2F;code&gt; variables, they just come from somewhere else.&lt;&#x2F;p&gt;
&lt;p&gt;The script&#x27;s entry point reads like the steps above:&lt;&#x2F;p&gt;
&lt;pre class=&quot;giallo&quot; style=&quot;color: #F8F8F2; background-color: #272822;&quot;&gt;&lt;code data-lang=&quot;shellscript&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #A6E22E;&quot;&gt;openbao_load&lt;&#x2F;span&gt;&lt;span&gt;() {&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #88846F;&quot;&gt;  # GitLab&amp;#39;s CI_DEBUG_TRACE would print every value&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;  case&lt;&#x2F;span&gt;&lt;span style=&quot;color: #FD971F;&quot;&gt; $-&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F92672;&quot;&gt; in *&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt;x&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;*)&lt;&#x2F;span&gt;&lt;span&gt; openbao_xtrace&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt;1&lt;&#x2F;span&gt;&lt;span&gt; &amp;amp;&amp;amp;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #66D9EF;&quot;&gt; set&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt; +x&lt;&#x2F;span&gt;&lt;span&gt; ;;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F92672;&quot;&gt; *)&lt;&#x2F;span&gt;&lt;span&gt; openbao_xtrace&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt; ;;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F92672;&quot;&gt; esac&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F92672;&quot;&gt; -n&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt; &amp;quot;${&lt;&#x2F;span&gt;&lt;span&gt;OPENBAO_COMPONENT&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;:-&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt;}&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; ]&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F92672;&quot;&gt; ||&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A6E22E;&quot;&gt; openbao_fail&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt; &amp;quot;OPENBAO_COMPONENT is not set&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  openbao_tmp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F92672;&quot;&gt;=&lt;&#x2F;span&gt;&lt;span&gt;$(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A6E22E;&quot;&gt;mktemp&lt;&#x2F;span&gt;&lt;span style=&quot;color: #AE81FF;&quot;&gt; -d&lt;&#x2F;span&gt;&lt;span&gt;)&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #66D9EF;&quot;&gt;  trap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt; openbao_disconnect EXIT&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #A6E22E;&quot;&gt;  openbao_install&lt;&#x2F;span&gt;&lt;span style=&quot;color: #88846F;&quot;&gt;     # pinned gcloud, checked by hash&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #A6E22E;&quot;&gt;  openbao_connect&lt;&#x2F;span&gt;&lt;span style=&quot;color: #88846F;&quot;&gt;     # IAP tunnel, Google ID token, OpenBao login&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #A6E22E;&quot;&gt;  openbao_export&lt;&#x2F;span&gt;&lt;span style=&quot;color: #88846F;&quot;&gt;      # one TF_VAR_* per OPENBAO_ENV line&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #A6E22E;&quot;&gt;  openbao_disconnect&lt;&#x2F;span&gt;&lt;span style=&quot;color: #88846F;&quot;&gt;  # revoke the token, kill the tunnel, delete the temp dir&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #66D9EF;&quot;&gt;  trap&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt; - EXIT&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #66D9EF;&quot;&gt;  echo&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt; &amp;quot;openbao: loaded $(&lt;&#x2F;span&gt;&lt;span style=&quot;color: #66D9EF;&quot;&gt;printf&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt; &amp;#39;%s\n&amp;#39; &amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;$OPENBAO_ENV&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F92672;&quot;&gt; |&lt;&#x2F;span&gt;&lt;span style=&quot;color: #A6E22E;&quot;&gt; grep&lt;&#x2F;span&gt;&lt;span style=&quot;color: #AE81FF;&quot;&gt; -c&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt; =) variables for &lt;&#x2F;span&gt;&lt;span&gt;$OPENBAO_COMPONENT&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;  [&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F92672;&quot;&gt; -z&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt; &amp;quot;&lt;&#x2F;span&gt;&lt;span&gt;$openbao_xtrace&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt;&amp;quot;&lt;&#x2F;span&gt;&lt;span&gt; ]&lt;&#x2F;span&gt;&lt;span style=&quot;color: #F92672;&quot;&gt; ||&lt;&#x2F;span&gt;&lt;span style=&quot;color: #66D9EF;&quot;&gt; set&lt;&#x2F;span&gt;&lt;span style=&quot;color: #AE81FF;&quot;&gt; -x&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span style=&quot;color: #66D9EF;&quot;&gt;  unset&lt;&#x2F;span&gt;&lt;span style=&quot;color: #E6DB74;&quot;&gt; openbao_xtrace&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span&gt;}&lt;&#x2F;span&gt;&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;There&#x27;s no custom image: each job downloads a pinned gcloud, checks its hash, and only uses it for the tunnel.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;three-ways-back&quot;&gt;Three ways back&lt;a class=&quot;post-anchor&quot; href=&quot;#three-ways-back&quot; aria-label=&quot;Anchor link for: three-ways-back&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;A vault you can lose is worse than no vault, so there are three independent ways back:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Raft snapshots every 6 hours&lt;&#x2F;strong&gt; to a bucket with a &lt;strong&gt;locked retention policy&lt;&#x2F;strong&gt;: not even I can delete them early. Failed runs send an email, and a restore test proves the snapshots actually restore.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;A recovery key&lt;&#x2F;strong&gt;, for the day Google login breaks.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;An &lt;code&gt;age&lt;&#x2F;code&gt;-encrypted export&lt;&#x2F;strong&gt; of every secret, restorable without GCP. Either of &lt;strong&gt;two passphrase-locked keys&lt;&#x2F;strong&gt;, kept in different places, opens it.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Both export keys are post-quantum, which age supports since version 1.3 (&lt;code&gt;age-keygen -pq&lt;&#x2F;code&gt;). After the &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;www.cisa.gov&#x2F;news-events&#x2F;news&#x2F;joint-statement-recent-advances-cryptographic-and-cybersecurity-capabilities&quot;&gt;joint statement&lt;&#x2F;a&gt; from ONCD, NSA and CISA on new attacks against today&#x27;s cryptography, that felt like the sensible default.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;possible-improvements&quot;&gt;Possible improvements&lt;a class=&quot;post-anchor&quot; href=&quot;#possible-improvements&quot; aria-label=&quot;Anchor link for: possible-improvements&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;One upgrade is planned, and one I left out on purpose because it guards against a stronger attacker than the one I&#x27;m planning for:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;An HSM-backed unseal key (planned), about $1 a month.&lt;&#x2F;strong&gt; Today the KMS key is software-protected. At the HSM level it would live in certified hardware that never lets it out. It&#x27;s one setting in OpenTofu, but the protection level of an existing key can&#x27;t change, so it means a new key and a seal migration.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;A Confidential VM (not planned, maybe when I have a decent salary), about $74 a month.&lt;&#x2F;strong&gt; The VM&#x27;s memory would be encrypted even from Google&#x27;s hosts. The free &lt;code&gt;e2-micro&lt;&#x2F;code&gt; doesn&#x27;t support it, hence the price. On its own it buys little: with KMS auto-unseal, anyone who controls the project can still ask KMS for the key. The real gain needs the key released only to a verified VM image, which is a much bigger redesign.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;closing&quot;&gt;Closing&lt;a class=&quot;post-anchor&quot; href=&quot;#closing&quot; aria-label=&quot;Anchor link for: closing&quot;&gt;&lt;span aria-hidden=&quot;true&quot;&gt;#&lt;&#x2F;span&gt;&lt;&#x2F;a&gt;
&lt;&#x2F;h2&gt;
&lt;p&gt;Security isn&#x27;t about finding the one provider you can trust. It&#x27;s about layers, so that a single mistake or a single leak isn&#x27;t enough: defense in depth, homelab edition.&lt;&#x2F;p&gt;
&lt;p&gt;Total cost: one coffee a year. Total drama: hopefully zero.&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;section class=&quot;alert note&quot; role=&quot;note&quot; aria-labelledby=&quot;Yo8JWS1N&quot;&gt;
    &lt;div class=&quot;alert-icon alert-icon-info&quot;&gt;&lt;&#x2F;div&gt;
    &lt;div class=&quot;alert-content&quot; role=&quot;presentation&quot;&gt;
        &lt;strong id=&quot;Yo8JWS1N&quot; class=&quot;alert-title&quot; aria-hidden=&quot;true&quot;&gt;License&lt;&#x2F;strong&gt;
        &lt;p&gt;This article is licensed under the &lt;a rel=&quot;noopener external&quot; target=&quot;_blank&quot; href=&quot;https:&#x2F;&#x2F;creativecommons.org&#x2F;licenses&#x2F;by-sa&#x2F;4.0&#x2F;&quot;&gt;CC BY-SA 4.0 license&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;

    &lt;&#x2F;div&gt;
&lt;&#x2F;section&gt;
</description>
      </item>
    </channel>
</rss>
