<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>tywer.dev</title>
        <link>https://tywer.dev/</link>
        <description>I architect cloud infrastructure by day and build private, self-hosted services by night. Writing about enterprise DevOps, privacy, and open-source software.</description>
        <lastBuildDate>Wed, 11 Nov 2026 05:04:25 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>tywer.dev</title>
            <url>https://tywer.dev/images/profile.webp</url>
            <link>https://tywer.dev/</link>
        </image>
        <copyright>Copyright (c) 2026 Tyler Harris</copyright>
        <atom:link href="https://tywer.dev/feed.xml" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[You Can't Take the Fix If You're Already End of Life]]></title>
            <link>https://tywer.dev/you-cant-take-the-fix-if-youre-already-end-of-life</link>
            <guid isPermaLink="false">https://tywer.dev/you-cant-take-the-fix-if-youre-already-end-of-life</guid>
            <pubDate>Sun, 08 Nov 2026 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>A security advisory only helps if you can still take the fix. I built
<a href="https://eol.watch/" target="_blank" rel="noreferrer">eol.watch</a> so an end-of-life date reaches you with time to
plan the upgrade. Where that tracking already exists, it usually lands too late,
and the upgrade shows up as an unplanned priority nobody wants to own.</p>
<p><img src="https://tywer.dev/images/eol-watch.webp" alt="eol.watch"></p>
<p>October was a clean example. That month, Node.js published security releases
for the versions it still maintains. The one that spread is
<a href="https://nvd.nist.gov/vuln/detail/cve-2026-111497" target="_blank" rel="noreferrer">CVE-2026-111497</a>. NVD scores
it 9.2, critical. The writeups call it Node2Shell, and also HTTP2Shell. Node.js
<a href="https://nodejs.org/en/blog/vulnerability/october-2026-security-releases" target="_blank" rel="noreferrer">rates the issue high</a>:
a flaw in the Brotli decoder bundled with Node, where malformed compressed
input can write past an internal buffer. An application that decompresses
Brotli data an attacker supplied can crash, leak process memory, or run code.</p>
<p>The fixes went only to versions Node.js still maintains. The
<a href="https://nodejs.org/en/blog/vulnerability/october-2026-security-releases" target="_blank" rel="noreferrer">announcement</a>
says end-of-life versions are always affected when a security release occurs.
<a href="https://endoflife.date/nodejs" target="_blank" rel="noreferrer">Node 20</a> and 18 got no release for this. On a
supported version, the response is a patch. On older versions, it is a major upgrade,
with breaking changes you would want more time to digest.</p>
<h2 id="step-zero-is-being-able-to-take-the-fix" tabindex="-1">Step zero is being able to take the fix </h2>
<p>The stream of vulnerability reports this year has a precondition that rarely
makes the headline. Before the score, before the exploit chatter, before the
Friday thread asking whether it is in our environment: if a fix exists, can we
absorb it?</p>
<p>On a supported release, the answer is a change window. You take the patch, you
test it, you roll it. The work is real, and it has an edge. The vendor already
produced a fix for the version you run.</p>
<p>Past end of life, that option is gone. There is nothing to apply. What you get
instead is an unplanned priority: change the dependency now, on a release the
tests have already covered. You were going to have to move eventually. You are
now doing it when a dependency change is the risky move, and the person who
makes it typically owns whatever breaks.</p>
<p>Scanners, SBOMs, and patch SLAs sit on top of that precondition. They find the
issue and record when it is closed, which only works if the version you run
still receives fixes. Step zero is running a version that does.</p>
<h2 id="the-date-was-public-the-urgency-was-not" tabindex="-1">The date was public. The urgency was not. </h2>
<p>End-of-life dates are often published years ahead. Kubernetes, Node.js, Postgres, the
distro under the cluster, the framework an app was generated with: the vendor
put the calendar in the open.</p>
<p>We often already track end of life on dependencies. Plenty of enterprises
have some version of that: a dependency scan, or someone watching release
notes. The signal is real, and a lot of the time it lands too late in the
cycle to do anything about it. By the time a dependency scan or a pipeline
check says the version is eol, that version has already been validated for
a release that has natural pressure to ship now.</p>
<p>Nobody wants to update a dependency at that point. It can break things. It
adds risk the team has already signed off on. Across teams, the person who
changes it becomes the owner, because they &quot;broke it.&quot; Late in a release, that
change is often treated as too risky to attempt. So the version stays, and the
next advisory finds you are still on it.</p>
<p>The version was current when it went into the build. Its end date was already
published. It got old by staying. A major jump planned
across a quarter is a project, with time to read the breaking changes and time
to test them before anyone has to own the fallout. The same jump, forced
because your version will never receive the fix, skips that.</p>
<p>If the lifecycle date was already the deadline, the CVE arrives while you are
still on a version that receives fixes. The next version is already chosen.
The finding is then simply a patch, not a new project.</p>
<h2 id="a-calendar-for-the-stack-i-actually-run" tabindex="-1">A calendar for the stack I actually run </h2>
<p>I am bad at remembering which things I run are quietly aging out, especially for
personal projects. A spreadsheet might be where this ends up, and it stays right only if
someone keeps editing it. A calendar reminder is the same problem with more setup:
one event per product, pinned to the date you knew that day. Vendors move those
dates, often enough that last quarter's row or reminder is already wrong.
Opening <a href="https://endoflife.date" target="_blank" rel="noreferrer">endoflife.date</a> when I happen to think of it
is the habit that fails on the week I am busy.</p>
<p><a href="https://eol.watch/" target="_blank" rel="noreferrer">eol.watch</a> follows that dataset. You subscribe to the
products you actually run, and it sends a reminder when a date is getting close:
as far out as a year, then six months, three months, a month, a week, and the
day it happens. Email, or a webhook into the chat channel you already watch.</p>
<p>The early reminders are the point. A year out, the upgrade can go on a roadmap. A
week out, it is a reminder that the roadmap slipped. The day of, with no
earlier warning, is how a lifecycle date turns into the week Node just handed
everyone still running 20 or 18.</p>
<p>That is the shift-left. The scan in the pipeline still matters. It tells you
what you are about to ship. A reminder a year before end of life gives you time
to prioritize the upgrade, before that version is locked into the next releases.</p>
<p>Keeping a pulse that early is what makes the later check boring.</p>
<p>You can track a small personal stack for free. The longer look-ahead is there
when the list, or the planning horizon, outgrows that.</p>
<p>It watches lifecycle dates. A dependency report already covers what is in
a build. That version was current when it got there. It aged by staying.
The reminder comes before anyone notices that in the report.</p>
<h2 id="learn-the-date-before-the-advisory-does" tabindex="-1">Learn the date before the advisory does </h2>
<p>For example, teams still on Node.js 20 or 18 did not get a quiet reminder when
security support ended. They got an October release whose patches do not apply
to them. The upgrade was already a known project. The advisory is what turned
it into someone's unplanned priority.</p>
<p>The vulnerability reports are going to keep coming. The part I can control
beforehand is smaller than it sounds. When the next one names something I run,
I want to be in the easy position to simply take in the fix.</p>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[The Sleep-Tight Server: Blocking Malicious IPs with SWAG and CrowdSec]]></title>
            <link>https://tywer.dev/the-sleep-tight-server-blocking-malicious-ips-with-swag-and-crowdsec</link>
            <guid isPermaLink="false">https://tywer.dev/the-sleep-tight-server-blocking-malicious-ips-with-swag-and-crowdsec</guid>
            <pubDate>Mon, 27 Jul 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[<p>There is a specific kind of dread that comes with opening port 443 on your home
network to the internet. Within minutes, the invisible army of bots, scanners,
and malicious scripts starts knocking at your door.</p>
<p>For a long time, I just accepted this as the cost of self-hosting. But this
morning, I woke up and checked my notifications. Waiting for me was a beautiful
stream of automated alerts: my server had silently detected, blocked, and banned
over half a dozen malicious IP addresses while I was fast asleep.</p>
<p>The secret? I recently upgraded my
<a href="https://github.com/linuxserver/docker-swag" target="_blank" rel="noreferrer">SWAG</a> (Secure Web Application
Gateway) setup to use <a href="https://github.com/crowdsecurity/crowdsec" target="_blank" rel="noreferrer">CrowdSec</a>,
complete with their new AppSec Web Application Firewall (WAF) rules. In this
post, I am going to show you exactly how to turn your reverse proxy into an
automated, self-updating fortress.</p>
<p><img src="/images/the-sleep-tight-server-crowdsec-swag.webp" alt="The Sleep-Tight Server: Blocking Malicious IPs with SWAG and CrowdSec"></p>
<h2 id="why-swag-crowdsec" tabindex="-1">Why SWAG &amp; CrowdSec? <a class="header-anchor" href="#why-swag-crowdsec" aria-label="Permalink to &quot;Why SWAG &amp; CrowdSec?&quot;">&ZeroWidthSpace;</a></h2>
<p>When you are running a home lab, exposing services is just part of the fun.
Whether you are throwing an authentication portal like Authelia in front of your
apps, or exposing a Dozzle dashboard to keep an eye on your container logs on
the go, a reverse proxy is mandatory.</p>
<p>For years, LinuxServer.io's SWAG (Secure Web Application Gateway) has been my
go-to. It handles Let's Encrypt certificates flawlessly and routes traffic
perfectly. To protect those exposed apps, the standard recommendation was always
Fail2Ban.</p>
<p>Fail2Ban is a great tool, but it has a fundamental limitation: it operates in a
silo. It is like a bouncer who only learns about a troublemaker after they have
already started a fight in your specific bar.</p>
<p>CrowdSec changes the game entirely. Instead of a lone bouncer, CrowdSec acts
like a global neighborhood watch network. If a malicious IP address attacks a
server in Tokyo, that behavior is reported, verified, and that IP is instantly
banned across the entire CrowdSec network, including your home server.</p>
<p>But what really sold me wasn't just the IP bans; it was the new AppSec Web
Application Firewall (WAF). CrowdSec can now actively inspect the actual traffic
payloads for exploits and drop the connection before the bad actor even touches
your backend containers.</p>
<h2 id="trying-swag-crowdsec-together" tabindex="-1">Trying SWAG &amp; CrowdSec Together <a class="header-anchor" href="#trying-swag-crowdsec-together" aria-label="Permalink to &quot;Trying SWAG &amp; CrowdSec Together&quot;">&ZeroWidthSpace;</a></h2>
<p>The brilliant team over at LinuxServer.io published an excellent guide on
<a href="https://www.linuxserver.io/blog/blocking-malicious-connections-with-crowdsec-and-swag" target="_blank" rel="noreferrer">blocking malicious connections with CrowdSec and SWAG</a>,
which even walks through setting up Discord notifications for your bans. I used
their tutorial as my foundation with some tweaks.</p>
<div class="language-yml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># simplified example</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">services</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  swag</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    image</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">lscr.io/linuxserver/swag:latest</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    container_name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">swag</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    cap_add</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">NET_ADMIN</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">PUID=${PUID}</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">PGID=${PGID}</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">TZ=${TZ}</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">URL=${SWAG_URL}</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">VALIDATION=http</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">      # This is the magic line that installs the CrowdSec integration!</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">      # If using Cloudflare, this ensures CrowdSec sees the attacker's real IP instead of Cloudflare's</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">DOCKER_MODS=linuxserver/mods:swag-crowdsec|linuxserver/mods:swag-cloudflare-real-ip</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">      # A secure key so SWAG and CrowdSec can communicate (generated with: openssl rand -hex 32)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">CROWDSEC_API_KEY=${CROWDSEC_API_KEY}</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">CROWDSEC_LAPI_URL=http://crowdsec:8080</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    volumes</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">${DOCKER_BASE_DIR}/swag/config:/config</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    ports</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">443:443</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">80:80</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">unless-stopped</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  crowdsec</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    image</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">docker.io/crowdsecurity/crowdsec:latest</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    container_name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">crowdsec</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">GID=1000</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">COLLECTIONS=crowdsecurity/nginx crowdsecurity/http-cve crowdsecurity/whitelist-good-actors crowdsecurity/appsec-generic-rules crowdsecurity/appsec-virtual-patching</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">CUSTOM_HOSTNAME=${SWAG_URL}</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    volumes</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">${DOCKER_BASE_DIR}/crowdsec/config:/etc/crowdsec:rw</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">${DOCKER_BASE_DIR}/crowdsec/data:/var/lib/crowdsec/data:rw</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">${DOCKER_BASE_DIR}/swag/log/nginx:/var/log/swag:ro</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">/var/log:/var/log/host:ro</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">unless-stopped</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    security_opt</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">no-new-privileges=true</span></span></code></pre>
</div><h3 id="breaking-down-the-magic" tabindex="-1">Breaking Down the Magic <a class="header-anchor" href="#breaking-down-the-magic" aria-label="Permalink to &quot;Breaking Down the Magic&quot;">&ZeroWidthSpace;</a></h3>
<p>There are two critical pieces making this work:</p>
<ol>
<li>
<p>The API Key: SWAG acts as the &quot;Bouncer&quot; (the enforcement node), but CrowdSec
acts as the &quot;Brain&quot; (the decision maker). They need a secure way to talk to
each other locally, which is handled by the <code>CROWDSEC_API_KEY</code> and the
<code>CROWDSEC_LAPI_URL</code>.</p>
</li>
<li>
<p>Shared Logs and Collections: Notice how we mount SWAG's Nginx logs directly
into the CrowdSec container as read-only (<code>:ro</code>). CrowdSec constantly watches
these logs. We also define a specific list of
<a href="https://app.crowdsec.net/hub/collections" target="_blank" rel="noreferrer">COLLECTIONS</a> as an environment
variable, this tells CrowdSec exactly what kind of malicious behavior to look
out for.</p>
</li>
</ol>
<h3 id="the-secret-sauce-appsec-and-virtual-patching" tabindex="-1">The Secret Sauce: AppSec and Virtual Patching <a class="header-anchor" href="#the-secret-sauce-appsec-and-virtual-patching" aria-label="Permalink to &quot;The Secret Sauce: AppSec and Virtual Patching&quot;">&ZeroWidthSpace;</a></h3>
<p>You may have noticed the long <code>COLLECTIONS</code> environment variable in the Docker
Compose file. This is where CrowdSec transforms from a simple log analyzer into
a full-fledged Web Application Firewall (WAF).</p>
<p>By chaining these specific collections together, we are building a layered
defense system. Let's break down what each one actually does in plain English:</p>
<ul>
<li>
<p><code>crowdsecurity/nginx</code>: This is the foundation. It teaches CrowdSec exactly how
to read and understand the standard Nginx access and error logs that SWAG
generates.</p>
</li>
<li>
<p><code>crowdsecurity/whitelist-good-actors</code>: This collection is a lifesaver. It
automatically whitelists known good actors like search engine crawlers
(Googlebot, Bing), trusted partners like Cloudflare, and public DNS resolvers.
This ensures you don't accidentally ban friendly traffic.</p>
</li>
<li>
<p><code>crowdsecurity/http-cve</code>: This collection continuously scans your logs for
patterns matching the exploitation of specific, known HTTP vulnerabilities.</p>
</li>
<li>
<p><code>crowdsecurity/appsec-generic-rules</code>: This is the core of the new WAF. It
actively inspects traffic and blocks common web application attacks, like SQL
injections (SQLi) or Cross-Site Scripting (XSS), before they ever reach your
backend containers.</p>
</li>
<li>
<p><code>crowdsecurity/appsec-virtual-patching</code>: This is arguably the coolest feature
in this entire stack. When a major new vulnerability is discovered in a
popular app, attackers start exploiting it immediately. Virtual patching acts
as a temporary shield, targeting and blocking those specific new exploits at
the proxy level. It protects you during that terrifying gap between a
vulnerability being announced and you actually having the time to update your
self-hosted apps.</p>
</li>
</ul>
<p>Instead of just banning an IP address after it repeatedly fails to log in, this
AppSec configuration actively drops the connection the second an attacker tries
to send a malicious payload.</p>
<h2 id="the-final-connections-logs-and-discord-alerts" tabindex="-1">The Final Connections: Logs and Discord Alerts <a class="header-anchor" href="#the-final-connections-logs-and-discord-alerts" aria-label="Permalink to &quot;The Final Connections: Logs and Discord Alerts&quot;">&ZeroWidthSpace;</a></h2>
<p>At this point, SWAG and CrowdSec are running, and the WAF collections are locked
and loaded. But there are two final pieces to the puzzle: we need to tell
CrowdSec where to find SWAG’s logs, and we need to set up those sweet, sweet
Discord notifications.</p>
<p><img src="/images/crowdsec-discord.webp" alt=""></p>
<h3 id="crowdsec-logs" tabindex="-1">CrowdSec Logs <a class="header-anchor" href="#crowdsec-logs" aria-label="Permalink to &quot;CrowdSec Logs&quot;">&ZeroWidthSpace;</a></h3>
<p>To tell CrowdSec how to read our SWAG traffic, we need to modify the
<code>acquis.yaml</code> file (found in your CrowdSec configuration folder). This file maps
log directories to the collections we installed earlier.</p>
<p>Here is the exact configuration I used:</p>
<div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">filenames</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">  - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">/var/log/host/auth.log*</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">labels</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  type</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">syslog</span></span></code></pre>
</div>]]></description>
            <content:encoded><![CDATA[<p>There is a specific kind of dread that comes with opening port 443 on your home
network to the internet. Within minutes, the invisible army of bots, scanners,
and malicious scripts starts knocking at your door.</p>
<p>For a long time, I just accepted this as the cost of self-hosting. But this
morning, I woke up and checked my notifications. Waiting for me was a beautiful
stream of automated alerts: my server had silently detected, blocked, and banned
over half a dozen malicious IP addresses while I was fast asleep.</p>
<p>The secret? I recently upgraded my
<a href="https://github.com/linuxserver/docker-swag" target="_blank" rel="noreferrer">SWAG</a> (Secure Web Application
Gateway) setup to use <a href="https://github.com/crowdsecurity/crowdsec" target="_blank" rel="noreferrer">CrowdSec</a>,
complete with their new AppSec Web Application Firewall (WAF) rules. In this
post, I am going to show you exactly how to turn your reverse proxy into an
automated, self-updating fortress.</p>
<p><img src="https://tywer.dev/images/the-sleep-tight-server-crowdsec-swag.webp" alt="The Sleep-Tight Server: Blocking Malicious IPs with SWAG and CrowdSec"></p>
<h2 id="why-swag-crowdsec" tabindex="-1">Why SWAG &amp; CrowdSec? </h2>
<p>When you are running a home lab, exposing services is just part of the fun.
Whether you are throwing an authentication portal like Authelia in front of your
apps, or exposing a Dozzle dashboard to keep an eye on your container logs on
the go, a reverse proxy is mandatory.</p>
<p>For years, LinuxServer.io's SWAG (Secure Web Application Gateway) has been my
go-to. It handles Let's Encrypt certificates flawlessly and routes traffic
perfectly. To protect those exposed apps, the standard recommendation was always
Fail2Ban.</p>
<p>Fail2Ban is a great tool, but it has a fundamental limitation: it operates in a
silo. It is like a bouncer who only learns about a troublemaker after they have
already started a fight in your specific bar.</p>
<p>CrowdSec changes the game entirely. Instead of a lone bouncer, CrowdSec acts
like a global neighborhood watch network. If a malicious IP address attacks a
server in Tokyo, that behavior is reported, verified, and that IP is instantly
banned across the entire CrowdSec network, including your home server.</p>
<p>But what really sold me wasn't just the IP bans; it was the new AppSec Web
Application Firewall (WAF). CrowdSec can now actively inspect the actual traffic
payloads for exploits and drop the connection before the bad actor even touches
your backend containers.</p>
<h2 id="trying-swag-crowdsec-together" tabindex="-1">Trying SWAG &amp; CrowdSec Together </h2>
<p>The brilliant team over at LinuxServer.io published an excellent guide on
<a href="https://www.linuxserver.io/blog/blocking-malicious-connections-with-crowdsec-and-swag" target="_blank" rel="noreferrer">blocking malicious connections with CrowdSec and SWAG</a>,
which even walks through setting up Discord notifications for your bans. I used
their tutorial as my foundation with some tweaks.</p>
<div class="language-yml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># simplified example</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">services</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  swag</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    image</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">lscr.io/linuxserver/swag:latest</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    container_name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">swag</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    cap_add</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">NET_ADMIN</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">PUID=${PUID}</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">PGID=${PGID}</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">TZ=${TZ}</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">URL=${SWAG_URL}</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">VALIDATION=http</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">      # This is the magic line that installs the CrowdSec integration!</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">      # If using Cloudflare, this ensures CrowdSec sees the attacker's real IP instead of Cloudflare's</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">DOCKER_MODS=linuxserver/mods:swag-crowdsec|linuxserver/mods:swag-cloudflare-real-ip</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">      # A secure key so SWAG and CrowdSec can communicate (generated with: openssl rand -hex 32)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">CROWDSEC_API_KEY=${CROWDSEC_API_KEY}</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">CROWDSEC_LAPI_URL=http://crowdsec:8080</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    volumes</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">${DOCKER_BASE_DIR}/swag/config:/config</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    ports</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">443:443</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">80:80</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">unless-stopped</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  crowdsec</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    image</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">docker.io/crowdsecurity/crowdsec:latest</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    container_name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">crowdsec</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">GID=1000</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">COLLECTIONS=crowdsecurity/nginx crowdsecurity/http-cve crowdsecurity/whitelist-good-actors crowdsecurity/appsec-generic-rules crowdsecurity/appsec-virtual-patching</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">CUSTOM_HOSTNAME=${SWAG_URL}</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    volumes</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">${DOCKER_BASE_DIR}/crowdsec/config:/etc/crowdsec:rw</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">${DOCKER_BASE_DIR}/crowdsec/data:/var/lib/crowdsec/data:rw</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">${DOCKER_BASE_DIR}/swag/log/nginx:/var/log/swag:ro</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">/var/log:/var/log/host:ro</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">unless-stopped</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    security_opt</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">no-new-privileges=true</span></span></code></pre>
</div><h3 id="breaking-down-the-magic" tabindex="-1">Breaking Down the Magic </h3>
<p>There are two critical pieces making this work:</p>
<ol>
<li>
<p>The API Key: SWAG acts as the &quot;Bouncer&quot; (the enforcement node), but CrowdSec
acts as the &quot;Brain&quot; (the decision maker). They need a secure way to talk to
each other locally, which is handled by the <code>CROWDSEC_API_KEY</code> and the
<code>CROWDSEC_LAPI_URL</code>.</p>
</li>
<li>
<p>Shared Logs and Collections: Notice how we mount SWAG's Nginx logs directly
into the CrowdSec container as read-only (<code>:ro</code>). CrowdSec constantly watches
these logs. We also define a specific list of
<a href="https://app.crowdsec.net/hub/collections" target="_blank" rel="noreferrer">COLLECTIONS</a> as an environment
variable, this tells CrowdSec exactly what kind of malicious behavior to look
out for.</p>
</li>
</ol>
<h3 id="the-secret-sauce-appsec-and-virtual-patching" tabindex="-1">The Secret Sauce: AppSec and Virtual Patching </h3>
<p>You may have noticed the long <code>COLLECTIONS</code> environment variable in the Docker
Compose file. This is where CrowdSec transforms from a simple log analyzer into
a full-fledged Web Application Firewall (WAF).</p>
<p>By chaining these specific collections together, we are building a layered
defense system. Let's break down what each one actually does in plain English:</p>
<ul>
<li>
<p><code>crowdsecurity/nginx</code>: This is the foundation. It teaches CrowdSec exactly how
to read and understand the standard Nginx access and error logs that SWAG
generates.</p>
</li>
<li>
<p><code>crowdsecurity/whitelist-good-actors</code>: This collection is a lifesaver. It
automatically whitelists known good actors like search engine crawlers
(Googlebot, Bing), trusted partners like Cloudflare, and public DNS resolvers.
This ensures you don't accidentally ban friendly traffic.</p>
</li>
<li>
<p><code>crowdsecurity/http-cve</code>: This collection continuously scans your logs for
patterns matching the exploitation of specific, known HTTP vulnerabilities.</p>
</li>
<li>
<p><code>crowdsecurity/appsec-generic-rules</code>: This is the core of the new WAF. It
actively inspects traffic and blocks common web application attacks, like SQL
injections (SQLi) or Cross-Site Scripting (XSS), before they ever reach your
backend containers.</p>
</li>
<li>
<p><code>crowdsecurity/appsec-virtual-patching</code>: This is arguably the coolest feature
in this entire stack. When a major new vulnerability is discovered in a
popular app, attackers start exploiting it immediately. Virtual patching acts
as a temporary shield, targeting and blocking those specific new exploits at
the proxy level. It protects you during that terrifying gap between a
vulnerability being announced and you actually having the time to update your
self-hosted apps.</p>
</li>
</ul>
<p>Instead of just banning an IP address after it repeatedly fails to log in, this
AppSec configuration actively drops the connection the second an attacker tries
to send a malicious payload.</p>
<h2 id="the-final-connections-logs-and-discord-alerts" tabindex="-1">The Final Connections: Logs and Discord Alerts </h2>
<p>At this point, SWAG and CrowdSec are running, and the WAF collections are locked
and loaded. But there are two final pieces to the puzzle: we need to tell
CrowdSec where to find SWAG’s logs, and we need to set up those sweet, sweet
Discord notifications.</p>
<p><img src="https://tywer.dev/images/crowdsec-discord.webp" alt=""></p>
<h3 id="crowdsec-logs" tabindex="-1">CrowdSec Logs </h3>
<p>To tell CrowdSec how to read our SWAG traffic, we need to modify the
<code>acquis.yaml</code> file (found in your CrowdSec configuration folder). This file maps
log directories to the collections we installed earlier.</p>
<p>Here is the exact configuration I used:</p>
<div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">filenames</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">  - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">/var/log/host/auth.log*</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">labels</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  type</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">syslog</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">---</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">filenames</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">  - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">/var/log/swag/*</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">labels</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  type</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">nginx</span></span></code></pre>
</div><h3 id="the-payoff-discord-webhook-notifications" tabindex="-1">The Payoff: Discord Webhook Notifications </h3>
<p>Now for the fun part: getting notified when your server drops the hammer on a
bad actor. CrowdSec uses an HTTP notification plugin to send alerts to Discord
via webhooks.</p>
<ol>
<li>Create <code>discord.yaml</code> file within CrowdSec's <code>/config/notifications/</code>
directory:</li>
</ol>
<div class="language-yml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">type</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">http</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">discord</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">log_level</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">info</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">format</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">|</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">  {</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">    "content": null,</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">    "embeds": [</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      {{range . -}}</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      {{$alert := . -}}</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      {{range .Decisions -}}</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      {{if $alert.Source.Cn -}}</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      {</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">        "title": "{{$alert.MachineID}}: {{.Scenario}}",</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">        "description": ":flag_{{ $alert.Source.Cn | lower }}: {{$alert.Source.IP}} will get a {{.Type}} for the next {{.Duration}}. &#x3C;https://www.shodan.io/host/{{$alert.Source.IP}}>",</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">        "url": "https://db-ip.com/{{$alert.Source.IP}}",</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">        "color": "16711680"</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      }</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      {{end}}</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      {{if not $alert.Source.Cn -}}</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      {</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">        "title": "{{$alert.MachineID}}: {{.Scenario}}",</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">        "description": ":pirate_flag: {{$alert.Source.IP}} will get a {{.Type}} for the next {{.Duration}}. &#x3C;https://www.shodan.io/host/{{$alert.Source.IP}}>",</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">        "url": "https://db-ip.com/{{$alert.Source.IP}}",</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">        "color": "16711680"</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      }</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      {{end}}</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      {{end -}}</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      {{end -}}</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">    ]</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">  }</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">url</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">&#x3C;DISCORD_WEBHOOK_URL></span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">method</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">POST</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">headers</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  Content-Type</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">application/json</span></span></code></pre>
</div><ol start="2">
<li>Enable notifications within the <code>profiles.yaml</code> as such:</li>
</ol>
<div class="language-yml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">default_ip_remediation</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># ...</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">notifications</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">  - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">discord</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">---</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">default_range_remediation</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># ...</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">notifications</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">  - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">discord</span></span></code></pre>
</div><h2 id="wrapping-up-sleep-tight-homelabbers" tabindex="-1">Wrapping Up: Sleep Tight, Homelabbers </h2>
<p>Securing a home server shouldn't require a Ph.D. in cybersecurity, and it
certainly shouldn't require you to constantly monitor your logs like a hawk.</p>
<p>By using CrowdSec and leveraging LinuxServer's incredible SWAG container, you
are no longer fighting the internet alone. You are tapping into a global
neighborhood watch and utilizing virtual patching to block exploits before you
even have to think about updating your backend apps.</p>
<p>Seeing that stream of Discord notifications every morning is a fantastic
reminder that your infrastructure is quietly doing the heavy lifting for you.
You can finally expose those self-hosted services with a bit more peace of mind
knowing the front door is properly deadbolted.</p>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[Taming the Container Chaos: A Lightweight Approach to Log Monitoring with Dozzle]]></title>
            <link>https://tywer.dev/taming-the-container-chaos-a-lightweight-approach-to-log-monitoring-with-dozzle</link>
            <guid isPermaLink="false">https://tywer.dev/taming-the-container-chaos-a-lightweight-approach-to-log-monitoring-with-dozzle</guid>
            <pubDate>Fri, 29 May 2026 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>If you are running a home server or managing multiple containers, you already
know the struggle. A service silently goes down, and suddenly you are scrambling
through terminal screens, digging through endless lines of text just to figure
out what happened. I used to play that wandering game too - until I found
Dozzle. Dozzle is a brilliant, lightweight web dashboard that gives you instant
access to all your container logs and metrics. But the real game-changer? I
configured it to automatically alert my Discord the second something goes wrong.
No more wandering. Here is how this simple tool completely transformed how I
monitor my home servers.</p>
<p><img src="https://tywer.dev/images/dozzle-banner.webp" alt=""></p>
<h2 id="what-is-dozzle" tabindex="-1">What is Dozzle? </h2>
<p>So, what exactly is <a href="https://dozzle.dev/" target="_blank" rel="noreferrer">Dozzle</a>? In the simplest terms, it is
a lightweight, real-time web viewer for your container logs. If you have ever
felt overwhelmed by the idea of setting up a massive, complex logging stack with
heavy databases just to see what your home server is doing, Dozzle is the breath
of fresh air you have been looking for.</p>
<p>Instead of storing logs in a giant, resource-hungry database, Dozzle hooks
directly into your container engine. It streams the live logs and stats straight
to your web browser. It is incredibly fast, shockingly lightweight, and doesn't
eat up the precious CPU and memory you'd rather save for your actual
applications.</p>
<video controls autoplay loop muted>
  <source src="https://dozzle.dev/assets/dozzle-dark.Cxxdho5N.mp4" type="video/mp4">
</video>
<h2 id="the-magic-of-alerts" tabindex="-1">The Magic of Alerts </h2>
<p>Having a clean dashboard is great, but the real magic happens when you don't
even have to look at it. While I already use Uptime Kuma to tell me if a service
has completely crashed, Dozzle fills a crucial gap: it catches the internal
errors before they take the whole system down. Dozzle lets you set up incredibly
specific automated alerts based on your logs and container metrics, pinging you
the second something goes wrong under the hood.</p>
<p>Take a look at my configuration:</p>
<p><img src="https://tywer.dev/images/dozzle-alerts.webp" alt=""></p>
<p>I have set up a few critical triggers that route directly to my Discord via
webhooks. For instance, the &quot;<strong>Unhealthy Status</strong>&quot; and &quot;<strong>Critical Application
Errors</strong>&quot; alerts are lifesavers. A container might still technically be &quot;up&quot; and
responding to Uptime Kuma, but Dozzle catches the internal Docker health check
failing or a &quot;fatal&quot; panic in the logs, telling me instantly that something is
wrong.</p>
<p>I also keep a close eye on <strong>OOM (Out of Memory)</strong> events. When you are running
resource-intensive services, keeping an eye on memory limits is crucial. If a
container gets too greedy and gets killed by the system, I get an immediate
notification.</p>
<p>Beyond just crashes, log monitoring gives you incredible peace of mind about
your network's perimeter. If you run any kind of authentication container to
protect your services, you can easily set up a simple log filter in Dozzle to
track failed login attempts. If someone or something is repeatedly trying to
guess a passcode, you'll be alerted. Uptime Kuma might tell you your login page
is online, but Dozzle lets you know if someone is actively knocking at the front
door, keeping you in the loop without you ever having to manually check the
logs.</p>
<h2 id="the-setup-and-dashboard" tabindex="-1">The Setup and Dashboard </h2>
<p>Getting Dozzle up and running is ridiculously easy. For most people, it takes a
single <code>docker run</code> command, and you are instantly looking at your logs in the
browser.</p>
<p>Once you are in the dashboard, the search functionality is a game-changer. You
don't need to learn a complicated query language. You just use the split-screen
view, type in the error you are looking for, and Dozzle highlights the exact
lines across your containers in real-time. It turns troubleshooting from a
tedious chore into a quick, painless search.</p>
<p>Checkout their &quot;<a href="https://dozzle.dev/guide/getting-started" target="_blank" rel="noreferrer">Getting Started</a>&quot;
guide for the full setup instructions.</p>
<h2 id="conclusion" tabindex="-1">Conclusion </h2>
<p>At the end of the day, managing a home server should be fun, not a second job.
Adding Dozzle to my stack has saved me time from digging through terminal
windows and hunting for why a container suddenly exited. It is simple, it is
fast, and the Discord alerts mean I can relax knowing my server will tell me if
it needs attention.</p>
<p>If you are currently managing your containers without a dedicated log viewer, I
highly encourage you to give <a href="https://dozzle.dev/" target="_blank" rel="noreferrer">Dozzle</a> a try. It takes five
minutes to set up, and it might just be the best upgrade you make to your server
this year!</p>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[The Dead Man’s Switch: Foolproof Backup Monitoring with Duplicati and Uptime Kuma]]></title>
            <link>https://tywer.dev/the-dead-mans-switch-foolproof-backup-monitoring-with-duplicati-and-uptime-kuma</link>
            <guid isPermaLink="false">https://tywer.dev/the-dead-mans-switch-foolproof-backup-monitoring-with-duplicati-and-uptime-kuma</guid>
            <pubDate>Tue, 24 Feb 2026 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>Have you ever experienced the absolute dread of needing to restore an important
file, only to discover your backup software quietly gave up the ghost three
months ago?</p>
<p>Most of us try to prevent this by turning on notifications. You set up your
backup jobs, configure the alerts, and for the first week, you diligently check
every single &quot;Backup Completed Successfully&quot; ping that hits your phone, Slack,
or inbox. But by week three? Those constant updates become pure white noise.
Suddenly, you're suffering from notification fatigue. You've trained yourself to
ignore the noise, making it incredibly easy to completely miss the one critical
&quot;Failure&quot; alert hidden in a sea of routine green checkmarks.</p>
<p>This creates a terrifying scenario, Schrödinger’s Backup. Until you actually go
looking for your data, your backup is simultaneously successful and completely
corrupted.</p>
<p><img src="https://tywer.dev/images/duplicati-uptimekuma.webp" alt=""></p>
<p><strong>Flipping the Script: The Dead Man's Switch</strong></p>
<p>Instead of the white noise of notifications, we can implement a Dead Man's
Switch. Think of it like the safety lever on a train: as long as the conductor
is actively holding it down (your backup runs successfully), the train keeps
moving. If they let go or fall asleep (your backup fails, stalls, or crashes),
the alarms immediately sound. Instead of asking, &quot;Did the backup fail?&quot; a Dead
Man's Switch monitor sits quietly and asks, &quot;Did the backup check in on time
today?&quot; We can eliminate silent failures by integrating Duplicati's http send
with an Uptime Kuma push monitor that keeps your channels quiet and only bothers
you when something is actually wrong.</p>
<h2 id="the-uptime-kuma-push-monitor" tabindex="-1">The Uptime Kuma Push Monitor </h2>
<p>Most monitoring tools work by constantly knocking on your server's front door,
asking, &quot;Are you there?&quot; A backup process though isn't always listening, so this
model doesn't quite work. Uptime Kuma solves this with
<a href="https://uptimekuma.org/wiki/add-a-monitor-in-uptime-kuma/" target="_blank" rel="noreferrer">Push Monitors</a>.
Instead of Kuma reaching out to Duplicati, Duplicati reaches out to Kuma. It
does this using a simple <code>GET</code> request:
<code>https://uptimekuma.domain.com/api/push/&lt;monitor_id&gt;?status=up&amp;msg=OK&amp;ping=</code></p>
<p><img src="https://tywer.dev/images/uptimekuma-push-duplicati.webp" alt="Uptime Kuma Push Monitor"></p>
<ul>
<li>Setting the Monitor Friendly Name the same as the backup job name in Duplicati
is convenient for identifying which backup job is not reporting in.</li>
<li>Add a little cushion to the check-in interval. If your backup job runs every
24 hours, set the check-in interval to 25 hours. Weekly backups? Perhaps an
alarm after 8 days. This will prevent false positives if your backup job runs
a few minutes late or takes a little longer than usual to complete.</li>
</ul>
<p>When our backup software visits that exact URL, Uptime Kuma receives the &quot;OK&quot;
status, resets the Dead Man's Switch timer, and marks the service as
successfully &quot;Up.&quot;</p>
<h2 id="duplicati-s-http-send" tabindex="-1">Duplicati's HTTP Send </h2>
<p>Now that Uptime Kuma is listening, we need to configure Duplicati to actually
send the signal. Fortunately, Duplicati has built-in HTTP reporting that we can
hijack for exactly this purpose.</p>
<p>We can set this up directly in the Duplicati web interface without writing a
single line of code. Edit the backup job you want to monitor, and navigate to
the <code>Options</code> step. Scroll down to the bottom and look for the
<code>Advanced Options</code> dropdown. We are going to add three specific settings here:</p>
<ul>
<li><code>send-http-url</code> : This is where you paste the exact URL that Uptime Kuma
generated for you in the previous step. Make sure it includes the parameters
at the end (like <code>?status=up&amp;msg=OK</code>).</li>
<li><code>send-http-verb</code> : Set this to <code>GET</code>.</li>
<li><code>send-http-level</code> : Set this to <code>Success,Warning</code>.</li>
</ul>
<p><img src="https://tywer.dev/images/duplicati-httpsend.webp" alt="Duplicati Advanced HTTP Send Options"></p>
<p>It is incredibly tempting to set the HTTP level to <code>All</code> or <code>Fatal,Error</code>. <strong>Do
not do this!</strong> Remember how a Dead Man's Switch works. If the backup fails, we
want Duplicati to stay completely silent so Uptime Kuma's timer runs out and
triggers the alarm.</p>
<p>Because we hardcoded <code>?status=up</code> into our URL, if you tell Duplicati to send an
HTTP request on an Error, your failed backup will ping Uptime Kuma and say,
&quot;Status is Up!&quot; Kuma will happily reset the timer, and you will be right back
where you started. By restricting the level strictly to <code>Success,Warning</code>, we
guarantee that the signal is only sent when your backup is actually safe.</p>
<h2 id="uptime-kuma-status-page" tabindex="-1">Uptime Kuma Status Page </h2>
<p>One of the best features of Uptime Kuma is the ability to create status pages.
Here's an example of a Backup Status Page capturing the status of all my
backups:</p>
<p><img src="https://tywer.dev/images/uptimekuma-backups-status.webp" alt="Uptime Kuma Backups Status Dashboard"></p>
<p>Now if I'm ever especially curious about the status of my backups, I can simply
take a quick glance.</p>
<h2 id="trusting-the-silence" tabindex="-1">Trusting the Silence </h2>
<p>By pairing Duplicati’s built-in HTTP reporting with Uptime Kuma’s Push Monitors,
we have successfully cured &quot;Schrödinger’s Backup.&quot; You no longer have to worry
about notification fatigue blinding you to a real disaster. You have built a
true Dead Man's Switch - he conductor’s hand is firmly on the lever, and if your
backup server ever loses power, drops its internet connection, or simply
freezes, Uptime Kuma will sound the alarm.</p>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[Reducing Context Switching in Infrastructure as Code (IaC)]]></title>
            <link>https://tywer.dev/reducing-context-switching-in-infrastructure-as-code-iac</link>
            <guid isPermaLink="false">https://tywer.dev/reducing-context-switching-in-infrastructure-as-code-iac</guid>
            <pubDate>Mon, 16 Feb 2026 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>Infrastructure as Code (IaC) has revolutionized how we deploy systems, but the
developer experience remains fragmented. Even for seasoned engineers, the gap
between writing a resource block and verifying its arguments or outputs is a
persistent friction point. In the age of AI-assisted coding, this has shifted
from a search for syntax to a mission for verification. We are writing code
faster than ever, yet we still find ourselves losing mental bandwidth in the
browser, double-checking the &quot;source of truth.&quot; To minimize this tax, I built
<a href="https://marketplace.visualstudio.com/items?itemName=TylerHarris.terraform-link-docs" target="_blank" rel="noreferrer">Terraform Link Docs</a>,
a VSCode extension that bridges the distance between your editor and the
Registry, keeping you in the zone by making documentation a single click away.</p>
<p><img src="https://tywer.dev/images/vscode-terraformlinkdocs-banner.webp" alt="Terraform Link Docs Banner"></p>
<h2 id="the-friction-of-the-source-of-truth" tabindex="-1">The Friction of the &quot;Source of Truth&quot; </h2>
<p>Every software engineer knows the &quot;<strong>context switching tax</strong>.&quot; It's the hidden
cost of what should be a brief, three-second search for documentation that
inevitably spirals into a five-minute distraction. Whether you are hunting for
the specific arguments of a resource, verifying the available outputs of a
legacy module version, or checking if an attribute has been deprecated, the
&quot;Source of Truth&quot; is rarely where you actually need it.</p>
<p>In the age of AI-assisted coding, this friction hasn't vanished, it has evolved.
While LLMs can scaffold an entire VPC in seconds, they are notoriously
&quot;confident&quot; about syntax that might be two versions out of date or entirely
hallucinated. This has forced a shift in our workflow: we aren't just writing
code anymore; we are verifying it.</p>
<p>When AI suggests a new argument, the &quot;mission for verification&quot; begins. If that
requires multiple clicks, browser tabs, and manual searches through the
Terraform Registry, your flow state is gone, death by a thousand clicks. The
cognitive recovery required to return to your logic after navigating a sea of
documentation is a heavy price to pay for a simple &quot;trust but verify&quot; check. By
the time you find the right page, you might even be left wondering, &quot;<em>Wait...
what was I doing again?</em>&quot;</p>
<h2 id="an-antidote-terraform-link-docs" tabindex="-1">An Antidote - Terraform Link Docs </h2>
<p>I built
<a href="https://marketplace.visualstudio.com/items?itemName=TylerHarris.terraform-link-docs" target="_blank" rel="noreferrer">Terraform Link Docs</a>
to be the bridge across that gap. The goal was simple: take the documentation
out of the browser and bake it directly into the editor. By transforming static
HCL strings into live, clickable portals to the &quot;Source of Truth,&quot; we can
effectively eliminate this context switching tax.</p>
<p>The core of the extension is a low-latency feedback loop. When you're looking at
a resource like <code>aws_instance</code> or a datasource like <code>aws_ami</code>, you shouldn't
have to search for it. You simply click, and the extension handles the heavy
lifting of finding the exact documentation page for that specific provider.</p>
<p><img src="https://tywer.dev/images/vscode-terraformLinkDocs-resourceModule.gif" alt="Terraform Link Docs Demo"></p>
<h3 id="solving-the-non-standard-problem" tabindex="-1">Solving the &quot;Non-Standard&quot; Problem </h3>
<p>One of the biggest friction points in IaC is working with the broader ecosystem.
While many tools support the &quot;big three&quot; (AWS, Azure, GCP), the experience falls
apart the moment you touch a community or partner provider or internal modules.</p>
<p>Terraform Link Docs solves this by:</p>
<ul>
<li>
<p>Parsing <code>required_providers</code>: It looks at your configuration to correctly link
resources from providers like Cloudflare, Datadog, or Tailscale to their
specific Registry pages.</p>
</li>
<li>
<p>Deep Module Integration: Whether your modules are hosted on the Terraform
Registry, GitHub, Bitbucket, or even referenced via local paths, the extension
generates a direct link to the source. It even handles complex Git references
like specific SHAs or tags, essential for that &quot;mission for verification&quot; when
using pinned versions.</p>
</li>
</ul>
<p><img src="https://tywer.dev/images/vscode-terraformLinkDocs-communityResources.gif" alt="Terraform Link Docs Demo"></p>
<h3 id="designed-to-be-invisible" tabindex="-1">Designed to be Invisible </h3>
<p>Good developer tools should feel like they were always part of the IDE. This
extension is designed to be lightweight and stay out of your way until you need
it. There are no heavy UI overlays or intrusive pop-ups, just a clean way to get
the information you need, verify your AI's suggestions, and get back to
building.</p>
<h2 id="real-world-impact-installs-and-counting" tabindex="-1">Real-World Impact: <InstallCount-VSCodeTerraformLinkDocs /> Installs and Counting </h2>
<p>When I first released Terraform Link Docs, I wasn't sure if the &quot;Context
Switching Tax&quot; was just a personal pet peeve or a widespread industry pain
point. The response from the DevOps community has been a clear validation of the
latter. With all the installs and feedback from infrastructure engineers at
companies, it's clear that &quot;verification latency&quot; is a challenge we are all
facing.</p>
<p>The most rewarding part of this project has been its evolution through
open-source collaboration. The community has been instrumental in making this
tool more robust. For instance, the <code>enableCommunityProviders</code> setting was born
directly from user feedback. Engineers needed a way to bridge the gap for
partner and community-tier providers that are often treated as second-class
citizens in standard IDE tooling. By listening to how people actually use
Terraform in production, the extension has grown from a simple link-generator
into a sophisticated HCL parser that respects the nuances of modern provider
blocks and module sources.</p>
<h2 id="reclaiming-the-flow-state" tabindex="-1">Reclaiming the Flow State </h2>
<p>At the end of the day, documentation shouldn't be a destination you have to
travel to, it should be a natural part of the environment you work in. In a
world where AI can generate code faster than we can read it, the tools that
protect our <strong>Deep Work</strong> and minimize cognitive recovery are more valuable than
ever.</p>
<p>By bringing the &quot;Source of Truth&quot; directly into VSCode, <strong>Terraform Link Docs</strong>
isn't just saving you a few clicks, it's protecting your mental momentum and
helping you maintain the clarity required to build complex systems.</p>
<h3 id="get-started-contribute" tabindex="-1">Get Started &amp; Contribute </h3>
<p>If you're tired of the &quot;death by a thousand clicks,&quot; you can grab the extension
today and start reclaiming your mental bandwidth:</p>
<ul>
<li>Install it here:
<a href="https://marketplace.visualstudio.com/items?itemName=TylerHarris.terraform-link-docs" target="_blank" rel="noreferrer">Terraform Link Docs on the VSCode Marketplace</a></li>
<li>Collaborate:
<a href="https://github.com/tdharris/vscode-terraform-link-docs" target="_blank" rel="noreferrer">GitHub Repository</a></li>
</ul>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[A Practical Guide to Sizing Kubernetes Requests and Limits with AWS CloudWatch]]></title>
            <link>https://tywer.dev/a-practical-guide-to-sizing-kubernetes-requests-and-limits-with-aws-cloudwatch</link>
            <guid isPermaLink="false">https://tywer.dev/a-practical-guide-to-sizing-kubernetes-requests-and-limits-with-aws-cloudwatch</guid>
            <pubDate>Sat, 23 Aug 2025 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>Ever deployed an application to Kubernetes only to see it mysteriously crash
with an OOMKilled error? Or maybe you're on the other end of the spectrum,
looking at your AWS bill and wondering why your giant cluster is barely being
used. You're not alone.</p>
<p>Setting the right CPU and memory requests and limits for your workloads maybe is
one of the trickiest parts of running many workloads in shared Kubernetes
environments. It often feels more like a dark art than a science. Guess too low,
and your app becomes unstable. Guess too high, and you're just wasting money on
resources you don't need.</p>
<p>But what if you could stop guessing? In this guide, I go through a practical,
data-driven approach. I'll share exactly how to use the power of AWS CloudWatch
to find that &quot;just right&quot; size for your Kubernetes pods, saving you money and
future headaches.</p>
<p><img src="https://tywer.dev/images/k8s-aws-cloudwatch.webp" alt=""></p>
<h2 id="a-quick-refresher-on-requests-and-limits" tabindex="-1">A Quick Refresher on Requests and Limits </h2>
<p>Before we dive in, let's quickly recap what CPU and memory requests and limits
are in Kubernetes:</p>
<ul>
<li>
<p><strong>Requests</strong>: This is the <em>guaranteed</em> amount of resources a container will
get. The Kubernetes scheduler uses this to decide where to place a pod. Think
of it as the minimum your app needs to run smoothly.</p>
</li>
<li>
<p><strong>Limits</strong>: This is the <em>maximum</em> amount of resources a container can use. If
your app tries to exceed this limit, it will be throttled (for CPU) or killed
(for memory). This is your safety net to prevent a single pod from hogging all
the resources on a node and perhaps an escape hatch for runaway processes.</p>
</li>
</ul>
<p><img src="https://tywer.dev/images/k8s-resource-requests-limits.webp" alt=""></p>
<p>For more details, check out the
<a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/" target="_blank" rel="noreferrer">Kubernetes documentation on resource management</a>.</p>
<h2 id="guiding-principles" tabindex="-1">Guiding Principles </h2>
<p>The core philosophy is a three-step cycle: <strong>Observe, Calculate, and Tune.</strong> We
begin by observing a pod's behavior under real-world load <em>without</em> predefined
requests or limits. We then use statistics of this data to calculate sensible
starting values. Finally, we apply these values and continue to monitor and tune
them over time.</p>
<p><strong>Key Assumptions:</strong></p>
<ul>
<li>This process assumes you are gathering metrics from pods that do not have
existing requests or limits configured. This allows the pod to use as many
node resources as it needs, revealing its true consumption pattern.</li>
<li>The node must have sufficient capacity to handle the pod's peak usage and
should not be running other resource-intensive workloads during the
observation period so it's not constrained.</li>
</ul>
<h2 id="step-1-observe-gather-real-world-metrics" tabindex="-1">Step 1: Observe - Gather Real-World Metrics </h2>
<p>The Hero of our story is AWS CloudWatch. If you're running your Kubernetes
cluster on AWS (like EKS), CloudWatch can be a goldmine of performance data.
Getting your pod's historical CPU and memory usage metrics over a representative
period is the first step.</p>
<p>From CloudWatch Container Insights, focus on these two primary metrics for each
pod:</p>
<ul>
<li><code>pod_cpu_utilization</code></li>
<li><code>pod_memory_utilization</code></li>
</ul>
<p>For each metric, you will extract two different statistics to serve two
different purposes: setting a baseline (<code>request</code>) and setting a ceiling
(<code>limit</code>).</p>
<ol>
<li>
<p>For Baselines (<code>requests</code>): Use Trimmed Mean.</p>
<ul>
<li><strong>Statistic</strong>: <code>TM(10%:90%)</code> (Trimmed Mean)</li>
<li><strong>Why</strong>: This is the cornerstone of a stable baseline. By calculating the
average usage after removing the top and bottom 10% of outliers, you get a
value that represents the pod's typical, steady-state load. It isn't skewed
by brief, intense spikes or long periods of inactivity. Consider this the
&quot;comfort zone&quot; for resource allocation. See
<a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Statistics-definitions.html" target="_blank" rel="noreferrer">CloudWatch statistics definitions</a>
for more information.</li>
</ul>
</li>
<li>
<p>For Ceilings (<code>limits</code>): Use Maximum for memory and a high percentile for CPU
(e.g., <code>p99</code>).</p>
<ul>
<li><strong>Statistic</strong>: <code>Maximum</code> for Memory and <code>p99</code> or <code>p95</code> or another high
percentile statistic for CPU.</li>
<li><strong>Why</strong>: The penalty for exceeding a memory limit is an <code>OOMKill</code> (pod
crash); therefore, we must respect the absolute peak memory usage to ensure
stability. The Maximum statistic gives you this worst-case number. Respect
the peak.</li>
</ul>
</li>
</ol>
<p>The CloudWatch graph may look similar to this:</p>
<p><img src="https://tywer.dev/images/aws-cloudwatch-k8s-resource-metrics.webp" alt=""></p>
<p>For additional information, see the following:</p>
<ul>
<li><a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Container-Insights-metrics-EKS.html" target="_blank" rel="noreferrer">Amazon EKS and Kubernetes Container Insights metrics</a>.</li>
<li><a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/graph_a_metric.html" target="_blank" rel="noreferrer">Amazon CloudWatch Graphing a metric</a>.</li>
<li><a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Statistics-definitions.html" target="_blank" rel="noreferrer">Amazon CloudWatch statistics definitions</a>.</li>
</ul>
<h2 id="step-2-calculate-the-formulas" tabindex="-1">Step 2: Calculate - The Formulas </h2>
<p>Once you have your observed data, use the following formulas to convert the
percentage-based utilization metrics from CloudWatch into the absolute values
Kubernetes requires.</p>
<p><strong>Prerequisites</strong>: You need to know the specifications of the EC2 instance type
used for your Kubernetes worker nodes. Specifically, you need:</p>
<ul>
<li>Node <code>vCPUs</code>: The number of <code>vCPUs</code> on the EC2 worker node instance (see
<a href="https://aws.amazon.com/ec2/instance-types/" target="_blank" rel="noreferrer">EC2 instance types</a>).</li>
<li>Node <code>Memory GiB</code>: The amount of memory on the EC2 worker node instance in GiB
(see <a href="https://aws.amazon.com/ec2/instance-types/" target="_blank" rel="noreferrer">EC2 instance types</a>).</li>
<li>Buffer: Decide on a safety margin to handle unexpected load. A 15-25% buffer
seems like a sensible default.</li>
</ul>
<h3 id="cpu" tabindex="-1">CPU </h3>
<h4 id="requests" tabindex="-1">Requests </h4>
<p>The following formula converts the trimmed mean CPU utilization percentage into
<em>millicores</em>, which is the unit Kubernetes uses for CPU requests and limits:</p>
<p><code>CPU (millicores) = (Trimmed Mean CPU Utilization % / 100) * (Node vCPUs * 1000) * (1 + Buffer %)</code></p>
<div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p>The following explains the components of the formula:</p>
<ul>
<li><code>Trimmed Mean CPU Utilization %</code>: The trimmed mean value you obtained from
CloudWatch. <code>/ 100</code> converts the percentage to a decimal.</li>
<li><code>Node vCPUs * 1000</code>: Converts the number of vCPUs to millicores (1 vCPU =
1000 millicores).</li>
<li><code>Buffer %</code>: A percentage (e.g., 0.25 for 25%) added to the request to
provide a safety margin.</li>
</ul>
</div>
<h4 id="limits" tabindex="-1">Limits </h4>
<p>I recommend <strong>not</strong> setting CPU limits unless really necessary, as I find it can
lead to unnecessary throttling when resources may be available on the node.
However, if you must set a limit, use <code>p99</code>, <code>p95</code> or other high-percentile
metrics data to guide you. For example, the 99th percentile of CPU usage, which
captures most spikes while ignoring extreme outliers:</p>
<p><code>CPU (millicores) = (p99 CPU Utilization % / 100) * (Node vCPUs * 1000) * (1 + Buffer %)</code></p>
<h3 id="memory" tabindex="-1">Memory </h3>
<h4 id="requests-1" tabindex="-1">Requests </h4>
<p><code>Memory (MiB) = (Trimmed Mean Trimmed Mean CPU Utilization % / 100) * (Node Memory GiB * 1024) * (1 + Buffer %)</code></p>
<div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p>The following explains the components of the formula:</p>
<ul>
<li><code>Trimmed Mean Memory Utilization %</code>: The trimmed mean value you obtained
from CloudWatch. <code>/ 100</code> converts the percentage to a decimal.</li>
<li><code>Node Memory GiB * 1024</code>: Converts the node memory from GiB to MiB (1 GiB =
1024 MiB).</li>
<li><code>Buffer %</code>: A percentage (e.g., 0.25 for 25%) added to the request to
provide a safety margin.</li>
</ul>
</div>
<h4 id="limits-1" tabindex="-1">Limits </h4>
<p><code>Memory (MiB) = (Maximum Memory Utilization % / 100) * (Node Memory GiB * 1024) * (1 + Buffer %)</code></p>
<div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p>The following explains the components of the formula:</p>
<ul>
<li><code>Maximum Memory Utilization %</code>: The maximum value you obtained from
CloudWatch. <code>/ 100</code> converts the percentage to a decimal.</li>
<li><code>Node Memory GiB * 1024</code>: Converts the node memory from GiB to MiB (1 GiB =
1024 MiB).</li>
<li><code>Buffer %</code>: A percentage (e.g., 0.25 for 25%) added to the limit to provide
a safety margin.</li>
</ul>
</div>
<h2 id="step-3-tune-apply-and-monitor" tabindex="-1">Step 3: Tune - Apply and Monitor </h2>
<p>Once you've calculated the requests and limits, it's time to apply them to your
pod specifications. For an example of how to set these values in Kubernetes, see
the
<a href="https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#example-1" target="_blank" rel="noreferrer">Kubernetes Container resources example</a>.</p>
<p>After deploying the updated pod configuration, continue to monitor the pod's
performance using CloudWatch and Kubernetes metrics. Look for signs of resource
contention, such as CPU throttling or <code>OOMKills</code>, and adjust the requests and
limits as necessary.</p>
<p><img src="https://tywer.dev/images/k8s-aws-resources-tuning-dashboard.webp" alt=""></p>
<h3 id="advanced-considerations" tabindex="-1">Advanced Considerations </h3>
<p>These guidelines provide a solid foundation, but every application is unique.
For example, the 25% buffer and <code>TM(10%:90%)</code> statistic are excellent starting
points, but you can refine them.</p>
<ul>
<li>
<p>Adjusting the Buffer: For critical production applications, you might increase
the buffer to 30% or more. For less critical dev/test environments, you might
reduce it to 15% or even lower.</p>
</li>
<li>
<p>When to use <code>TM(10%:95%)</code>? Consider using a <code>TM(10%:95%)</code> for your requests.
This trims the inactive bottom 10% but keeps more of the legitimate high-usage
data. This is ideal for applications that have a low idle state but a frequent
and predictable &quot;busy&quot; state. It will result in a higher, more generous
request that can better accommodate regular bursts without relying on bursting
above the request.</p>
</li>
<li>
<p>Consider other statistics: Depending on your application's behavior, you might
find that other statistics (like maximum, percentile or interquartile mean)
provide better insights into typical usage patterns. See
<a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Statistics-definitions.html" target="_blank" rel="noreferrer">CloudWatch statistics definitions</a>
for more options. Experiment and see what works best for your workloads.</p>
</li>
</ul>
<h2 id="conclusion" tabindex="-1">Conclusion </h2>
<p>Setting the right CPU and memory requests and limits for your Kubernetes pods
doesn't have to be a guessing game. By leveraging AWS CloudWatch to gather
real-world usage data, you can make informed decisions that balance performance
and cost.</p>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[The EKS Passport: A Simple Analogy for AWS IRSA]]></title>
            <link>https://tywer.dev/the-eks-passport-a-simple-analogy-for-aws-irsa</link>
            <guid isPermaLink="false">https://tywer.dev/the-eks-passport-a-simple-analogy-for-aws-irsa</guid>
            <pubDate>Sun, 08 Jun 2025 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>In modern cloud security, the principle of least privilege is paramount: every
application should only have the permissions it needs, for the shortest time
necessary. For a long time, achieving this for pods running in Amazon EKS was a
challenge that often led to overly broad permissions or complex credential
management.</p>
<p>To understand the elegant solution, let's step away from the technical details
for a moment.</p>
<p>Imagine your application, running in a pod inside your EKS cluster, is a
Traveler. Its mission is to enter the secure &quot;nation&quot; of AWS to perform a
specific task, like retrieving a secret from Secrets Manager, reading an object
from an S3 bucket, or invoking a Lambda function.</p>
<p>The old way of granting this access was like giving the Traveler a permanent,
physical master key. We would hardcode long-lived AWS <code>access_key_id</code> and
<code>secret_access_key</code> directly into our application's environment. If a malicious
actor ever got their hands on it, they could gain access to our AWS account and
environment, and we might not know until it was too late. This approach is a
significant and unnecessary security risk.</p>
<p>Thankfully, there's a far more secure and elegant method. Instead of a master
key, our Traveler is issued a special, short-lived &quot;passport&quot; that is digitally
signed by their &quot;home country&quot; (Kubernetes). The &quot;nation&quot; of AWS has already
agreed to trust passports issued from this specific country. When the Traveler
arrives at the border, they present their passport. After verifying its
authenticity, they are issued a temporary <strong>access badge</strong> that only works for
the specific mission they need to accomplish. This badge has a short lifespan
and expires very soon after their mission is complete. This is the very essence
of <strong>IAM Roles for Service Accounts (IRSA)</strong>, the modern, native way to grant
your applications the precise permissions they need, exactly when they need
them, without ever handling a long-lived key.</p>
<p><img src="https://tywer.dev/images/kubernetes-passport-to-cloud.webp" alt=""></p>
<p>This passport is a great metaphor for IRSA. In this guide, we will unpack how
this &quot;passport system&quot; works under the hood and demonstrate a practical example
with a Go application to get our own Traveler the secure credentials it needs.</p>
<h2 id="the-problem-with-traditional-aws-credentials-in-eks" tabindex="-1">The Problem with Traditional AWS Credentials in EKS </h2>
<p>Before IRSA, developers had a few common, but flawed, patterns for giving pods
AWS access. Each of these methods essentially amounts to leaving a permanent key
lying around, creating significant challenges.</p>
<h3 id="hardcoding-keys-in-secrets-or-environment-variables" tabindex="-1">Hardcoding Keys in Secrets or Environment Variables </h3>
<p>This is the most direct anti-pattern. You generate a long-lived IAM user's
<code>access_key_id</code> and <code>secret_access_key</code> and save them as Kubernetes secrets,
which are then mounted into your pods as environment variables.</p>
<ul>
<li><strong>Security Risk</strong>: These keys represent a static, mostly permanent credential.
If they are ever leaked — whether through an accidental log output, a
compromised container, a developer mistakenly committing a <code>.env</code> file to a
public Git repository or using it locally to test — a malicious actor has a
direct, persistent entry point to your AWS account.</li>
<li><strong>Operational Nightmare</strong>: Security best practices demand regular credential
rotation. How do you rotate a key being used by many different services at
once? It’s a painful, error-prone process that often requires coordinated
deployments and risks downtime. Mostly, teams seem to simply avoid it, leaving
old keys in place indefinitely.</li>
</ul>
<h3 id="assigning-iam-roles-to-nodes-ec2-instance-profiles" tabindex="-1">Assigning IAM Roles to Nodes (EC2 Instance Profiles) </h3>
<p>A slightly better approach was to assign an IAM role to the underlying EC2 nodes
in the EKS cluster. Any pod running on that node could then inherit its
permissions.</p>
<ul>
<li><strong>Violation of Least Privilege</strong>: This pattern is a blunt instrument. Every
single pod on the node—the metrics-scraper, the API backend, the caching
service—gets the exact same set of permissions. If a single, low-priority pod
on that node is compromised, the attacker gains the full permissions of the
node's role, which is often far more than the compromised application needed.</li>
</ul>
<p>These challenges demanded a better, cloud-native approach—one that could provide
granular, temporary, and easily managed credentials directly to the applications
that need them. This is precisely the problem IRSA was built to solve.</p>
<h2 id="the-irsa-passport-analogy" tabindex="-1">The IRSA Passport Analogy </h2>
<p>Now that we understand the security risks of static keys, let's unpack the inner
workings of IAM Roles for Service Accounts (IRSA) in EKS. Think of it as a
passport process that ensures your pods can securely access AWS resources
without the risks associated with static credentials. At first glance, the
workflow might seem complex, but it's a logical sequence of checks and balances
that ensures a secure handshake between Kubernetes and AWS.</p>
<p>The process of an application using IAM Roles for Service Accounts (IRSA) is
like a traveler using a passport to get a visa from border control for entry
into a foreign country:</p>
<ol>
<li>
<p><strong>Your Application Gets a Passport</strong>: When your application's pod is created,
the EKS API server acts as a trusted government and issues a digital
&quot;passport&quot;—a JSON Web Token (JWT)—to the pod. This passport is a signed
document that proves its identity.</p>
</li>
<li>
<p><strong>The Passport is Paired with a Visa</strong>: Your application is pre-approved for
a specific &quot;visa&quot; by linking its service account to an IAM role. This IAM
role defines the permissions it has to access AWS resources.</p>
</li>
<li>
<p><strong>The Traveler Arrives at Border Control</strong>: Your application, using the AWS
SDK, presents its passport (the JWT) to AWS Security Token Service (STS),
which acts as the border control officer.</p>
</li>
<li>
<p><strong>Border Control Verifies the Passport</strong>: AWS STS inspects the passport's
digital signature and uses a trusted list of keys from the EKS OIDC provider
to verify that the passport is authentic and was issued by a legitimate
authority.</p>
</li>
<li>
<p><strong>The Traveler Receives an Entry Stamp</strong>: Once verified, AWS STS grants your
application temporary &quot;entry stamps&quot; in the form of security credentials.
Your app can now use these credentials to access the AWS resources it's been
granted permissions for.</p>
</li>
</ol>
<h2 id="the-technical-breakdown" tabindex="-1">The Technical Breakdown </h2>
<p>Here's a more detailed breakdown of the components involved in this process:</p>
<p><img src="https://tywer.dev/images/aws-eks-irsa.webp" alt=""></p>
<h3 id="oidc-provider-creation" tabindex="-1">OIDC Provider Creation </h3>
<p>First, a trust relationship must be established. You only do this once per EKS
cluster. By creating an IAM OIDC Provider, you are essentially telling your AWS
account: &quot;I trust my EKS cluster. I recognize its authority to issue trusted
identity documents, and I'm willing to accept them as authentic.&quot;</p>
<p>Technically, the EKS cluster publishes a public OIDC discovery endpoint (a URL)
where IAM can find the public signing keys necessary to verify the tokens that
your pods will present later. This is the foundation of the entire
process—without this trust, AWS would have no reason to believe a token from
your cluster is legitimate.</p>
<h3 id="iam-role-creation" tabindex="-1">IAM Role Creation </h3>
<p>Next, an IAM Role is needed that your pod will assume. This role contains two
critical components:</p>
<ul>
<li><strong>Permissions Policy</strong>: This defines what actions the role can perform on
which AWS resources (e.g., read from a specific S3 bucket).</li>
<li><strong>Trust Policy</strong>: This is where you specify that this role can be assumed by
entities presenting a valid token from your EKS cluster's OIDC provider, and
you can further restrict it to a specific Kubernetes Service Account and
namespace.</li>
</ul>
<p>Here's an example of what the Trust Policy looks like. Notice how it's not
trusting an AWS service or another user, but the OIDC provider:</p>
<div class="language-json vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "Version"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"2012-10-17"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "Statement"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: [</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    {</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">      "Effect"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"Allow"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">      "Principal"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: {</span></span>
<span class="line highlighted"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">        "Federated"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"arn:aws:iam::YOUR_AWS_ACCOUNT_ID:oidc-provider/oidc.eks.us-west-2.amazonaws.com/id/YOUR_OIDC_ID"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      },</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">      "Action"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"sts:AssumeRoleWithWebIdentity"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">      "Condition"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: {</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">        "StringEquals"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: {</span></span>
<span class="line highlighted"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">          "oidc.eks.us-west-2.amazonaws.com/id/YOUR_OIDC_ID:sub"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"system:serviceaccount:your-namespace:your-app-sa"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">        }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">  ]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span></code></pre>
</div><h3 id="the-pod-s-service-account-and-token" tabindex="-1">The Pod's Service Account and Token </h3>
<p>A Kubernetes service account is annotated with the ARN of the IAM role, linking
the two. With IRSA configured, Kubernetes does something special: it
automatically generates a unique, signed JSON Web Token (JWT) and mounts it into
the pod at a specific file path
(<code>/var/run/secrets/eks.amazonaws.com/serviceaccount/token</code>).</p>
<p>This token is our passport. It's an identity document, signed by the trusted
OIDC provider (our &quot;passport office&quot;), that cryptographically proves the pod's
identity, including the namespace and service account name it belongs to. It's
short-lived and automatically rotated by Kubernetes, meaning the passport is
only valid for a short time.</p>
<h3 id="role-assumption" tabindex="-1">Role Assumption </h3>
<p>When your application starts up, the AWS SDK detects that it's running in an
environment with IRSA configured. Instead of looking for static credentials in
environment variables, it reads the JWT from the mounted file and exchanges it
with AWS STS for temporary credentials. See
<a href="https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts-minimum-sdk.html" target="_blank" rel="noreferrer">Use IRSA with the AWS SDK</a>
for more details.</p>
<p>STS then performs its &quot;border check&quot; - it uses the OIDC provider configuration
to verify the token's signature is valid (public key). It checks the Trust
Policy on the IAM Role to ensure that the identity in the token is allowed to
assume the role. If everything checks out, STS grants the application temporary,
short-lived AWS credentials. Your application can then use these credentials to
make authorized API calls to services like S3 or DynamoDB.</p>
<h2 id="putting-it-all-together-a-practical-example-with-go" tabindex="-1">Putting It All Together: A Practical Example with Go </h2>
<p>We've covered the theory of IRSA. Now, let's see how these pieces fit together
in a real-world scenario.</p>
<p>For a hands-on demonstration, I've created a simple Go application and a set of
Kubernetes manifests bundled as a Helm chart available on GitHub:
<a href="https://github.com/tdharris/aws-identity-validator" target="_blank" rel="noreferrer">tdharris/aws-identity-validator</a>.</p>
<p>This project is designed to be just a &quot;simple&quot; way to validate that IRSA is
working. The application itself does only one thing: it uses the AWS SDK to ask,
&quot;Who am I?&quot; and logs the response.</p>
<p>To see this all in action for yourself, I encourage you to clone the repository
and follow the step-by-step guide in the <code>README</code>. It will walk you through
creating these resources and deploying the application. Though, it is fairly
involved, so be prepared for a bit of setup.</p>
<p>Skipping ahead, here's the application's logs to see the definitive proof that
our setup is working:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">AWS</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Identity</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Validator</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">===========================</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">[IRSA Environment Check]</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">✓</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS_WEB_IDENTITY_TOKEN_FILE</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> env</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> var</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> is</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> set:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> /var/run/secrets/eks.amazonaws.com/serviceaccount/token</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">✓</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Token</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> file</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> exists</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">✓</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Token</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> file</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> size:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 1246</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> bytes</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">✓</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS_ROLE_ARN</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> env</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> var</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> is</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> set:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> arn:aws:iam::</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">account-i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">:role/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">role-nam</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">[AWS SDK v1]</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">✓</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Successfully</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> authenticated</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> with</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> SDK</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> v1</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Account</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> ID:</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">account-i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">User</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> ID:</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">user-i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">:</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">session-i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">ARN:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> arn:aws:sts::</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">account-i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">:assumed-role/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">role-nam</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">session-i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Provider:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> WebIdentityCredentials</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Access</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Key</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> ID:</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">access-key-i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Using</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> temporary</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> credentials</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (has </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">session</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> token</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">)</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">[AWS SDK v2]</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">✓</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Successfully</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> authenticated</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> with</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> SDK</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> v2</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Account</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> ID:</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">account-i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">User</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> ID:</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">user-i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">:</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">session-i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">ARN:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> arn:aws:sts::</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">account-i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">:assumed-role/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">role-nam</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">session-i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Provider:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> WebIdentityCredentials</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Access</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Key</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> ID:</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">access-key-i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Using</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> temporary</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> credentials</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (has </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">session</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> token</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">)</span></span></code></pre>
</div><p>This output confirms that the application successfully authenticated with AWS
using the temporary credentials provided by IRSA. It shows the account ID, user
ID, and ARN of the assumed role, demonstrating that our pod is indeed acting as
a trusted identity with the correct permissions.</p>
<h2 id="the-new-standard-for-eks-security" tabindex="-1">The New Standard for EKS Security </h2>
<p>By swapping static keys for auto-rotating, temporary credentials, IAM Roles for
Service Accounts (IRSA) provides a fundamental security upgrade. It grants you
granular, pod-level permissions, eliminates the risk of leaked secrets, and
simplifies operations—all with clear audit trails in AWS.</p>
<p>You've effectively replaced the risky master key with a secure passport for
every application. For any workload running in EKS, IRSA isn't just another
feature; it's the modern, native, and essential way to handle identity in the
cloud.</p>
<p>For more details on IRSA, check out the
<a href="https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html" target="_blank" rel="noreferrer">AWS EKS IAM Roles for Service Accounts</a>
and the
<a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/" target="_blank" rel="noreferrer">Kubernetes Service Accounts for Pods</a>.</p>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[Git Credential Helper for Bitwarden Secrets Manager]]></title>
            <link>https://tywer.dev/git-credential-helper-for-bitwarden-secrets-manager</link>
            <guid isPermaLink="false">https://tywer.dev/git-credential-helper-for-bitwarden-secrets-manager</guid>
            <pubDate>Sun, 18 May 2025 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>Tired of that familiar &quot;Enter your password&quot; prompt when interacting with your
Git repositories? Yah, you can enable caching, provide it every once in a while,
but how about using Bitwarden to seamlessly manage your Git credentials?
<a href="https://github.com/tdharris/git-credential-bws" target="_blank" rel="noreferrer">git-credential-bws</a> is a
<a href="https://git-scm.com/docs/gitcredentials" target="_blank" rel="noreferrer">Git credential helper</a> that integrates
with
<a href="https://bitwarden.com/products/secrets-manager/" target="_blank" rel="noreferrer">Bitwarden Secrets Manager</a> to
securely store and retrieve your Git credentials for hassle-free authentication.</p>
<p><img src="https://tywer.dev/images/bws-gh-gl.webp" alt=""></p>
<h2 id="why-is-git-always-asking-for-my-password-anyways" tabindex="-1">Why is Git always asking for my password anyways? </h2>
<p>When you clone a Git repository that requires authentication, Git prompts you
for your username and password. If you don't have a credential helper
configured, you'll be asked to enter your credentials every time you interact
with the repository. This can be tedious and inconvenient, especially if you're
working with multiple repositories or frequently pushing changes.</p>
<p>In this case, you are probably using HTTPS to access your Git repositories
instead of SSH. While SSH keys can be a great way to authenticate with Git, they
require some setup and management. If you're not comfortable with SSH or prefer
to use HTTPS, you can still streamline your Git workflow by using a credential
helper and ditch that pesky password prompt.</p>
<h2 id="what-is-a-git-credential-helper" tabindex="-1">What is a Git credential helper? </h2>
<p>A <a href="https://git-scm.com/docs/gitcredentials" target="_blank" rel="noreferrer">Git credential helper</a> retrieves
your username and password or Personal Access Token (PAT) from a secure storage
location and seamlessly provides them to Git when needed. This way, you don't
have to enter your credentials every time you interact with a repository that
requires authentication. It allows you to authenticate with your Git
repositories without having to enter your username and password every time. Git
provides several built-in credential helpers, such as <code>cache</code>, <code>store</code>, and
<code>osxkeychain</code>, but you can also create your own custom credential helper.</p>
<h2 id="bitwarden-secrets-manager-git-credential-helper" tabindex="-1">Bitwarden Secrets Manager Git Credential Helper </h2>
<p><a href="https://github.com/tdharris/git-credential-bws" target="_blank" rel="noreferrer">git-credential-bws</a> is a custom
<a href="https://bitwarden.com/products/secrets-manager/" target="_blank" rel="noreferrer">Bitwarden Secrets Manager</a> Git
credential helper. It allows you to securely store your Git credentials in
Bitwarden and retrieve them automatically when needed. This way, you can manage
your Git credentials in a secure and convenient way, without having to enter
them manually every time.</p>
<h3 id="how-does-it-work" tabindex="-1">How does it work? </h3>
<p>Here's a high-level overview of how it operates:</p>
<ol>
<li>Git invokes the helper script when credentials are required.</li>
<li>The script receives the <code>get</code> command from Git.</li>
<li>It uses <code>bws secret get &lt;secret_id&gt;</code> to fetch the secret data from Bitwarden
Secrets Manager using <a href="https://bitwarden.com/help/secrets-manager-cli/" target="_blank" rel="noreferrer">bws</a>
CLI.</li>
<li>It parses JSON with <code>jq</code> to extract the provided username (optional) and
password key arguments.</li>
<li>It outputs the credentials to Git in the required format (<code>username=...</code> and
<code>password=...</code>).</li>
</ol>
<h3 id="installation" tabindex="-1">Installation </h3>
<p>For more information on how to install and configure the helper, please refer to
the
<a href="https://github.com/tdharris/git-credential-bws/blob/main/README.md" target="_blank" rel="noreferrer">git-credential-bws documentation</a>
to:</p>
<ol>
<li>Install the helper script.</li>
<li>Configure Git to use the helper.</li>
<li>Create a Bitwarden secret for your Git credentials.</li>
</ol>
<h3 id="usage" tabindex="-1">Usage </h3>
<p>Once installed and configured, you can use the helper by simply interacting with
your Git repositories as usual. When Git requires credentials, it will
automatically invoke the <code>git-credential-bws</code> helper to retrieve them from
Bitwarden Secrets Manager using the
<a href="https://bitwarden.com/help/secrets-manager-cli/" target="_blank" rel="noreferrer">bws</a> CLI.</p>
<h2 id="try-it-out" tabindex="-1">Try it out! </h2>
<p>Using a Git credential helper like
<a href="https://github.com/tdharris/git-credential-bws/" target="_blank" rel="noreferrer">git-credential-bws</a> allows you
to securely manage your Git credentials in a Password Vault, eliminating the
need to enter your username and password every time you interact with
repositories. If you're looking for a way to simplify your Git authentication
process, give it a try! It's a great way to enhance your Git experience while
keeping your credentials secure.</p>
<h2 id="additional-resources" tabindex="-1">Additional Resources </h2>
<ul>
<li><a href="https://git-scm.com/docs/gitcredentials" target="_blank" rel="noreferrer">Git Credential Helpers</a> - Official
Git documentation on credential helpers.</li>
<li><a href="https://bitwarden.com/products/secrets-manager/" target="_blank" rel="noreferrer">Bitwarden Secrets Manager</a> -
Learn more about Bitwarden's Secrets Manager.</li>
<li><a href="https://bitwarden.com/help/secrets-manager-cli/" target="_blank" rel="noreferrer">bws CLI</a> - Bitwarden's
command-line interface for managing secrets.</li>
<li><a href="https://docs.github.com/en/get-started/git-basics/why-is-git-always-asking-for-my-password" target="_blank" rel="noreferrer">Github Git Basics: Why is Git always asking for my password?</a></li>
</ul>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[Your Self-Hosted AI Starter Kit: Ollama, OpenWebUI, Authelia]]></title>
            <link>https://tywer.dev/your-self-hosted-ai-starter-kit</link>
            <guid isPermaLink="false">https://tywer.dev/your-self-hosted-ai-starter-kit</guid>
            <pubDate>Sat, 01 Feb 2025 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>In a world where data is the new gold, the privacy implications of relying
solely on cloud-based AI services are a growing concern. Are you comfortable
sharing your most sensitive data with algorithms you don't control? I'm
hesitant, it hasn't stopped me, but I feel uneasy about it. That's why I
embarked on a quest to build a private, secure, and self-hosted AI environment.
Using the power of Ollama, the user-friendliness of OpenWebUI, and the security
of Authelia for authentication, I've unlocked the potential of models like Llama
and DeepSeek without compromising my data. Let me show you how you can do the
same. All thanks to the power of open-source software and the community that
supports it!</p>
<p><img src="https://tywer.dev/images/adam.webp" alt=""></p>
<h2 id="the-ai-starter-kit" tabindex="-1">The AI Starter Kit </h2>
<p><strong>TLDR</strong>; See the
<a href="https://github.com/tdharris/ollama-openwebui" target="_blank" rel="noreferrer">tdharris/ollama-openwebui</a>
repository for the full <code>docker-compose.yml</code> setup.</p>
<p>The self-hosted AI starter kit consists of the following components:</p>
<ol>
<li><strong>Ollama</strong>: An open-source platform that allows you to run state-of-the-art
AI models locally on your own hardware.</li>
<li><strong>OpenWebUI</strong>: A user-friendly interface for running models like DeepSeek,
Llama, and <a href="https://ollama.com/library/" target="_blank" rel="noreferrer">more</a>.</li>
<li><strong>Authelia</strong>: An open-source authentication and authorization server that
provides two-factor authentication and single sign-on for your applications.
OpenWebUI integrates via OIDC for secure access.</li>
<li><strong>Nginx</strong>: To access OpenWebUI securely over HTTPS as a reverse proxy and
have Authelia handle the authentication.</li>
<li><strong>Hardware</strong>: A GPU and plenty of memory for accelerated AI model inference.
I am using my desktop with an NVIDIA RTX 3080 GPU and 64GB of RAM, which is
probably enough for small models.</li>
</ol>
<p><img src="https://tywer.dev/images/ollama-openwebui-authelia.webp" alt=""></p>
<h3 id="ollama-open-source-ai-models" tabindex="-1">Ollama: Open-Source AI Models </h3>
<p><a href="https://ollama.com/" target="_blank" rel="noreferrer">Ollama</a> is an open-source platform that allows you to run
state-of-the-art AI models locally on your own hardware. It provides a simple
and user-friendly interface for running models like DeepSeek, Llama, and more.
Ollama is designed to be easy to use, secure, and private, giving you full
control over your data and models.</p>
<p>To get started, I created an initial <code>docker-compose.yml</code> file following the
official <a href="https://hub.docker.com/r/ollama/ollama" target="_blank" rel="noreferrer">Ollama Docker image</a>
<code>ollama/ollama</code>, which is available on Docker Hub.</p>
<div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">services</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  ollama</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    image</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">ollama/ollama:latest</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    container_name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">ollama</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">unless-stopped</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    ports</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"11434:11434"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    volumes</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">ollama:/root/.ollama</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">NVIDIA_DRIVER_CAPABILITIES=all</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">NVIDIA_VISIBLE_DEVICES=all</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    runtime</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">nvidia</span></span></code></pre>
</div><div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p>The <code>NVIDIA_DRIVER_CAPABILITIES</code> and <code>NVIDIA_VISIBLE_DEVICES</code> environment
variables are required for GPU support. See
<a href="https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html#installation" target="_blank" rel="noreferrer">NVIDIA Container Toolkit</a>
for more information.</p>
</div>
<p>I then ran <code>docker-compose up -d</code> to start the Ollama service. Once the service
was up and running, I explored the available models from the
<a href="https://ollama.com/library" target="_blank" rel="noreferrer">Ollama library</a> and installed one I was interested
in trying out:</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">docker</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> exec</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -it</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> ollama</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> ollama</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> run</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> deepseek-r1:7b</span></span></code></pre>
</div><p>While that was downloading, I moved on to setting up OpenWebUI.</p>
<h3 id="openwebui-user-friendly-ai-interface" tabindex="-1">OpenWebUI: User-Friendly AI Interface </h3>
<p><a href="https://docs.openwebui.com/" target="_blank" rel="noreferrer">OpenWebUI</a> is a user-friendly interface for
running AI models like DeepSeek, Llama, and more. It provides a simple and
intuitive way to interact with AI models without the need for complex
command-line interfaces. OpenWebUI is designed to be easy to use, accessible,
and powerful, making it ideal for both beginners and experts.</p>
<p><img src="https://tywer.dev/images/openwebui-welcome.webp" alt=""></p>
<p>To set up OpenWebUI, I explored the
<a href="https://docs.openwebui.com/" target="_blank" rel="noreferrer">OpenWebUI Documentation</a>, the
<a href="https://github.com/open-webui/open-webui" target="_blank" rel="noreferrer">OpenWebUI GitHub Repository</a> and
<a href="https://docs.openwebui.com/getting-started/env-configuration" target="_blank" rel="noreferrer">available environment variables</a>
and came up with the following to add to my <code>docker-compose.yml</code> file:</p>
<div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">openWebUI</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  image</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">ghcr.io/open-webui/open-webui:latest</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  container_name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">open-webui</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  restart</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">unless-stopped</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  ports</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"3000:8080"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  extra_hosts</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"host.docker.internal:host-gateway"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  volumes</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">open-webui:/app/backend/data</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"OLLAMA_BASE_URL=http://ollama:11434"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  depends_on</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">ollama</span></span></code></pre>
</div><p>I ran <code>docker-compose up -d</code> to start the OpenWebUI service. Once the service
was up and running, I accessed the OpenWebUI interface at
<code>http://localhost:3000</code>, but held off from trying it out since I wanted to
integrate it with Authelia for my Identity Provider.</p>
<h3 id="authelia-secure-access-with-oidc-two-factor-authentication" tabindex="-1">Authelia: Secure Access with OIDC &amp; Two-Factor Authentication </h3>
<p><a href="https://www.authelia.com/" target="_blank" rel="noreferrer">Authelia</a> is an open-source authentication and
authorization server that provides two-factor authentication and single sign-on
for your applications. It supports multiple authentication backends, including
LDAP, OAuth2, and OIDC. I chose to use Authelia with OIDC for my setup.</p>
<p><img src="https://tywer.dev/images/authelia-2fa-prompt.webp" alt=""></p>
<p>To integrate Authelia with OpenWebUI, I followed the
<a href="https://www.authelia.com/integration/openid-connect/open-webui/" target="_blank" rel="noreferrer">Authelia OIDCS Open WebUI documentation</a>.
The following YAML configuration is an example Authelia
<a href="https://www.authelia.com/configuration/identity-providers/openid-connect/clients/" target="_blank" rel="noreferrer">client configuration</a>
for use with <a href="https://docs.openwebui.com/" target="_blank" rel="noreferrer">Open WebUI</a>:</p>
<div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">identity_providers</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  oidc</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">    ## The other portions of the mandatory OpenID Connect 1.0 configuration go here.</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">    ## See: https://www.authelia.com/c/oidc</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    clients</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">      - </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">client_id</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"open-webui"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">        client_name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"Open WebUI"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">        client_secret</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"$pbkdf2-sha512$310000$c8p78n7pUMln0jzvd4aK4Q$JNRBzwAo0ek5qKn50cFzzvE9RXV88h1wJn5KGiHrD0YKtZaR/nCb2CJPOsKaPK0hjf.9yHxzQGZziziccp6Yng"</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"> # The digest of 'insecure_secret'.</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">        # Optionally use below if above digest approach doesn't work (not ideal):</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">        # client_secret: '&#x3C;YOUR_RAW_TEXT_CLIENT_SECRET>'</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">        # token_endpoint_auth_method: client_secret_basic</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">        public</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">false</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">        authorization_policy</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"two_factor"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">        redirect_uris</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">          - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"https://ai.example.com/oauth/oidc/callback"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">        scopes</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">          - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"openid"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">          - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"profile"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">          - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"groups"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">          - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"email"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">        userinfo_signed_response_alg</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"RS256"</span></span></code></pre>
</div><p>See
<a href="https://www.authelia.com/integration/openid-connect/frequently-asked-questions/#how-do-i-generate-a-client-identifier-or-client-secret" target="_blank" rel="noreferrer">How do I generate a client identifier or client secret?</a>
to generate the <code>client_secret</code> value.</p>
<p>I restarted my Authelia service and recreated my OpenWebUI container with the
updated environment variable configurations. Now finally, I made my way to
adding the nginx reverse proxy configuration to access with my own subdomain.</p>
<h3 id="nginx-secure-access-with-reverse-proxy" tabindex="-1">Nginx: Secure Access with Reverse Proxy </h3>
<p>In order to access OpenWebUI securely, I set up an NGINX reverse proxy with SSL
termination, see
<a href="https://github.com/linuxserver/docker-nginx" target="_blank" rel="noreferrer">linuxserver/docker-nginx</a> for a
great example. This allows me to access the service over HTTPS and have Authelia
handle the authentication. Here's the subdomain server configuration I used:</p>
<div class="language-nginx vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">nginx</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">server</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    listen </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">443</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> ssl;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    server_name </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">ai.*;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    include </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">/config/nginx/ssl.conf;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    client_max_body_size </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    include </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">/config/nginx/authelia-server.conf;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    location</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> / </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        include </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">/config/nginx/authelia-location.conf;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        include </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">/config/nginx/proxy.conf;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        include </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">/config/nginx/resolver.conf;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_app &#x3C;local_ip_or_container_name>;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_port </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">3002</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_proto http;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        proxy_pass </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_proto://$upstream_app:$upstream_port;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span></code></pre>
</div><div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p>Replace <code>&lt;local_ip_or_container_name&gt;</code> with the IP address or container name
of your OpenWebUI service.</p>
</div>
<h3 id="try-it-out" tabindex="-1">Try It Out </h3>
<p>With everything set up, I accessed my OpenWebUI service at
<code>https://ai.example.com</code> and was greeted with the Authelia login page. After
successfully authenticating, I was able to access the OpenWebUI interface and
run AI models like DeepSeek and Llama securely and privately.</p>
<p><img src="https://tywer.dev/images/openwebui-welcome.webp" alt=""></p>
<h3 id="workspace-knowledge-enhance-your-chats-with-context" tabindex="-1">Workspace Knowledge: Enhance Your Chats with Context </h3>
<p>You can leverage your own
<a href="https://docs.openwebui.com/features/workspace/knowledge/" target="_blank" rel="noreferrer">Knowledge</a> directly
in your chats with Open WebUI. This is a powerful feature that allows you to
provide context to your AI models and improve the quality of their responses.
You can add your Knowledge in the form of text, images, or files, and Open WebUI
will use it to generate more accurate and relevant responses.</p>
<p><img src="https://tywer.dev/images/openwebui-knowledge.webp" alt=""></p>
<h3 id="workspace-models-create-custom-models" tabindex="-1">Workspace Models: Create Custom Models </h3>
<p>You can create your own custom models in Open WebUI using the
<a href="https://docs.openwebui.com/features/workspace/models/" target="_blank" rel="noreferrer">Models</a> feature. This
allows you to attach your Knowledge to your models and use them to generate
responses in your chats with citations, etc. You can create models for a wide
range of tasks, including text generation, image recognition, and more.</p>
<h2 id="conclusion" tabindex="-1">Conclusion </h2>
<p>By combining the power of Ollama, the user-friendliness of OpenWebUI, and the
security of Authelia, I've pieced together a private, secure, and self-hosted AI
environment that allows me to run state-of-the-art models like Ollama and
DeepSeek without compromising my data. With GPU support, a user-friendly
interface, and secure access, I can leverage the full potential of AI models
while maintaining control over my data and privacy. If you're looking to build
your own self-hosted AI environment, I hope this guide has provided you with a
solid starting point.</p>
<p>For the full <code>docker-compose.yml</code> setup, see my
<a href="https://github.com/tdharris/ollama-openwebui" target="_blank" rel="noreferrer">tdharris/ollama-openwebui</a> GitHub
repository.</p>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[Tame Your Dynamic IP: A Cloudflare Worker Solution for Unifi]]></title>
            <link>https://tywer.dev/tame-your-dynamic-ip-a-cloudflare-worker-solution-for-unifi</link>
            <guid isPermaLink="false">https://tywer.dev/tame-your-dynamic-ip-a-cloudflare-worker-solution-for-unifi</guid>
            <pubDate>Sun, 15 Dec 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>Ever been frustrated with that pesky dynamic IP address from your ISP? You know,
the one that changes every so often, usually when you least expect it, and
you're left wondering why your services are down or your remote access isn't
working? While there are many Dynamic DNS (DDNS) services out there, I wanted to
explore a seamless solution connecting my Cloudflare DNS with my
<a href="https://ui.com/" target="_blank" rel="noreferrer">Unifi</a> network, leveraging
<a href="https://workers.cloudflare.com/" target="_blank" rel="noreferrer">Cloudflare Workers</a> to keep my DNS records
up-to-date.</p>
<p><img src="https://tywer.dev/images/dyndns-cloudflare-unifi.webp" alt=""></p>
<div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p>As of UniFi Network Application
<a href="https://community.ui.com/releases/UniFi-Network-Application-9-1-120/a5e88ae2-3c44-420a-bebb-5120bf2288b2" target="_blank" rel="noreferrer">9.1.120</a>,
there is native support for Cloudflare as a Dynamic DNS provider. This means
you can now configure your Unifi network to update your Cloudflare DNS records
directly without needing a custom Cloudflare Worker. For more details, see
<a href="https://help.ui.com/hc/en-us/articles/9203184738583-UniFi-Gateway-Dynamic-DNS" target="_blank" rel="noreferrer">UniFi Gateway - Dynamic DNS</a>.</p>
</div>
<h2 id="the-dns-strategy-one-record-to-rule-them-all" tabindex="-1">The DNS Strategy: One Record to Rule Them All </h2>
<p>The first step in this process is to create a DNS record in Cloudflare that will
be updated with your dynamic IP address. This record will be the primary record,
other subdomain services can <code>CNAME</code> to this primary record. This way, you only
need to update the primary record, and all other dependent subdomains will
automatically be updated with the new IP address.</p>
<ul>
<li>
<p><strong>Primary DNS Record</strong>:
<br/><code>dyndns.example.com</code> or <code>dns.example.com</code> as an <code>A</code> record to the IP
Address. This is the record that will be updated with the dynamic IP address.</p>
</li>
<li>
<p><strong>Service Subdomains</strong>:
<br/><code>service1.example.com</code>, <code>service2.example.com</code>, etc. (<code>CNAME</code> to the
above primary record).</p>
</li>
</ul>
<p><img src="https://tywer.dev/images/dyndns-one-record-to-rule-them-all.webp" alt=""></p>
<h2 id="cloudflare-worker-the-dynamic-ip-handler" tabindex="-1">Cloudflare Worker: The Dynamic IP Handler </h2>
<p>Next, we need to create a Cloudflare Worker that will handle the incoming
requests from the Unifi network and update the DNS record with the new IP
address. The Cloudflare Worker will be the endpoint that Unifi will call every
time the IP address changes.</p>
<p>This Cloudflare Worker acts as the middleman between your Unifi network and
Cloudflare's DNS API. Cloudflare Workers are like tiny programs that run on
Cloudflare's global network of servers, allowing you to execute code close to
your users and build incredibly fast and efficient applications. They're perfect
for tasks like handling API requests, modifying web pages on the fly, and, of
course, managing dynamic DNS!</p>
<p><img src="https://tywer.dev/images/dyndns-solution-diagram.webp" alt=""></p>
<p>Here's the breakdown:</p>
<ul>
<li>Enforces HTTPS to ensure all communication is encrypted.</li>
<li>Requires a valid Cloudflare API Key with appropriate permissions to update the
DNS record.</li>
<li>Requires a valid Domain name or Zone in Cloudflare.</li>
<li>Validates the incoming request's parameters (IP Address, Hostname, Domain /
Zone, and Cloudflare API Key).</li>
<li>Locates the DNS zone and record based on the provided hostname and domain.</li>
<li>Updates the DNS record with the new IP address.</li>
</ul>
<p>Essentially, this Worker provides a secure and automated way to update your DNS
records whenever your Unifi network detects an IP address change.</p>
<p>See the <strong>source code</strong> at
<a href="https://github.com/tdharris/cloudflare-worker-dyndns" target="_blank" rel="noreferrer">tdharris/cloudflare-worker-dyndns</a>
for my Dynamic DNS Cloudflare Worker that will update the DNS record with the
incoming IP address. It can be deployed to your Cloudflare account by cloning
the repository and using the
<a href="https://developers.cloudflare.com/workers/cli-wrangler" target="_blank" rel="noreferrer">Wrangler CLI</a> to
publish the Worker, see Step &quot;4. Deploy your project&quot; from the
<a href="https://developers.cloudflare.com/workers/get-started/guide/" target="_blank" rel="noreferrer">Quick Start Guide</a>.</p>
<h2 id="unifi-configuration-the-trigger-that-keeps-you-updated" tabindex="-1">Unifi Configuration: The Trigger That Keeps You Updated </h2>
<p>Unifi provides a feature called &quot;Dynamic DNS&quot; that allows you to configure a
custom script to run whenever the IP address changes. This is where we will
configure the Unifi network to call the Cloudflare Worker endpoint every time
the IP address changes.</p>
<h3 id="create-a-cloudflare-api-token" tabindex="-1">Create a Cloudflare API Token </h3>
<p>For the Cloudflare Worker to interact with the Cloudflare API, you will need to
create an API Token with the appropriate permissions. See the
<a href="https://developers.cloudflare.com/api/tokens/create" target="_blank" rel="noreferrer">Cloudflare API Tokens documentation</a>
for more information on creating a token with the necessary permissions. Either
a User or an Account API Token can be used.</p>
<p>For this use case, you will need the following permissions:</p>
<ul>
<li><code>Zone:Zone:Read</code></li>
<li><code>Zone:DNS:Read</code></li>
<li><code>Zone:DNS:Edit</code></li>
</ul>
<p><img src="https://tywer.dev/images/dyndns-cloudflare-api-token.webp" alt=""></p>
<h3 id="configure-unifi-dynamic-dns" tabindex="-1">Configure Unifi Dynamic DNS </h3>
<p>For more information, see the
<a href="https://help.ui.com/hc/en-us/articles/9203184738583-UniFi-Gateway-Dynamic-DNS" target="_blank" rel="noreferrer">Unifi Gateway Dynamic DNS documentation</a>.
At the time of writing this, the following steps are how to configure the Unifi
Gateway to call the Cloudflare Worker endpoint:</p>
<ol>
<li>
<p>Open the <strong>Unifi Dynamic DNS Settings</strong>:</p>
<ul>
<li>Navigate to your Unifi Controller.</li>
<li>Go to the <code>Settings</code> tab.</li>
<li>Go to the <code>Internet</code> tab.</li>
<li>Select the appropriate <code>WAN</code> interface.</li>
<li>Scroll down to the <code>Dynamic DNS</code> section.</li>
<li>Select <code>Create New Dynamic DNS</code>.</li>
</ul>
</li>
<li>
<p>Configure the Dynamic DNS Settings:</p>
<ul>
<li><strong>Service</strong>: <code>dyndns</code></li>
<li><strong>Hostname</strong>: <code>dns.example.com</code> - your primary DNS record.</li>
<li><strong>Username</strong>: <code>user@example.com</code> - your Cloudflare API Email Address.</li>
<li><strong>Password</strong>: <code>xxxxxxxx</code> - your Cloudflare API Token.</li>
<li><strong>Server</strong>: The Cloudflare Worker endpoint URL with the following URI
parameters:
<ul>
<li><code>ip</code>: <code>%i</code> - The IP Address, provided dynamically by Unifi.</li>
<li><code>hostname</code>: <code>%h</code> - The Hostname, provided dynamically by Unifi.</li>
<li><code>zone</code>: <code>example.com</code> - The Zone Name, provided statically by you.</li>
</ul>
</li>
</ul>
<p>For example:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">https://your-worker-subdomain.your-worker-name.workers.dev/update?ip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">=%i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">&#x26;hostname</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">%h</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">&#x26;zone</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">example.com</span></span></code></pre>
</div><div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p></p>
<ul>
<li>Replace <code>your-worker-subdomain</code> and <code>your-worker-name</code> with your
Cloudflare Worker subdomain and name.</li>
<li>Replace <code>example.com</code> with your Cloudflare Zone Name.</li>
</ul>
</div>
<p><img src="https://tywer.dev/images/dyndns-unifi-settings.webp" alt=""></p>
</li>
</ol>
<h2 id="conclusion" tabindex="-1">Conclusion </h2>
<p>And there you have it! You've now built your own dynamic DNS system using the
combined powers of Cloudflare Workers and your Unifi network. No more worrying
about IP address changes affecting your remote access. Whether you're running a
homelab or hosting a personal website, this solution provides a reliable and
efficient way to keep your DNS records up-to-date. So go ahead, embrace the
dynamic world of IP addresses with confidence, knowing your domain or subdomain
will always lead to the right place.</p>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[AI-Powered Bookmarking: Self-Hosting Hoarder - Integrating OpenAI, Meilisearch and Authelia]]></title>
            <link>https://tywer.dev/ai-powered-bookmarking-self-hosting-hoarder</link>
            <guid isPermaLink="false">https://tywer.dev/ai-powered-bookmarking-self-hosting-hoarder</guid>
            <pubDate>Sat, 05 Oct 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>Overwhelmed by the endless flood of online information?
<a href="https://hoarder.app/" target="_blank" rel="noreferrer">Hoarder</a> is your self-hosted solution for taming the
chaos. Combine its powerful bookmarking and note-taking features with
<a href="https://openai.com/" target="_blank" rel="noreferrer">OpenAI</a> intelligence,
<a href="https://www.meilisearch.com/" target="_blank" rel="noreferrer">Meilisearch</a> lightning fast search engine and
<a href="https://www.authelia.com/" target="_blank" rel="noreferrer">Authelia</a> secure OIDC authentication, and you've got
a curated collection of your online discoveries. Let's dive into how to set up
Hoarder with multi-user support, supercharged by AI for ultimate organization.</p>
<p><img src="https://tywer.dev/images/hoarder-app.webp" alt=""></p>
<h2 id="the-bookmark-everything-app" tabindex="-1">The Bookmark Everything App </h2>
<p>Hoarder is an app that lets you quickly save and organize links, notes, and
images. It will automatically tag them using AI, making it easy to find them
later. It's an open-source alternative to services like
<a href="https://getpocket.com/" target="_blank" rel="noreferrer">Pocket</a> and <a href="https://raindrop.io/" target="_blank" rel="noreferrer">Raindrop</a>. Similar
open-source projects are <a href="https://bmrk.cc/" target="_blank" rel="noreferrer">Bookmark It</a> and
<a href="https://brace.to/" target="_blank" rel="noreferrer">Brace.to</a>.</p>
<p>Key features and benefits:</p>
<ul>
<li><strong>Effortless Bookmarking</strong>: Save links, notes, and images with just a click.</li>
<li><strong>AI-Powered Tagging</strong>: Hoarder uses OpenAI to automatically tag your
bookmarks.</li>
<li><strong>Informative Previews</strong>: Automatically fetches metadata like title,
description, and an image so you can quickly identify everything.</li>
<li><strong>Organize with Ease</strong>: Create lists and tags to keep everything organized how
you like.</li>
<li><strong>Search and Filter</strong>: Quickly find what you're looking for with powerful
search and filter capabilities.</li>
<li><strong>Cross-Platform</strong>: Access your bookmarks from any device with a modern web
browser with support for mobile apps and browser extensions.</li>
<li><strong>Self-Hosted</strong>: You own your data and can run it on your own server. It's
also open-source!</li>
</ul>
<p>I have been saving interesting articles and various tools I come across as well
as birthday gift ideas for friends and family.</p>
<h2 id="installation-configuration" tabindex="-1">Installation &amp; Configuration </h2>
<p>Check out the <a href="https://docs.hoarder.app/" target="_blank" rel="noreferrer">official Hoarder documentation</a> for
detailed installation instructions. You can run Hoarder using Docker, Unraid,
manually on your server or even on Kubernetes. I went with the recommended
approach and followed the
<a href="https://docs.hoarder.app/Installation/docker" target="_blank" rel="noreferrer">Docker Compose Installation</a>
steps to download the compose file, populate the initial environment variables
and get it running.</p>
<h2 id="customization-advanced-features" tabindex="-1">Customization &amp; Advanced Features </h2>
<p>For more details on how to customize Hoarder, check out the
<a href="https://docs.hoarder.app/configuration" target="_blank" rel="noreferrer">Hoarder Configuration</a> documentation.</p>
<h3 id="openai-integration-for-automatic-tagging" tabindex="-1">OpenAI Integration for Automatic Tagging </h3>
<p>Hoarder supports AI tagging using either OpenAI or Ollama. While both OpenAI and
Ollama provide access to powerful language models, they differ significantly in
their approach. OpenAI offers cloud-based access to its models (like GPT-3.5 and
GPT-4) via API, making them readily available but with usage costs. Ollama, on
the other hand, focuses on running open-source language models locally on your
own hardware. This gives you more control and privacy, but requires technical
expertise and sufficient computing resources.</p>
<p><img src="https://tywer.dev/images/ollama-vs-openai.webp" alt=""></p>
<p>I decided to quickly create an account with OpenAI at
<a href="https://platform.openai.com/" target="_blank" rel="noreferrer">platform.openai.com</a>, created a new <code>hoarder</code>
project and API key using the <code>gpt-4o-mini</code> inference text model and topped up
the account with some minimal credits. The quality of the tags you'll get will
depend on the quality of the model you choose, but it seems to do well with just
this minimal one. See the
<a href="https://platform.openai.com/docs/quickstart" target="_blank" rel="noreferrer">OpenAI Platform Quickstart guide</a>
for more details.</p>
<p>I then added the api key to the Hoarder environment variable <code>OPENAI_API_KEY</code>,
which enabled the OpenAI integration. Now, whenever I save a bookmark, Hoarder
automatically tags it with relevant keywords, making it easier to find later.
For more information, see the
<a href="https://docs.hoarder.app/configuration#inference-configs-for-automatic-tagging" target="_blank" rel="noreferrer">Hoarder Inference Configs</a>
documentation.</p>
<h4 id="openai-costs" tabindex="-1">OpenAI Costs </h4>
<p>OpenAI charges per token used, with the cost varying depending on the model you
choose. The <code>gpt-4o-mini</code> model is quite affordable. You can check the
<a href="https://platform.openai.com/pricing" target="_blank" rel="noreferrer">OpenAI Pricing</a> page for more details. In
my experience, it seems like I could get 20,000 bookmarks tagged for around $5,
which is quite reasonable. I am also considering trying out Ollama in the future
to compare the results and see what kind of performance it needs to run locally.</p>
<h3 id="meilisearch-integration-for-search" tabindex="-1">Meilisearch Integration for Search </h3>
<p><a href="https://www.meilisearch.com/" target="_blank" rel="noreferrer">Meilisearch</a> is an open-source and fast search
engine that provides instant search results. It's easy to set up and can be
integrated with Hoarder to provide a seamless search experience. Hoarder's
<code>docker-compose.yml</code> comes with an internal Meilisearch instance to support
search functionality.</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">MEILI_MASTER_KEY</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">Generate</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> one</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> with</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "openssl rand -base64 36"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span></code></pre>
</div><p>I did run into an issue where search wasn't initially working, but after
following the suggestion from
<a href="https://github.com/hoarder-app/hoarder/issues/342" target="_blank" rel="noreferrer">Issue #342</a>, it then worked
immediately.</p>
<h3 id="nginx-reverse-proxy-configuration" tabindex="-1">NGINX Reverse Proxy Configuration </h3>
<p>In order to access Hoarder over HTTPS and have it served on a subdomain. I
already had an NGINX reverse proxy set up for other services, so I added a new
server block to the configuration files. Here's a simplified version of the
configuration:</p>
<div class="language-nginx vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">nginx</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">server</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    listen </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">443</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> ssl;</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">    # listen [::]:443 ssl;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    server_name </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">hoarder.*;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    include </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">/config/nginx/ssl.conf;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    client_max_body_size </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    location</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> / </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        include </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">/config/nginx/proxy.conf;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        include </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">/config/nginx/resolver.conf;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_app &#x3C;ip_or_container_name>;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_port </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">3000</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_proto http;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        proxy_pass </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_proto://$upstream_app:$upstream_port;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    location</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> ~</span><span style="--shiki-light:#032F62;--shiki-dark:#DBEDFF"> (/hoarder)?/api </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        include </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">/config/nginx/proxy.conf;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        include </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">/config/nginx/resolver.conf;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_app &#x3C;ip_or_container_name>;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_port </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">3000</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_proto http;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        proxy_pass </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_proto://$upstream_app:$upstream_port;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span></code></pre>
</div><h3 id="authelia-integration-for-oidc-authentication" tabindex="-1">Authelia Integration for OIDC Authentication </h3>
<p>I wanted to integrate SSO authentication to Hoarder since I've been using
<a href="https://www.authelia.com/" target="_blank" rel="noreferrer">Authelia</a> for other services. Authelia is an
open-source authentication and authorization server that provides Single Sign-On
(SSO) and two-factor authentication (2FA) for your applications. It supports
OpenID Connect (OIDC), SAML, and LDAP, and can be easily integrated with
services like Hoarder.</p>
<p>Previously, I've followed the
<a href="https://www.authelia.com/configuration/identity-providers/introduction/" target="_blank" rel="noreferrer">Authelia Identity Providers - OpenID Connect documentation</a>
to set up my internal Identity Provider (IdP). What's needed next is to
configure a new Client Application in Authelia for Hoarder. For more context,
see my Hoarder Discussion
<a href="https://github.com/hoarder-app/hoarder/discussions/419" target="_blank" rel="noreferrer">Authelia OIDC Client Config - Hoarder OAUTH SSO</a>
as you'll find others who have shared their configs as well for Google,
<a href="https://goauthentik.io/" target="_blank" rel="noreferrer">Authentik</a>, etc.</p>
<p>For my integration with Authelia, an example client config I found to work is
the following:</p>
<div class="language-yaml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yaml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">- </span><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">client_id</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"hoarder"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  client_name</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"Hoarder"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  client_secret</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"&#x3C;generated_plaintext_client_secret>"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  token_endpoint_auth_method</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">client_secret_basic</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  authorization_policy</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">two_factor</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"> # optional</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  redirect_uris</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"https://&#x3C;hoarder_address>/api/auth/callback/custom"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  audience</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># optional</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"https://&#x3C;hoarder_address>"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  grant_types</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># optional</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">authorization_code</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">  scopes</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">openid</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">profile</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    - </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">email</span></span></code></pre>
</div><div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p>Based on various failed attempts, it seemed that <code>token_endpoint_auth_method</code>:
<code>client_secret_basic</code> was necessary, with the <code>client_secret</code> configured with
a plaintext value. For more information, see
<a href="https://www.authelia.com/integration/openid-connect/frequently-asked-questions/#how-do-i-generate-a-client-identifier-or-client-secret" target="_blank" rel="noreferrer">How Do I Generate a Client Identifier or Client Secret</a>.</p>
</div>
<p>I added the following environment variables to my Hoarder configuration:</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># .env</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">OAUTH_WELLKNOWN_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">https://</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">authelia_address</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">/.well-known/openid-configuration</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">OAUTH_CLIENT_SECRET</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">plaintext_client_secret_from_authelia</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">OAUTH_CLIENT_ID</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">hoarder</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">OAUTH_PROVIDER_NAME</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">authelia</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">NEXTAUTH_URL</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">https://</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">hoarder_address</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">DISABLE_SIGNUPS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">true</span><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"> # optional - avoid new users signing up as local Hoarder users</span></span></code></pre>
</div><div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p>For more information, see the
<a href="https://docs.hoarder.app/configuration#authentication--signup" target="_blank" rel="noreferrer">Hoarder Authentication / Signup</a>
documentation.</p>
</div>
<p>Now, when I access Hoarder, I can select <code>Login with Authelia</code> and I'm
redirected to the Authelia login page and then access Hoarder! Other users can
also log in using their Authelia credentials. And everything is protected by
Authelia's 2FA, which is a nice added layer of security.</p>
<p><img src="https://media2.giphy.com/media/v1.Y2lkPTc5MGI3NjExNWR6amJ2cG1nZTN5eTZhaXZsajgxZnllZG9kMDhmbnNmOXIxdG5hYyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/5GoVLqeAOo6PK/200.webp" alt=""></p>
<!-- ![](https://media4.giphy.com/media/TdfyKrN7HGTIY/200.webp?cid=790b7611cvkx7c7ax1rf3olxo512qglekizr1aoxor1f280z&ep=v1_gifs_search&rid=200.webp&ct=g) -->
<h2 id="conclusion" tabindex="-1">Conclusion </h2>
<p>Hoarder is a powerful self-hosted bookmarking app that can help you organize
your online discoveries. By integrating OpenAI, Meilisearch, and Authelia, you
can supercharge your bookmarking experience with AI tagging, lightning-fast
search, and secure OIDC authentication. Give it a try to tame the chaos of the
internet!</p>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[Beyond Screenshots: Capture CLI Magic with Charmbracelet VHS]]></title>
            <link>https://tywer.dev/beyond-screenshots-capture-cli-magic-with-charmbracelet-vhs</link>
            <guid isPermaLink="false">https://tywer.dev/beyond-screenshots-capture-cli-magic-with-charmbracelet-vhs</guid>
            <pubDate>Fri, 13 Sep 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>Tired of static screenshots failing to capture the magic of your CLI wizardry?
Sometimes you need to show off your tools in motion. Recently, I stumbled upon a
<em>charming</em> little tool called <a href="https://github.com/charmbracelet/vhs" target="_blank" rel="noreferrer">VHS</a> from
<a href="https://github.com/charmbracelet" target="_blank" rel="noreferrer">Charmbracelet</a> that allows you to record your
terminal sessions in a beautifully consistent way. Let's explore how to use it
and some of its features.</p>
<p><img src="https://tywer.dev/images/vhs.webp" alt=""></p>
<h2 id="terminal-gifs-as-code" tabindex="-1">Terminal GIFs as Code </h2>
<p>Write terminal GIFs as code for integration testing and demoing your CLI tools.
VHS is a Go library that records your terminal sessions and outputs them as GIFs
as well as other formats like mp4. It's a great way to show off your CLI tools
in action as sometimes a screenshot just doesn't cut it.</p>
<h3 id="record-tapes-capture-your-terminal-sessions" tabindex="-1">Record Tapes: Capture Your Terminal Sessions </h3>
<p>VHS records your terminal sessions into tapes. A tape file is a series of
instructions or commands that represent your terminal session. You can then
replay these tapes so they render into GIFs and other formats. You can customize
the output formats, colors, themes, font sizes, typing speed, and more. This is
great for creating consistent demos of your CLI tools. Recording a tape file is
better than just recording the terminal directly as it allows you to have more
control and reproducibility. See the
<a href="https://github.com/charmbracelet/vhs#vhs-command-reference" target="_blank" rel="noreferrer">VHS Command Reference</a>
for more details.</p>
<p>A quick way to get an initial tape is to use the <code>vhs record</code> command. This will
start recording your terminal session into a tape file. You can then stop
recording by typing <code>exit</code>.</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">vhs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> record</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> ></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> cassette.tape</span></span></code></pre>
</div><p>Here is an example tape file:</p>
<div class="language-elixir vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">elixir</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Where should we write the GIF?</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Output</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> demo.gif</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Set up a 1200x600 terminal with 46px font.</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Set</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> FontSize</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 46</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Set</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> Width</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 1200</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Set</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> Height</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 300</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Type a command in the terminal.</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Type</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "echo 'Welcome to VHS!'"</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Pause for dramatic effect...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Sleep</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> 500ms</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Run the command by pressing enter.</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Enter</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Admire the output for a bit.</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Sleep</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> 5s</span></span></code></pre>
</div><h3 id="play-tapes-render-outputs-gifs" tabindex="-1">Play Tapes: Render Outputs (GIFs) </h3>
<p>Once you have a tape file, you can replay it to render GIFs and other formats.
You can use the <code>vhs replay</code> command to replay a tape file. This will render the
tape into a GIF file by default. You can also specify other output formats like
mp4, etc. You can tweak all the various style settings to get it just right.</p>
<p>Here is an example of rendering a GIF from the above tape file:</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">vhs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> cassette.tape</span></span></code></pre>
</div><p>Here is the GIF output from the above example tape file:</p>
<p><video src="https://tywer.dev/images/vhs-demo.webm" autoplay loop muted playsinline style="max-width: 100%; height: auto;"></video></p>
<h3 id="publish-tapes-sharing-made-simple" tabindex="-1">Publish Tapes: Sharing Made Simple </h3>
<p>Once you have your GIFs, you can easily share them with others. You can embed
them in your documentation, blog posts, or even your GitHub READMEs. You can
also simply publish them to their servers for easy sharing using the <code>publish</code>
subcommand. This hosts them on <code>vhs.charm.sh</code>. The output provides a link to
share your GIFs with others.</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">❯</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> vhs</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> publish</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> demo.gif</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">  Share</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> your</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> GIF</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> with</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Markdown:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">  !</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">[Made with VHS](</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">https://vhs.charm.sh/vhs-2sbLBRPQRiJHxruJda9hbW.gif</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">)</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">  Or</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> HTML</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (with </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">badge</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">):</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">  &#x3C;</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">img</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> src="https://vhs.charm.sh/vhs-2sbLBRPQRiJHxruJda9hbW.gif"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> alt="Made with VHS"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">  &#x3C;</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">a</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> href="https://vhs.charm.sh"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    &#x3C;</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">img</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> src="https://stuff.charm.sh/vhs/badge.svg"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">  &#x3C;</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">/a</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">></span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">  Or</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> link</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> to</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> it:</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">  https://vhs.charm.sh/vhs-2sbLBRPQRiJHxruJda9hbW.gif</span></span></code></pre>
</div><h3 id="ci-cd-integration-automate-your-demos" tabindex="-1">CI/CD Integration: Automate Your Demos </h3>
<p>You can integrate VHS into your CI/CD pipelines to automatically generate GIFs
of your tools in action. This is a great way to ensure your demos are always up
to date and consistent. You can also use it to create integration tests for your
CLI tools. You can record your terminal sessions and replay them to ensure your
tools are working as expected.</p>
<p>See <a href="https://github.com/charmbracelet/vhs-action" target="_blank" rel="noreferrer">charmbracelet/vhs-action</a> and
<a href="https://github.com/charmbracelet/vhs#continuous-integration" target="_blank" rel="noreferrer">Continuous Integration (CI)</a>
for more details.</p>
<h2 id="showcase-your-cli-tools" tabindex="-1">Showcase Your CLI Tools </h2>
<p>VHS is a great tool for showcasing your CLI tools in action. It's a fun way to
create consistent demos that show off your tools in a visually appealing way.
It's also a great way to create integration tests for your CLI tools. You can
record your terminal sessions and replay them to ensure your tools are working
as expected.</p>
<p>Here are some other examples of VHS tapes from a <code>gh2gl</code> tool I've been working
on:</p>
<ul>
<li>
<p>Migrate GitHub repositories to GitLab projects.
<video src="https://tywer.dev/images/gh2gl.webm" autoplay loop muted playsinline style="max-width: 100%; height: auto;"></video></p>
</li>
<li>
<p>Configure consistent Protected Branch Settings for GitLab projects.
<video src="https://tywer.dev/images/gh2gl-projects-protected-branch.webm" autoplay loop muted playsinline style="max-width: 100%; height: auto;"></video></p>
</li>
<li>
<p>Configure Merge Approval Rules for GitLab projects.
<video src="https://tywer.dev/images/gh2gl-projects-merge-approval.webm" autoplay loop muted playsinline style="max-width: 100%; height: auto;"></video></p>
</li>
<li>
<p>Configure Merge Method for GitLab projects.
<video src="https://tywer.dev/images/gh2gl-projects-merge-method.webm" autoplay loop muted playsinline style="max-width: 100%; height: auto;"></video></p>
</li>
<li>
<p>Set up GitLab as a remote for existing local GitHub repositories.
<video src="https://tywer.dev/images/gh2gl-git-remote-set-url.webm" autoplay loop muted playsinline style="max-width: 100%; height: auto;"></video></p>
</li>
</ul>
<a href="https://vhs.charm.sh">
  <img src="https://stuff.charm.sh/vhs/badge.svg">
</a>
<h2 id="conclusion" tabindex="-1">Conclusion </h2>
<p>VHS is a <em>charming</em> tool that allows you to capture your CLI magic in motion.
It's a great way to showcase your CLI tools in a visually appealing way. It's
also a great way to create integration tests for your CLI tools. Give it a try
and see how it can help you show off your tools in a whole new light.</p>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[Automating AWS Access Key Rotation with Terraform, Keybase, Bitwarden Secrets Manager]]></title>
            <link>https://tywer.dev/automating-aws-access-key-rotation-with-terraform-keybase-bitwarden-secrets-manager</link>
            <guid isPermaLink="false">https://tywer.dev/automating-aws-access-key-rotation-with-terraform-keybase-bitwarden-secrets-manager</guid>
            <pubDate>Mon, 22 Jul 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>In the evolving landscape of cloud security, managing AWS IAM Access Keys
securely and efficiently is paramount. This guide introduces a robust method to
automate the creation, deletion, and rotation of AWS IAM Access Keys using
Terraform, Keybase, and Bitwarden Secrets Manager, ensuring your credentials are
always up-to-date and securely stored.</p>
<p>This solution leverages Terraform to manage the lifecycle of AWS IAM Access
Keys, Keybase for pgp encryption and decryption of secrets from AWS, and
<em>optionally</em> Bitwarden Secrets Manager for storing and retrieving secrets across
projects.</p>
<div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p>For seamless project switching with automatic secret retrieval as environment
variables, see
<a href="https://tywer.dev/secrets-management-for-developers.html">Bitwarden Secrets Manager: Elevating Developer Environments</a>.</p>
</div>
<p><img src="https://tywer.dev/images/terraform-aws-keybase-bitwarden.webp" alt=""></p>
<h2 id="dependencies" tabindex="-1">Dependencies </h2>
<h3 id="terraform" tabindex="-1">Terraform </h3>
<p><a href="https://www.terraform.io/" target="_blank" rel="noreferrer">Terraform</a> or
<a href="https://opentofu.org/manifesto/" target="_blank" rel="noreferrer">OpenTofu</a> is the Infrastructure as Code (IaC)
tool used here to manage the lifecycle of these AWS IAM Access Keys. Terraform
is a popular choice for managing cloud resources due to its declarative syntax
and support for multiple cloud providers. With this approach, we can simply
<code>apply</code> and/or <code>destroy</code> our Terraform configuration to create, delete, or
update our AWS Access Keys. Multiple keys for various environments can be
handled using
<a href="https://developer.hashicorp.com/terraform/cloud-docs/workspaces" target="_blank" rel="noreferrer">Terraform Workspaces</a>.</p>
<h3 id="keybase" tabindex="-1">Keybase </h3>
<p>To avoid storing the secret in plaintext in tfstate, the secret is encrypted
with a
<a href="https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_access_key#pgp_key" target="_blank" rel="noreferrer">pgp_key</a>,
in this case, the pgp key from Keybase. Keybase is a secure messaging and
file-sharing platform that provides end-to-end encryption for messages and
files. We can use Keybase to encrypt and decrypt our secrets securely.</p>
<h3 id="bitwarden-secrets-manager" tabindex="-1">Bitwarden Secrets Manager </h3>
<p><a href="https://bitwarden.com/help/secrets-manager-overview/" target="_blank" rel="noreferrer">Bitwarden Secrets Manager</a>
allows me to persist my secrets across projects and environments. I can easily
retrieve my secrets as environment variables using the
<a href="https://bitwarden.com/help/secrets-manager-cli/" target="_blank" rel="noreferrer">Secrets Manager CLI</a> (<code>bws</code>).
This is especially useful when working on multiple projects or switching between
environments.</p>
<h2 id="solution" tabindex="-1">Solution </h2>
<p>My
<a href="https://github.com/tdharris/terraform-aws-access-key" target="_blank" rel="noreferrer">tdharris/terraform-aws-access-key</a>
repository contains the Terraform configuration and supporting script to easily
create, delete, and rotate AWS IAM Access Keys using Terraform, Keybase, and
Bitwarden Secrets Manager.</p>
<p>Ensure you are in the correct AWS account before each operation:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">aws</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> sts</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> get-caller-identity</span></span></code></pre>
</div><p>For all operations, select the appropriate Terraform workspace for the account
or environment:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">terraform</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> workspace</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> select</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">nam</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span></code></pre>
</div><p>If the workspace does not exist, create it with:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">terraform</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> workspace</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> new</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">nam</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span></code></pre>
</div><h3 id="usage" tabindex="-1">Usage </h3>
<p>The <code>aws-key.sh</code> script is a wrapper around the Terraform configuration to
simplify the process of creating, rotating, and deleting AWS IAM Access Keys and
decrypting them using Keybase. It also provides an option to sync the Key to
Bitwarden Secrets Manager for storing and retrieving secrets across projects.</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Commands:</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    create</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      Create</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> a</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> new</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Key.</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    delete</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      Delete</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> an</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> existing</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Key.</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    rotate</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      Rotate</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> an</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> existing</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Key.</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    decrypt</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">     Output</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> decrypted</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Key.</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    update</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      Update</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> the</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> status</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> of</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> an</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Key</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (active </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">or</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> inactive</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">). (</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">default</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> is</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> active</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">)</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    bws-sync</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">    Sync</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> the</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Key</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> to</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Bitwarden</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Secrets</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Manager</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (customized).</span></span></code></pre>
</div><ol>
<li>
<p><strong>Create Key</strong>:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">./aws-key.sh</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> create</span></span></code></pre>
</div><details>
 <summary>Show Terraform Apply</summary>
<div class="language-hcl vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">hcl</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Terraform used the selected providers to generate the following execution plan</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Resource actions are indicated with the following symbols</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> create</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Terraform will perform the following actions</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># aws_iam_access_key.example will be created</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">+</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> resource</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> "aws_iam_access_key"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> "example"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> create_date</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">          =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (known after apply)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> encrypted_secret</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">     =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (known after apply)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">                   =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (known after apply)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> key_fingerprint</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">      =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (known after apply)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> pgp_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">              =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "keybase:some_person_that_exists"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> secret</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">               =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (sensitive value)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> ses_smtp_password_v4</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (sensitive value)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> status</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">               =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "Active"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> user</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">                 =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "mycli"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Plan</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> to add, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> to change, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> to destroy</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Changes to Outputs</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> aws_access_key_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">   =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (known after apply)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> aws_caller_identity</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> account_id </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> arn        </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "arn:aws:iam::&#x3C;account-id>:user/mycli"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> id         </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> user_id    </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;user-id>"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> aws_user_name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">       =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "mycli"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> encrypted_secret</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (sensitive value)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_iam_access_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">example</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Creating</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">...</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_iam_access_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">example</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Creation complete after 1s [id=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">new-access-key-id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">]</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Apply complete</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">!</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Resources</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> added, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> changed, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> destroyed</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Outputs</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_access_key_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;new-access-key-id>"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_caller_identity</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"account_id"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>"</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"arn"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "arn:aws:iam::&#x3C;account-id>:user/mycli"</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"id"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>"</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"user_id"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;user-id>"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_user_name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "mycli"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">encrypted_secret</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">sensitive</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span></code></pre>
</div></details>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Retrieved from tfstate, parsed and decrypted using Keybase</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Decrypted</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Outputs:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">aws_user_name</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "mycli"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">aws_access_key_id</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;new-access-key-id>"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">aws_decrypted_secret</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;decrypted-secret>"</span></span></code></pre>
</div></li>
<li>
<p><strong>Rotate Key</strong>:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">./aws-key.sh</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> rotate</span></span></code></pre>
</div><div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Example</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">$</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> ./aws-key.sh</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> rotate</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Previously</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> invoked</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> identity</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (tfstate):</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "account_id"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "arn"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "arn:aws:iam::&#x3C;account-id>:user/mycli"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "id"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "user_id"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;user-id>"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Current</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Identity:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "UserId"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;user-id>",</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "Account"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>",</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "Arn"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "arn:aws:iam::&#x3C;account-id>:user/mycli"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Validating</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> tfstate</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> identity</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> is</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> the</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> same</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> as</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> current</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> aws</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> identity...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">✔</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Success</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Rotate</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> aws</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> access</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> key</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> '&#x3C;old-access-key-id>'</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> ?</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> [y/n] y</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Rotating</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> access</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> key</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> with</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> terraform</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> destroy,</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> then</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> apply...</span></span></code></pre>
</div><details>
 <summary>Show Terraform Destroy & Apply</summary>
<div class="language-hcl vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">hcl</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Destroy</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_iam_access_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">example</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Refreshing state</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">...</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> [id=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">old-access-key-id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">]</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Terraform used the selected providers to generate the following execution plan</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Resource actions are indicated with the following symbols</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> destroy</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Terraform will perform the following actions</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># aws_iam_access_key.example will be destroyed</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> resource</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> "aws_iam_access_key"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> "example"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> create_date</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">          =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;date>"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> encrypted_secret</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">     =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;secret>"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">                   =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;old-access-key-id>"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> key_fingerprint</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">      =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;fingerprint>"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> pgp_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">              =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "keybase:some_person_that_exists"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> ses_smtp_password_v4</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (sensitive value)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> status</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">               =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "Active"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> user</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">                 =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "mycli"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Plan</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> to add, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> to change, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> to destroy</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Changes to Outputs</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> aws_access_key_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">   =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;old-access-key-id>"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> aws_caller_identity</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> account_id </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> arn        </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "arn:aws:iam::&#x3C;account-id>:user/mycli"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> id         </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> user_id    </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;user-id>"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> aws_user_name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">       =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "mycli"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> encrypted_secret</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (sensitive value)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_iam_access_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">example</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Destroying</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">...</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> [id=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">old-access-key-id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_iam_access_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">example</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Destruction complete after 0s</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Destroy complete</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">!</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Resources</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> destroyed</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span></span></code></pre>
</div><div class="language-hcl vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">hcl</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Apply</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Terraform used the selected providers to generate the following execution plan</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Resource actions are indicated with the following symbols</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> create</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Terraform will perform the following actions</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># aws_iam_access_key.example will be created</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">+</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> resource</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> "aws_iam_access_key"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> "example"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> create_date</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">          =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (known after apply)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> encrypted_secret</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">     =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (known after apply)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">                   =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (known after apply)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> key_fingerprint</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">      =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (known after apply)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> pgp_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">              =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "keybase:some_person_that_exists"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> secret</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">               =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (sensitive value)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> ses_smtp_password_v4</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (sensitive value)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> status</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">               =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "Active"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> user</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">                 =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "mycli"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Plan</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> to add, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> to change, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> to destroy</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Changes to Outputs</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> aws_access_key_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">   =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (known after apply)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> aws_caller_identity</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> account_id </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> arn        </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "arn:aws:iam::&#x3C;account-id>:user/mycli"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> id         </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    +</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> user_id    </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;user-id>"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> aws_user_name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">       =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "mycli"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> encrypted_secret</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (sensitive value)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_iam_access_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">example</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Creating</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">...</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_iam_access_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">example</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Creation complete after 1s [id=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">new-access-key-id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">]</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Apply complete</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">!</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Resources</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> added, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> changed, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> destroyed</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Outputs</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_access_key_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;new-access-key-id>"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_caller_identity</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"account_id"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>"</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"arn"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "arn:aws:iam::&#x3C;account-id>:user/mycli"</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"id"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>"</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"user_id"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;user-id>"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_user_name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "mycli"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">encrypted_secret</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">sensitive</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span></code></pre>
</div></details>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Retrieved from tfstate, parsed and decrypted using Keybase</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Decrypted</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Outputs:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">aws_user_name</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "mycli"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">aws_access_key_id</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;new-access-key-id>"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">aws_decrypted_secret</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;decrypted-secret>"</span></span></code></pre>
</div></li>
<li>
<p><strong>Decrypt Key</strong>:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">./aws-key.sh</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> decrypt</span></span></code></pre>
</div><div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Retrieved from tfstate, parsed and decrypted using Keybase</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Decrypted</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Outputs:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">aws_user_name</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "mycli"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">aws_access_key_id</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;new-access-key-id>"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">aws_decrypted_secret</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;decrypted-secret>"</span></span></code></pre>
</div></li>
<li>
<p><strong>Import Existing Key</strong>:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">terraform</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> import</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> aws_iam_access_key.key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">access_key_i</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">d</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span></code></pre>
</div></li>
<li>
<p><strong>Deactivate/Activate Key</strong>:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">./aws-key.sh</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> update</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> inactive</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">./aws-key.sh</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> update</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> active</span></span></code></pre>
</div></li>
<li>
<p><strong>Delete Key</strong>:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">./aws-key.sh</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> delete</span></span></code></pre>
</div><details>
 <summary>Show Terraform Destroy</summary>
<div class="language-hcl vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">hcl</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Destroy</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_iam_access_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">example</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Refreshing state</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">...</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> [id=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">old-access-key-id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">]</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Terraform used the selected providers to generate the following execution plan</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Resource actions are indicated with the following symbols</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> destroy</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Terraform will perform the following actions</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># aws_iam_access_key.example will be destroyed</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> resource</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> "aws_iam_access_key"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> "example"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> create_date</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">          =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;date>"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> encrypted_secret</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">     =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;secret>"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">                   =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;old-access-key-id>"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> key_fingerprint</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">      =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;fingerprint>"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> pgp_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">              =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "keybase:some_person_that_exists"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> ses_smtp_password_v4</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (sensitive value)</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> status</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">               =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "Active"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> user</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">                 =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "mycli"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Plan</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> to add, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> to change, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> to destroy</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Changes to Outputs</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> aws_access_key_id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">   =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;old-access-key-id>"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> aws_caller_identity</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> account_id </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> arn        </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "arn:aws:iam::&#x3C;account-id>:user/mycli"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> id         </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;account-id>"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    -</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> user_id    </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;user-id>"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    } </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> aws_user_name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">       =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "mycli"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> -></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> null</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> encrypted_secret</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    =</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (sensitive value)</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_iam_access_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">example</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Destroying</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">...</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> [id=</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">old-access-key-id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">]</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">aws_iam_access_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">example</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Destruction complete after 0s</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Destroy complete</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">!</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> Resources</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 1</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> destroyed</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">.</span></span></code></pre>
</div></details>
</li>
<li>
<p><strong>Sync Key to Bitwarden Secrets Manager</strong>:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">./aws-key.sh</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> bws-sync</span></span></code></pre>
</div><div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">❯</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> ./aws-key.sh</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> bws-sync</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">INFO:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Exec</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Decrypt</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Key...</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Decrypted</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Outputs:</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">aws_user_name</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;redacted>"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">aws_access_key_id</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;redacted>"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">aws_decrypted_secret</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> =</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;redacted>"</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">INFO:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Exec</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Bitwarden</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Secrets</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Manager</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Sync...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">INFO:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Retrieving</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> secret</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> name</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> based</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> on</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> current</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> terraform</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> workspace...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">INFO:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Finding</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> secret</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> '&#x3C;terraform_workspace_name>'...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">INFO:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Editing</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> secret</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> '&#x3C;redacted>'...</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">INFO:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> New</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Secret</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Value:</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "BW_ITEM_NAME"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;redacted>",</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "AWS_ACCESS_KEY_ID"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;redacted>",</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "AWS_SECRET_ACCESS_KEY"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;redacted>",</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "AWS_MFA_ARN"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "arn:aws:iam::&#x3C;redacted>:mfa/&#x3C;redacted>",</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "AWS_DEFAULT_REGION"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;redacted>"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">Update</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> secret</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> '&#x3C;redacted>'</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> with</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> above</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> value?</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> [y/n] y</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "id"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;redacted>",</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "organizationId"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;redacted>",</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "projectId"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;redacted>",</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "key"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;redacted>",</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "value"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "{\n  </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">BW_ITEM_NAME</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">&#x3C;redacted></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">,\n  </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">AWS_ACCESS_KEY_ID</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">&#x3C;redacted></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">,\n  </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">AWS_SECRET_ACCESS_KEY</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">: </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">&#x3C;redacted></span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">\"</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">\n}",</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "note"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "",</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "creationDate"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;date>",</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    "revisionDate"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">:</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;date>"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">✔</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Success</span></span></code></pre>
</div><div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p></p>
<ul>
<li>The name of the secret is the same as the Terraform workspace name.</li>
<li>Since I use Bitwarden Secrets Manager to load my secrets as environment
variables across projects, I am automatically all set anywhere I need to
use these secrets. Checkout
<a href="https://tywer.dev/secrets-management-for-developers.html">Bitwarden Secrets Manager: Elevating Developer Environments</a>
for more details.</li>
</ul>
</div>
</li>
</ol>
<h2 id="function-for-rotating-aws-access-keys" tabindex="-1">Function for Rotating AWS Access Keys </h2>
<p>Now we can tie all this together in a convenient helper script that does all the
heavy lifting for us, making it easy to rotate our AWS Access Keys with a single
command. It performs the following steps:</p>
<ol>
<li>Navigates to the specified Terraform AWS Access Key directory.</li>
<li>Verifies the current AWS identity.</li>
<li>Prompts the user to select the appropriate Terraform workspace.</li>
<li>Ensures Keybase is running.</li>
<li>Rotates the AWS Access Key using a script.</li>
<li>Optionally syncs the new key with Bitwarden if enabled.</li>
</ol>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">TERRAFORM_AWS_ACCESS_KEY_DIR</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"&#x3C;path-to>/terraform-aws-access-key"</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">function</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> secret_rotate_aws_keys</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    local</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -r</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> enable_bws_sync</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">${1</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">:-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">true</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    local</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -r</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> log_prefix</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"[secret_rotate_aws_keys]"</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">    cd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$TERRAFORM_AWS_ACCESS_KEY_DIR</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> ||</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">        log</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> error</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "Failed to cd into </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$TERRAFORM_AWS_ACCESS_KEY_DIR</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    log</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> info</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$log_prefix</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Starting AWS Access Key Rotation"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    aws</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> sts</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> get-caller-identity</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --no-cli-pager</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> !</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> ask</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "Do you want to continue with the current aws identity?"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">; </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">then</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 1</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    fi</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    log</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> info</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$log_prefix</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Select the TF Workspace aligned with the AWS Access Key to rotate"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    local</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -r</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> workspace</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"$(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">terraform</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> workspace list </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">|</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> fzf</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --prompt</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> " Select the TF Workspace > " </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">|</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> sed</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> 's|* ||g;s|^[[:space:]]*||')"</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    terraform</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> workspace</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> select</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$workspace</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> ||</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">        log</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> error</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "Failed to select the TF Workspace: </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$workspace</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    log</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> info</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$log_prefix</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> tf workspace: </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$workspace</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    log</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> info</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "Ensuring keybase is running"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> !</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> keybase</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> whoami</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> 2></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">/dev/null</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">; </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">then</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">        log</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> info</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$log_prefix</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Keybase is not running, attempting to start it with: run_keybase -g"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">        run_keybase</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -g</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> &#x26;&#x26; </span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">keybase</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> whoami</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    fi</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    log</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> info</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$log_prefix</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Rotating AWS Access Key"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">    ./aws-key.sh</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> rotate</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> ||</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">        log</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> error</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "Failed to rotate AWS Access Key"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 1</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> [[ </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$enable_bws_sync</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> ==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "true"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> ]]; </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">then</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">        log</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> info</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$log_prefix</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> Syncing with Bitwarden: ./aws-key.sh bws-sync"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">        ./aws-key.sh</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> bws-sync</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    fi</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span></code></pre>
</div><h2 id="final-thoughts" tabindex="-1">Final Thoughts </h2>
<p>Automating the creation, deletion, and rotation of AWS IAM Access Keys is
essential for maintaining a secure and efficient cloud environment. By using
Terraform, Keybase, and Bitwarden Secrets Manager, we can ensure our credentials
are always up-to-date and securely stored. This solution provides a robust
method for managing AWS IAM Access Keys across multiple environments and
projects, making it easier to maintain a secure cloud infrastructure.</p>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[Mastering Self-Hosted File Sync and Backup with SyncThing and Duplicati]]></title>
            <link>https://tywer.dev/mastering-self-hosted-file-sync-and-backup-with-syncthing-and-duplicati</link>
            <guid isPermaLink="false">https://tywer.dev/mastering-self-hosted-file-sync-and-backup-with-syncthing-and-duplicati</guid>
            <pubDate>Wed, 07 Aug 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>Integrating SyncThing and Duplicati can offer an accessible self-hosted
Dropbox-like experience, allowing you to keep your files synchronized across
multiple devices while ensuring they are securely backed up offsite with
end-to-end encryption.</p>
<p>SyncThing will manage the synchronization of files between your devices, and
Duplicati will handle the encrypted backup to a cloud storage provider of your
choice. This approach combines the benefits of having files readily available
across devices with the reliability and security of an encrypted offsite backup,
protecting your data from loss and unauthorized access.</p>
<p><img src="https://tywer.dev/images/syncthing-duplicati-diagram.webp" alt=""></p>
<h2 id="syncthing" tabindex="-1">SyncThing </h2>
<p><a href="https://syncthing.net/" target="_blank" rel="noreferrer">SyncThing</a> keeps all my files synchronized across my
devices. It's decentralized, so it doesn't require a centralized server,
instead, my devices discover and connect directly to each other. This means my
files are never stored on a 3rd-party server and are only accessible to me and
the devices I've authorized. Their <a href="https://syncthing.net/security/" target="_blank" rel="noreferrer">security</a>
ensures all communication is encrypted and authenticated, and it's an
open-source
<a href="https://github.com/syncthing/syncthing/blob/main/LICENSE" target="_blank" rel="noreferrer">MPL-2.0 License</a>.</p>
<div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p>I'm a big fan of <a href="https://www.linuxserver.io/" target="_blank" rel="noreferrer">linuxserver.io</a>, so I use their
<a href="https://hub.docker.com/r/linuxserver/syncthing" target="_blank" rel="noreferrer">Docker image</a> to run
SyncThing on my server. Find out more information from their
<a href="https://docs.linuxserver.io/images/docker-syncthing/" target="_blank" rel="noreferrer">documentation</a> or
checkout their <a href="https://github.com/linuxserver/docker-syncthing" target="_blank" rel="noreferrer">GitHub</a>.</p>
</div>
<p>Create as many Folders as you need, and share them with your devices. You can
also set up <a href="https://docs.syncthing.net/users/versioning.html" target="_blank" rel="noreferrer">versioning</a> to
keep a history of changes. I found the following folders useful:</p>
<ul>
<li><strong>Drop</strong>: A folder where I can <em>drop</em> files I want to sync across all my
devices. I try to keep this lightweight and avoid large clunky files, just
stuff I might need at a moment's notice.</li>
<li><strong>Personal</strong>: My personal files, like documents, photos, and videos.</li>
<li><strong>Work</strong>: Work-related files that aren't necessarily sensitive or
confidential, but just stuff I may need access to from different devices, or
perhaps a running archive of interesting projects, demos, or presentations I
may want to keep.</li>
<li><strong>Backup</strong>: A folder where I can backup files from my devices. I include this
in my Duplicati backup job to the cloud to ensure there is an offsite backup
of my files. I have a directory in here for each of my devices and have
Duplicati jobs that will respectively sync their files into each directory.
Since it's in SyncThing, I can just locally copy files into the directory, and
I have the peace of mind, knowing they will be synced to my server and then
backed up to the cloud.</li>
</ul>
<p>Here is a generic example showing folders shared between devices:</p>
<p><img src="https://syncthing.net/img/screenshot-dark.png" alt=""></p>
<h2 id="duplicati" tabindex="-1">Duplicati </h2>
<p><a href="https://www.duplicati.com/" target="_blank" rel="noreferrer">Duplicati</a> is a free, open-source backup client
that securely stores encrypted, incremental, compressed backups on cloud storage
services and remote servers. It's a zero trust, fully encrypted backup solution
ensuring my data is simply safe. At the time of writing, it's also open-source,
see their
<a href="https://github.com/duplicati/duplicati/blob/master/LICENSE.txt" target="_blank" rel="noreferrer">LICENSE</a>.</p>
<div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p>I've used both
<a href="https://hub.docker.com/r/duplicati/duplicati" target="_blank" rel="noreferrer">Duplicati's Docker Image</a> and
<a href="https://hub.docker.com/r/linuxserver/duplicati" target="_blank" rel="noreferrer">Linuxserver's Docker Image</a>
to run Duplicati on my devices. You can also
<a href="https://duplicati.com/download" target="_blank" rel="noreferrer">download desktop versions</a> for Windows,
macOS, and Linux.</p>
</div>
<p>Duplicati works with a variety of storage providers, including
<a href="https://aws.amazon.com/s3/" target="_blank" rel="noreferrer">Amazon S3</a>,
<a href="https://www.google.com/drive/" target="_blank" rel="noreferrer">Google Drive</a>,
<a href="https://www.microsoft.com/en-us/microsoft-365/onedrive/online-cloud-storage" target="_blank" rel="noreferrer">Microsoft OneDrive</a>,
and <a href="https://www.backblaze.com/b2/cloud-storage.html" target="_blank" rel="noreferrer">Backblaze B2</a>, etc.
Duplicati has many <a href="https://duplicati.com/Integrations" target="_blank" rel="noreferrer">Integrations</a> to choose
from:</p>
<p><img src="https://tywer.dev/images/duplicati-integrations.webp" alt=""></p>
<p>I run Duplicati on each of my devices with a simple backup job that just locally
saves files to a directory that SyncThing keeps synchronized between all my
devices. This way I have at least an easily-accessible local backup of my files
on each device, and then my server will back them up to the cloud with it's own
Duplicati job.</p>
<p>Since I signed up early to <a href="https://www.box.com/" target="_blank" rel="noreferrer">Box</a> during some promotion, I
have a lot of free storage there, so I use that as my backup destination.
<a href="https://www.storj.io/" target="_blank" rel="noreferrer">StorJ</a> is super innovative and has very
<a href="https://www.storj.io/pricing" target="_blank" rel="noreferrer">competitive pricing</a>, so I also use them. They
are similar to Cloud Storage providers like
<a href="https://aws.amazon.com/s3/" target="_blank" rel="noreferrer">Amazon S3</a>, but they use a decentralized network of
nodes to store your data, which feels like the smarter way. So I have data
backed up to 2 different providers! I can easily restore from Box without having
to pay for egress, but I can also restore from StorJ in the event of a
disastrous scenario.</p>
<h2 id="what-can-the-storage-provider-see" tabindex="-1">What Can the Storage Provider See? </h2>
<p>Well, not much, they're encrypted you see. The storage provider can see the
encrypted files, but they can't see the contents of these files. This is because
Duplicati encrypts the files before sending them to their destination. They also
compress and chunk the data, so filenames and metadata are scrambled and they
are optimally stored in the cloud to reduce space and bandwidth.</p>
<p><img src="https://tywer.dev/images/duplicati-destination-example.webp" alt=""></p>
<p>If you're interested to learn more about how Duplicati encrypts your data, check
out
<a href="https://docs.duplicati.com/en/latest/appendix-a-how-the-backup-process-works/" target="_blank" rel="noreferrer">How the backup process works</a>.</p>
<h2 id="conclusion" tabindex="-1">Conclusion </h2>
<p>SyncThing and Duplicati are a powerful combination for managing your files
across devices and ensuring they are securely backed up offsite. By integrating
these two tools, you can create a self-hosted Dropbox-like experience that keeps
your files synchronized and protected from loss and unauthorized access. This
approach gives you full control over your data and peace of mind that it is safe
and accessible whenever you need it.</p>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[Organizing Dotfiles with Git Submodules]]></title>
            <link>https://tywer.dev/organizing-dotfiles-with-git-submodules</link>
            <guid isPermaLink="false">https://tywer.dev/organizing-dotfiles-with-git-submodules</guid>
            <pubDate>Fri, 02 Aug 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>Managing dotfiles on GitHub ensures a consistent development environment across
machines and simplifies setup and sharing. Here's how I organize my dotfiles on
GitHub using Git submodules for public and private configurations.</p>
<h2 id="what-are-dotfiles" tabindex="-1">What Are Dotfiles? </h2>
<p>We all have our favorite tools, configurations, aliases that make our
development environment comfortable and efficient. These configurations are
typically stored in dotfiles. They are typically hidden files in the user's home
directory and start with a dot (e.g., <code>.bashrc</code>, <code>zshrc</code>, <code>.vimrc</code>,
<code>.gitconfig</code>), but they can also be directories (e.g., <code>.vim</code>, <code>.config</code>), or
even common aliases (e.g., <code>bash_aliases</code>). Point is, they can be anything and
everything that you use to customize your shell, editor, or other tools that are
essential to your workflow.</p>
<p>For more info, check out
<a href="https://www.youtube.com/watch?v=r_MpUP6aKiQ" target="_blank" rel="noreferrer">Fireship's ~/.dotfiles in 100 Seconds</a>
and the <a href="https://dotfiles.github.io/" target="_blank" rel="noreferrer">unofficial guide to dotfiles on GitHub</a>.</p>
<p><a href="https://www.youtube.com/watch?v=r_MpUP6aKiQ" target="_blank" rel="noreferrer"><img src="https://img.youtube.com/vi/r_MpUP6aKiQ/0.jpg" alt="Fireship's ~/.dotfiles in 100 Seconds"></a></p>
<h2 id="why-organize-dotfiles-in-the-cloud" tabindex="-1">Why Organize Dotfiles in the Cloud? </h2>
<p>Managing dotfiles on version control platforms like GitHub is real nice for at
least a few reasons:</p>
<ul>
<li>
<p><strong>Consistency</strong>: By storing dotfiles in a central repository, you can maintain
a consistent development environment across multiple machines. This is
especially useful when switching between workstations or setting up a new
computer.</p>
</li>
<li>
<p><strong>Backup</strong>: GitHub provides a secure backup of your dotfiles, ensuring that
you don't lose your configurations in case of hardware failure or accidental
deletion.</p>
</li>
<li>
<p><strong>Sharing</strong>: You can easily share your dotfiles with others by providing them
with a link to your GitHub repository. This is particularly helpful for
collaborating on projects or learning from others' configurations. Just look
at all the <a href="https://dotfiles.github.io/inspiration/" target="_blank" rel="noreferrer">exemplary dotfiles</a> out
there!</p>
</li>
<li>
<p><strong>Easy Setup</strong>: With your dotfiles on GitHub, you can quickly set up your
development environment on a new machine by cloning the repository and
symlinking the dotfiles to your home directory. This is particularly useful
for setting up cloud workspaces or Codespaces.</p>
</li>
</ul>
<h2 id="my-dotfiles-strategy" tabindex="-1">My Dotfiles Strategy </h2>
<p>Here's how I organize <a href="https://github.com/tdharris/.dotfiles" target="_blank" rel="noreferrer">my .dotfiles</a>,
it's probably not that unique, but it works for me:</p>
<p><img src="https://tywer.dev/images/dotfiles-submodules.webp" alt=""></p>
<ul>
<li>
<p><strong>Public Repository</strong>: I store my public dotfiles in a repository named
<a href="https://github.com/tdharris/.dotfiles" target="_blank" rel="noreferrer">.dotfiles</a>. Mostly I have tons of
aliases and functions that I've accumulated over the years. It's helpful to
have them in a public place to share easily with others.</p>
</li>
<li>
<p><strong>Private Dotfiles Repositories as Git Submodules</strong>: I have additional
repositories for specific profile contexts like <code>.dotfiles-work</code> and
<code>.dotfiles-personal</code> for configurations that I want to keep private. I load
these private repositories as Git submodules in my public <code>.dotfiles</code>
repository. This way, I can keep my private configurations separate from the
public ones while still having them all in one place.</p>
</li>
<li>
<p><strong>Symlinks</strong>: Instead of copying the dotfiles to my home directory, I create
symlinks to the files in the <code>.dotfiles</code> repository. This allows me to keep
the files in a centralized location while still using them in my development
environment.</p>
</li>
<li>
<p><strong>Structure</strong>: I organize my dotfiles into the following directories:</p>
<ul>
<li>
<p><a href="https://github.com/tdharris/.dotfiles/tree/main/config" target="_blank" rel="noreferrer">config</a> directory
contains configurations for specific tools like <code>git</code>, <code>vim</code>, <code>zsh</code>, etc.
They are kept in sync with the actual files in my home directory using
symlinks managed by the <a href="https://www.gnu.org/software/stow/" target="_blank" rel="noreferrer">stow</a> tool.</p>
</li>
<li>
<p><a href="https://github.com/tdharris/.dotfiles/tree/main/bash" target="_blank" rel="noreferrer">bash</a> directory
containing all sorts of tool-specific aliases and functions, all with an
<code>_aliases</code> suffix. For example:</p>
</li>
</ul>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">asdf_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">  context_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">  file_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">  gruntwork_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">  kubectl_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">  prompts_aliases</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">aws_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">   env_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      gh_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">    iac_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">        log_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">      terraform_aliases</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">bw_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">    extract_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">  git_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">   k9s_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">        notify_aliases</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">   terragrunt_aliases</span></span></code></pre>
</div></li>
<li>
<p><strong>Bootstrap Script</strong>: I have a
<a href="https://github.com/tdharris/.dotfiles/blob/main/bootstrap.sh" target="_blank" rel="noreferrer">bootstrap.sh</a>
script that will load all the aliases and functions in the <code>bash</code> directories
from all my dotfiles repositories. If the submodule repositories have a <code>bash</code>
directory, it will load those as well. This script is sourced in my <code>.bashrc</code>
or <code>.zshrc</code> file.</p>
</li>
<li>
<p><strong>Install Script</strong>: I have an
<a href="https://github.com/tdharris/.dotfiles/blob/main/install.sh" target="_blank" rel="noreferrer">install.sh</a>
script that simply appends the necessary lines to my <code>.bashrc</code> or <code>.zshrc</code> to
load the <code>bootstrap.sh</code> script.</p>
</li>
</ul>
<h2 id="using-gnu-stow-for-managing-symlinks" tabindex="-1">Using GNU Stow for Managing Symlinks </h2>
<p>GNU Stow is a symlink farm manager that can help you manage your dotfiles
easily. It allows you to keep your dotfiles organized in a central repository
and create symlinks to them in your home directory. This simplifies the process
of setting up your development environment on new machines and ensures that your
configurations are consistent across different environments. There are many
great tutorials of using Stow for managing dotfiles. As just an example, see
<a href="https://github.com/tdharris/.dotfiles/tree/main/config" target="_blank" rel="noreferrer">tdharris/.dotfiles/config</a>.
For more info, checkout
<a href="https://www.youtube.com/watch?v=WpQ5YiM7rD4&amp;t=180s" target="_blank" rel="noreferrer">Omer's ~/.dotfiles 101: A Zero to Configuration Hero Blueprint</a>:</p>
<p><a href="https://www.youtube.com/watch?v=WpQ5YiM7rD4&amp;t=180s" target="_blank" rel="noreferrer"><img src="https://img.youtube.com/vi/WpQ5YiM7rD4/0.jpg" alt="Omer's ~/.dotfiles 101: A Zero to Configuration Hero Blueprint"></a>.</p>
<h2 id="starting-your-dotfiles-journey" tabindex="-1">Starting Your Dotfiles Journey </h2>
<ol>
<li>
<p><strong>Create a Dotfiles Repository</strong>: Create a repository to store your dotfiles.
You can name it <code>.dotfiles</code> or something similar.</p>
<ul>
<li>Add your dotfiles to the repository. You can organize them however you
like, by tool or function (e.g., <code>config/bash</code>, <code>config/vim</code>,
<code>config/git</code>), etc.</li>
<li>Create Symlinks using Stow: Instead of copying the dotfiles to your home
directory, create symlinks to the files in your dotfiles repository. You
can use the <a href="https://www.gnu.org/software/stow/" target="_blank" rel="noreferrer">stow</a> tool to manage
symlinks for you.</li>
</ul>
</li>
<li>
<p><strong>Create Submodules for any Private Repositories</strong>: If you have private
configurations, create separate repositories for them like above and then add
them as submodules to your main dotfiles repository. You can do this by
running the following command:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> submodule</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> add</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">repository-ur</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">l</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">submodule-pat</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">h</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span></code></pre>
</div><p>For example:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> submodule</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> add</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> https://github.com/</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">usernam</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">e</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">/.dotfiles-work.git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> work</span></span></code></pre>
</div></li>
<li>
<p><strong>How to update submodules</strong>: When making changes to your submodules, you'll
need to commit and push the changes in the submodule repository and then
commit the changes in the main repository to update the submodule reference.</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">cd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> work</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> add</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> .</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> commit</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -m</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "Update work submodule"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> push</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">cd</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> ..</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> add</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> work</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> commit</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -m</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "Update work submodule reference"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> push</span></span></code></pre>
</div><p>Alternatively, if you want to update all submodules at once, you can use the
following command:</p>
<div class="language-shell vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">shell</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">git</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> submodule</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> update</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --recursive</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --remote</span></span></code></pre>
</div><p>Then commit and push the changes in the main dotfiles repository.</p>
</li>
</ol>
<h2 id="conclusion" tabindex="-1">Conclusion </h2>
<p>Organizing your dotfiles on GitHub is a great way to maintain a consistent
development environment, back up your configurations, share your settings with
others, and simplify setup on new machines. By following a few simple
strategies, you can keep your dotfiles organized and accessible across multiple
machines. If you're interested in seeing how I organize my dotfiles, check out
<a href="https://github.com/tdharris/.dotfiles" target="_blank" rel="noreferrer">my .dotfiles</a>.</p>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[Self-Hosted E2EE Pastebin - Paaster and Cloudflare to the Rescue!]]></title>
            <link>https://tywer.dev/self-hosted-e2ee-pastebin-paaster-and-cloudflare-to-the-rescue</link>
            <guid isPermaLink="false">https://tywer.dev/self-hosted-e2ee-pastebin-paaster-and-cloudflare-to-the-rescue</guid>
            <pubDate>Fri, 12 Jul 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>Exploring how to self-host an end-to-end encrypted pastebin using
<a href="https://github.com/WardPearce/paaster" target="_blank" rel="noreferrer">Paaster</a> and
<a href="https://developers.cloudflare.com/r2/" target="_blank" rel="noreferrer">Cloudflare R2</a> storage. I'd like to
easily share sensitive information like code snippets or logs with others
without the need to trust a third-party service with capabilities like access
code protection, expiration, view limits, etc.</p>
<h2 id="paaster" tabindex="-1">Paaster </h2>
<p><a href="https://github.com/WardPearce/paaster" target="_blank" rel="noreferrer">Paaster</a> is a secure and user-friendly
pastebin application that allows you to store and share text snippets. It
features end-to-end encryption so that only people you share the link with can
view the paste. It also supports access code protection, expiration, rate
limiting, share via QR code, and more. There is support for multiple storage
backends, including local file storage, <a href="https://aws.amazon.com/s3/" target="_blank" rel="noreferrer">AWS S3</a>,
<a href="https://developers.cloudflare.com/r2/" target="_blank" rel="noreferrer">Cloudflare R2</a>,
<a href="https://cloud.google.com/storage" target="_blank" rel="noreferrer">Google Cloud Storage</a>,
<a href="https://github.com/minio/minio" target="_blank" rel="noreferrer">MinIO</a>, <a href="https://www.storj.io/" target="_blank" rel="noreferrer">Storj</a>, and
more. Easily deployable with Docker and even support for
<a href="https://vercel.com/" target="_blank" rel="noreferrer">Vercel</a>.</p>
<p><video src="https://tywer.dev/images/paaster.webm" autoplay loop muted playsinline></video></p>
<h2 id="cloudflare-r2" tabindex="-1">Cloudflare R2 </h2>
<p><a href="https://developers.cloudflare.com/r2/" target="_blank" rel="noreferrer">Cloudflare R2</a> is a serverless edge
storage platform that provides a simple, secure, and scalable way to store and
serve data, similar to AWS S3 and other providers. Though this isn't quite
&quot;Self-Hosted&quot;, I'm pretty happy with it since the data is encrypted prior to
being stored in the bucket, and only I have access to the encryption keys.</p>
<h2 id="guide" tabindex="-1">Guide </h2>
<p>I primarily followed the
<a href="https://github.com/WardPearce/paaster?tab=readme-ov-file#setup" target="_blank" rel="noreferrer">Paaster Setup Instructions</a>
and started from the
<a href="https://github.com/WardPearce/paaster/blob/main/docker-public-s3/docker-compose.yml" target="_blank" rel="noreferrer">docker-public-s3/docker-compose.yml</a>
example. Paaster's frontend can be served with <a href="https://vercel.com/" target="_blank" rel="noreferrer">Vercel</a>,
but I opted to self-host both the frontend and backend, but with Cloudflare R2
as the storage backend.</p>
<ol>
<li>
<p><strong>DNS Configuration</strong>.</p>
<p>Choose a subdomain for your Paaster instance, e.g., <code>paaster.example.com</code>.
Update the <code>CNAME</code> records to point to where you will host the frontend /
backend. For example:</p>
<ul>
<li><code>paaster.example.com</code> - frontend</li>
<li><code>api-paaster.example.com</code> - backend</li>
</ul>
</li>
<li>
<p><strong>Cloudflare R2 Configuration</strong>.</p>
<ul>
<li>Create a new R2 bucket in the Cloudflare dashboard. <code>paaster</code></li>
<li>Enable
<a href="https://developers.cloudflare.com/r2/buckets/public-buckets/#custom-domains" target="_blank" rel="noreferrer">Custom Domains</a>
for your bucket. Pick something like <code>r2.paaster.example.com</code>. This will
need to be different from your frontend domain.</li>
<li>Configure
<a href="https://developers.cloudflare.com/r2/buckets/cors/" target="_blank" rel="noreferrer">Cross-Origin Resource Sharing (CORS)</a>
for your bucket. This is required for the frontend to interact with the R2
bucket.<br/> Allowed Origins: <code>https://paaster.example.com</code><br/> Allowed
Methods: <code>GET</code></li>
<li>Retrieve the following from the R2 bucket settings, for example:
<ul>
<li>Location: <code>Western North America (WNAM)</code></li>
<li>S3 API URL. This will be used in the backend configuration.
<code>https://***.r2.cloudflarestorage.com/paaster</code></li>
</ul>
</li>
<li>Create a new Access Key and Secret Key for the R2 bucket, see
<a href="https://developers.cloudflare.com/r2/api/s3/tokens/" target="_blank" rel="noreferrer">R2 Authentication</a>.
These will be used in the backend configuration. <code>paaster</code>
<ul>
<li>Token Name: <code>paaster</code></li>
<li>Permissions: <code>Object Read &amp; Write</code></li>
<li>Apply to specific buckets only: <code>paaster</code></li>
<li>Note the Access Key and Secret Key.</li>
</ul>
</li>
</ul>
</li>
<li>
<p><strong>Backend &amp; Frontend Configuration</strong> - Self-Hosted Docker-Compose.</p>
<ul>
<li>
<p>Download the example
<a href="https://raw.githubusercontent.com/WardPearce/paaster/main/docker-public-s3/docker-compose.yml" target="_blank" rel="noreferrer">docker-public-s3/docker-compose.yml</a>
file.</p>
</li>
<li>
<p>Update the backend:</p>
<div class="language-yml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">paaster_backend</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">    ...</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">        ...</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">        paaster_s3</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">            '{</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">                "endpoint_url": "&#x3C;R2_S3_API_URL>", # https://***.r2.cloudflarestorage.com/paaster</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">                "secret_access_key": "&#x3C;R2_SECRET_ACCESS_KEY>",</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">                "access_key_id": "&#x3C;R2_ACCESS_KEY_ID>",</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">                "region_name": "WNAM",</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">                "bucket": "paaster",</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">                "folder": "pastes",</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">                "download_url": "https://r2.paaster.example.com"</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">            }'</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">        paaster_proxy_urls</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">            '{</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">                "frontend": "https://paaster.example.com",</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">                "backend": "http://api-paaster.example.com"</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">            }'</span></span></code></pre>
</div></li>
<li>
<p>Update the frontend:</p>
<div class="language-yml vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">yml</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">paaster_frontend</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">    ...</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">    environment</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">        ...</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">        VITE_NAME</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"paaster.example.com"</span></span>
<span class="line"><span style="--shiki-light:#22863A;--shiki-dark:#85E89D">        VITE_API_URL</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"http://api-paaster.example.com"</span></span></code></pre>
</div></li>
<li>
<p>Start the backend with <code>docker-compose up -d</code>.</p>
</li>
<li>
<p>Verify logs are healthy with <code>docker-compose logs -f</code></p>
</li>
</ul>
</li>
<li>
<p><strong>Reverse Proxy Configuration</strong>.</p>
<p>Proxy exposed ports to the frontend and backend services using whatever
reverse proxy you prefer, like Nginx, Traefik, Caddy, etc. For example, with
<code>nginx</code>:</p>
<div class="language-nginx vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">nginx</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Frontend</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">server</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    listen </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">443</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> ssl http2;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    server_name </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">paaster.*;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    client_max_body_size </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    location</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> / </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        include </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">/config/nginx/proxy.conf;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        include </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">/config/nginx/resolver.conf;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_app &#x3C;paaster_frontend_ip>;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_port </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">8889</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_proto http;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        proxy_pass </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_proto://$upstream_app:$upstream_port;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">        # Security Headers</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        add_header </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Strict-Transport-Security </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"max-age=31536000"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> always;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        add_header </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">X-XSS-Protection </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"1; mode=block"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> always;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        add_header </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">X-Frame-Options </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"DENY"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> always;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        add_header </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">Feature-Policy </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"microphone 'none'; camera 'none'; geolocation 'none'; payment 'none'"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> always;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">        # Remove the proxy_hide_header directive for X-Frame-Options if setting it explicitly</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        proxy_hide_header </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">X-Frame-Options;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Backend</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">server</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    listen </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">443</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> ssl http2;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    server_name </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">api-paaster.*;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    client_max_body_size </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">;</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    location</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> / </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        include </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">/config/nginx/proxy.conf;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        include </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">/config/nginx/resolver.conf;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_app &#x3C;paaster_backend_ip>;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_port </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">8888</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        set </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_proto http;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        proxy_pass </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$upstream_proto://$upstream_app:$upstream_port;</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        proxy_hide_header </span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">X-Frame-Options;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">    }</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span></code></pre>
</div></li>
<li>
<p><strong>Try it Out!</strong>.</p>
<ul>
<li>Visit your new <code>https://paaster.example.com</code> and create a new paste.</li>
<li>Share the paste with others securely!</li>
</ul>
</li>
</ol>
<h2 id="final-thoughts" tabindex="-1">Final Thoughts </h2>
<p>Paaster is a fantastic self-hosted pastebin solution that provides end-to-end
encrypted pastes that I can share with others securely. The setup was
straightforward and I was able to get everything up and running. I'm excited to
start using Paaster to share sensitive information with others securely!</p>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
        <item>
            <title><![CDATA[Bitwarden Secrets Manager: Elevating Developer Environments]]></title>
            <link>https://tywer.dev/secrets-management-for-developers</link>
            <guid isPermaLink="false">https://tywer.dev/secrets-management-for-developers</guid>
            <pubDate>Sun, 07 Jul 2024 00:00:00 GMT</pubDate>
            <content:encoded><![CDATA[<p>Exploring Bitwarden Secrets Manager (BWS) for developers: setup, workflow
integration, and managing secrets across projects. The objective is to create an
alias that automatically retrieves and sets project-specific secrets as
environment variables when switching projects.</p>
<p><img src="https://tywer.dev/images/bws.webp" alt=""></p>
<h2 id="practical-usage" tabindex="-1">Practical Usage </h2>
<p>I've streamlined the process of fetching secrets from Bitwarden Secrets Manager
and setting as environment variables in my shell:</p>
<ul>
<li>
<p>Github Personal Access Token for my personal account:</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">❯</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> env-gh</span></span></code></pre>
</div><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">❯</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> printenv</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> |</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> grep</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> GITHUB_OAUTH_TOKEN</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">GITHUB_OAUTH_TOKEN</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">sensitive</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span></code></pre>
</div></li>
<li>
<p>Github Enterprise Personal Access Token for my work account:</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">❯</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> env-ghe</span></span></code></pre>
</div><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">❯</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> printenv</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> |</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> grep</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> GH_ENTERPRISE_TOKEN</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">GH_ENTERPRISE_TOKEN</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">sensitive</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span></code></pre>
</div></li>
<li>
<p>AWS IAM Credentials for my personal account:</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">❯</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> env-aws-personal</span></span></code></pre>
</div><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">❯</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> printenv</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> |</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> grep</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS_</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">AWS_REGION</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">us-west-2</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">AWS_ACCESS_KEY_ID</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">sensitive</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">AWS_DEFAULT_REGION</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">us-west-2</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">AWS_SECRET_ACCESS_KEY</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">sensitive</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span></code></pre>
</div></li>
<li>
<p>AWS IAM Credentials for my work account:</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">❯</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> env-aws-wrk-dev</span></span></code></pre>
</div><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">❯</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> printenv</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> |</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> grep</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS_</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">AWS_REGION</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">us-east-2</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">AWS_ACCESS_KEY_ID</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">sensitive</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">AWS_DEFAULT_REGION</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">us-east-2</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">AWS_SECRET_ACCESS_KEY</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">sensitive</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span></code></pre>
</div></li>
</ul>
<div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p>See the <a href="#bonus-direnv-integration">Direnv Integration</a> for automatically
loading secrets from Bitwarden Secrets Manager when you <code>cd</code> into a project
directory.</p>
</div>
<h2 id="why-secrets-management" tabindex="-1">Why Secrets Management? </h2>
<p>I need to manage multiple secrets across different projects, environments, and
accounts. Secrets Management tools like Bitwarden Secrets Manager or more
popularly, Hashicorp Vault, can help streamline this. Here are some reasons why
I use Secrets Management:</p>
<ul>
<li><strong>Centralized Management</strong>: Now that my environments pull from one place, I
can easily update secrets in one place and have them propagate to all my
environments, making it easy to update, rotate, and revoke secrets.</li>
<li><strong>Security</strong>: Storing secrets in plaintext in configuration files or scripts
is a pretty bad idea. This approach is more secure and reduces the risk of
secrets being exposed.</li>
<li><strong>Access Control</strong>: Provides access control to restrict who can access.</li>
<li><strong>Auditability</strong>: Provides audit logs to track who accessed or modified
secrets.</li>
<li><strong>CI/CD</strong>: Can integrate with CI/CD pipelines to provide secrets to builds and
applications securely.</li>
</ul>
<h2 id="getting-started-with-bitwarden-secrets-manager" tabindex="-1">Getting Started with Bitwarden Secrets Manager </h2>
<p>I primarily followed the
<a href="https://bitwarden.com/help/secrets-manager-quick-start/" target="_blank" rel="noreferrer">Bitwarden Secrets Manager Quick Start</a>
to enable Bitwarden Secrets Manager, create projects, create a machine account,
and create secrets:</p>
<p><img src="https://tywer.dev/images/bws-overview.webp" alt=""></p>
<ul>
<li>
<p><a href="https://bitwarden.com/help/secrets-manager-quick-start/#activate-secrets-manager" target="_blank" rel="noreferrer">Activated Bitwarden Secrets Manager</a>
for my Account.</p>
</li>
<li>
<p>Added 2
<a href="https://bitwarden.com/help/secrets-manager-quick-start/#add-a-project" target="_blank" rel="noreferrer">Projects</a>
to organize my secrets: <code>personal</code> and <code>work</code> contexts.</p>
</li>
<li>
<p>Added
<a href="https://bitwarden.com/help/secrets-manager-quick-start/#add-secrets" target="_blank" rel="noreferrer">Secrets</a>
to the <code>personal</code> and <code>work</code> projects with the following Names and Values:</p>
<div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p>The Secret Name follows a naming pattern I explain in the below Tip. The
Secret Value will be a flat <code>json</code> object with the key-value pairs for the
environment variables I want to set.</p>
</div>
<ul>
<li>
<p><code>gh-pat-personal-desktop</code> :</p>
<div class="language-json vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "GITHUB_OAUTH_TOKEN"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"&#x3C;value>"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span></code></pre>
</div></li>
<li>
<p><code>wrk-ghe-pat-desktop</code> :</p>
<div class="language-json vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "GH_ENTERPRISE_TOKEN"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"&#x3C;value>"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span></code></pre>
</div></li>
<li>
<p><code>aws-iam-personal-me</code>, <code>wrk-aws-iam-prod-me</code> :</p>
<div class="language-json vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">json</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">{</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "AWS_ACCESS_KEY_ID"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"&#x3C;value>"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "AWS_SECRET_ACCESS_KEY"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"&#x3C;value>"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">,</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">  "AWS_DEFAULT_REGION"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">: </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"&#x3C;value>"</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span></code></pre>
</div><p><strong>TIP</strong>: I use the following naming convention for secrets:</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">company</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">?></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">-</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">platform</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">-</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">account-type</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">-</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">account</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">-</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">name</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Examples:</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># gh-pat-personal-desktop</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># wrk-ghe-pat-desktop</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># wrk-aws-iam-prod-me</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># wrk-aws-iam-dev-me</span></span></code></pre>
</div><ul>
<li>An optional company context prefix (<code>wrk</code> or <code>&lt;client&gt;</code>)</li>
<li>Platform (<code>aws</code>, <code>gh</code>, etc.)</li>
<li>Account Type (<code>iam</code> or <code>root</code> for AWS, <code>pat</code> for a Github Personal Access
Token, etc.)</li>
<li>Environment (<code>dev</code>, <code>stage</code>, <code>prod</code>)</li>
<li>User Identity or token name (<code>me</code>, <code>desktop</code> or <code>service-account</code>).</li>
</ul>
</li>
</ul>
</li>
<li>
<p>Added a
<a href="https://bitwarden.com/help/secrets-manager-quick-start/#add-a-machine-account" target="_blank" rel="noreferrer">Machine account</a>
for myself called <code>personal</code>, which has <code>Can read</code> permissions to both
projects. This account will be used to authenticate with Bitwarden Secrets
Manager from my development environment, so I created an access token called
<code>desktop</code> as well.</p>
</li>
</ul>
<h2 id="environment-setup" tabindex="-1">Environment Setup </h2>
<h3 id="bitwarden-secrets-manager-cli" tabindex="-1">Bitwarden Secrets Manager CLI </h3>
<ol>
<li>
<p>Install the
<a href="https://bitwarden.com/help/secrets-manager-cli/" target="_blank" rel="noreferrer">Bitwarden Secrets Manager CLI</a> -
see <a href="https://github.com/bitwarden/sdk/releases" target="_blank" rel="noreferrer">Releases</a>. Since I use
<a href="https://asdf-vm.com/" target="_blank" rel="noreferrer">asdf</a>, I installed with the following:</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">asdf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> plugin</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> add</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> bitwarden-secrets-manager</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">asdf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> install</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> bitwarden-secrets-manager</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> latest</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">asdf</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> global</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> bitwarden-secrets-manager</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> latest</span></span></code></pre>
</div><ul>
<li><a href="https://github.com/asdf-community/asdf-bitwarden-secrets-manager" target="_blank" rel="noreferrer">asdf-community/asdf-bitwarden-secrets-manager</a></li>
</ul>
</li>
<li>
<p>Authenticate with the Bitwarden Secrets Manager using the <code>desktop</code> machine
account access token. Add the following to your shell profile (e.g.,
<code>.bashrc</code>, <code>.zshrc</code>, etc.):</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">export</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> BWS_ACCESS_TOKEN</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=&#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">machine_account_access_token</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span></code></pre>
</div></li>
<li>
<p>Verify the Bitwarden Secrets Manager CLI is working by running:</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">bws</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> project</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> list</span></span></code></pre>
</div></li>
</ol>
<h3 id="shell-integration" tabindex="-1">Shell Integration </h3>
<p>I added the following <code>aliases</code> and a couple key <code>bash</code> functions to my dotfiles
to make it easier to retrieve secrets and set them as environment variables:</p>
<ul>
<li><a href="https://github.com/tdharris/.dotfiles/blob/c2a5f0d00b4f6cd46fb8e42a63e1e093813f2cbc/bash/bw_aliases#L14-L22" target="_blank" rel="noreferrer">tdharris/.dotfiles/bash/bw_aliases</a>:</li>
</ul>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Add to your .bashrc, .zshrc, .dotfiles, etc.</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Bitwarden Secrets Manager</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Retrieve a secret from Bitwarden Secrets Manager, parse the value as JSON,</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># and export the key-value pairs as environment variables.</span></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Usage: bws_env &#x3C;secret_uuid></span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">function</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> bws_env</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    local</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -r</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> id</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">$1</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    local</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -r</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> value</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"$(</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">bws</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> secret get "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$id</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">" </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">|</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> jq</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -r</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> '.value')"</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">    # Ensure the value is a JSON object with at least one key</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> [[ </span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"$(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$value</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">" </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">|</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> jq</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -r</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> 'type')"</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> !=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "object"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> ]] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">||</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> [[ </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-z</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "$(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$value</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">" </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">|</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> jq</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -r</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> 'keys | length')"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> ]]; </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">then</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">        echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "Error: Value is not a JSON object or is empty"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 1</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    fi</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D">    # Export each key as an environment variable</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    while</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> IFS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> read</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -r</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> key</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">; </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">do</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        local</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> value_key</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"$(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$value</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">" </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">|</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> jq</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -r</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> --arg</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> key "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$key</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">" '.[$key]')"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">        export</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$key</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$value_key</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">    done</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> &#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> &#x3C;(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$value</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">" </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">|</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> jq</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> -r</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> 'keys[]')</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># AWS</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">function</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> env-aws-clear</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">	unset</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS_SECRET_KEY</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS_MFA_ARN</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS_SECRET_ACCESS_KEY</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> \</span></span>
<span class="line"><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">        AWS_ACCESS_KEY_ID</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> AWS_SESSION_TOKEN</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">;</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">}</span></span></code></pre>
</div><div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Add to your .bashrc, .zshrc, .dotfiles, etc.</span></span>
<span class="line"></span>
<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D"># Bitwarden Secrets Manager Aliases</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">alias</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> env-gh</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"bws_env &#x3C;secret_uuid>"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">alias</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> env-ghe</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"bws_env &#x3C;secret_uuid>"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">alias</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> env-aws-personal</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"env-aws-clear; bws_env &#x3C;secret_uuid>"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">alias</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> env-aws-wrk-dev</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"env-aws-clear; bws_env &#x3C;secret_uuid>"</span></span>
<span class="line"><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">alias</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> env-aws-clientA</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"env-aws-clear; bws_env &#x3C;secret_uuid>"</span></span></code></pre>
</div><div class="note custom-block github-alert"><p class="custom-block-title">NOTE</p>
<p>Replace <code>&lt;secret_uuid&gt;</code> with the UUID of the secret you want to retrieve from
Bitwarden Secrets Manager.</p>
</div>
<p>Verify the aliases are working by running:</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">❯</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> env-gh</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">❯</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> printenv</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> |</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> grep</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> GITHUB_OAUTH_TOKEN</span></span>
<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">GITHUB_OAUTH_TOKEN</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=&#x3C;</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">sensitive</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span></span></code></pre>
</div><h3 id="bonus-direnv-integration" tabindex="-1">Bonus: Direnv Integration </h3>
<p>I use <a href="https://direnv.net/" target="_blank" rel="noreferrer">direnv</a> to automatically load environment variables
from <code>.envrc</code> files in my project directories. I added the following to my
<code>.envrc</code> files to load secrets from Bitwarden Secrets Manager when I <code>cd</code> into a
project directory:</p>
<div class="language-bash vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">bash</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0" v-pre=""><code><span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "Loading Bitwarden Secrets Manager Environment Variables..."</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">;</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">source</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">$HOME</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">/.dotfiles/bash/bw_aliases"</span></span>
<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0">bws_env</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "&#x3C;secret_uuid>"</span></span>
<span class="line"><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">echo</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> "✔ Success"</span></span></code></pre>
</div><h2 id="related-links" tabindex="-1">Related Links </h2>
<ul>
<li><a href="https://bitwarden.com/help/secrets-manager-overview/" target="_blank" rel="noreferrer">Bitwarden Secrets Manager Overview</a></li>
<li><a href="https://asdf-vm.com/" target="_blank" rel="noreferrer">asdf</a></li>
<li><a href="https://github.com/tdharris/.dotfiles/tree/main" target="_blank" rel="noreferrer">tdharris/.dotfiles</a></li>
</ul>
]]></content:encoded>
            <author>Tyler Harris</author>
        </item>
    </channel>
</rss>