<?xml version="1.0" encoding="UTF-8"?><rss 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" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ely on Medium]]></title>
        <description><![CDATA[Stories by Ely on Medium]]></description>
        <link>https://medium.com/@edeckers?source=rss-635a48996a6b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hrvWM7EVViOgCpntGWFiQw.jpeg</url>
            <title>Stories by Ely on Medium</title>
            <link>https://medium.com/@edeckers?source=rss-635a48996a6b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 07:18:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@edeckers/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building an MCP server: teaching AI assistants about backups]]></title>
            <link>https://edeckers.medium.com/building-my-first-mcp-server-teaching-ai-assistants-about-backups-26a24ecf103e?source=rss-635a48996a6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/26a24ecf103e</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[mcp-server]]></category>
            <dc:creator><![CDATA[Ely]]></dc:creator>
            <pubDate>Sun, 15 Feb 2026 17:22:17 GMT</pubDate>
            <atom:updated>2026-02-15T23:39:20.827Z</atom:updated>
            <content:encoded><![CDATA[<h4>My journey into the Model Context Protocol</h4><p><strong>Today I built a Model Context Protocol (MCP) server to connect AI assistants with </strong><a href="https://github.com/bareos/bareos"><strong>Bareos backup infrastructure</strong></a><strong>. Join me as I walk through building this integration and share what I learned along the way.</strong></p><p><strong>Or if you just want to see the result, check it out at </strong><a href="https://github.com/edeckers/bareos-mcp-server"><strong>https://github.com/edeckers/bareos-mcp-server</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*MQ7wtGXTcnMW0MjE" /><figcaption>Photo by <a href="https://unsplash.com/@venczakjanos?utm_source=medium&amp;utm_medium=referral">János Venczák</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What is MCP?</h3><p>The <a href="https://en.wikipedia.org/wiki/Model_Context_Protocol">Model Context Protocol</a> is Anthropic’s solution for giving AI assistants like Claude access to external tools and data. It’s a JSON-RPC based protocol that runs over stdin/stdout.</p><p>The concept is straightforward: instead of manually running bconsole commands, copying output, and pasting it into a chat, you ask “show me the last 10 backup jobs” and the AI fetches it directly from your Bareos Director through the MCP server.</p><h3>Why Bareos?</h3><p>I’ve been managing my backups with Bareos for a while now. And while bconsole is powerful, it requires remembering specific command syntax for listing jobs, checking storage pools, or viewing client status.</p><p>Being able to query backup infrastructure conversationally, like “why did last night’s backup fail?” or “how much storage is left in the Full pool?” seemed like a practical use case for MCP.</p><h3>The journey</h3><h4>Understanding the Protocol</h4><p>MCP is a JSON-RPC protocol with three main operations:</p><ul><li>Initialize: Server announces capabilities</li><li>List tools: Server describes available tools</li><li>Call tool: Client executes a tool with arguments</li></ul><p>And that’s pretty much it. The rest is tool implementation and error handling.</p><h4>Read-Only by design for now</h4><p>I deliberately kept everything read-only initially, so no starting jobs, deleting volumes, or pruning backups. Just queries.</p><p>This was a practical decision: I wanted to understand the protocol and tool design without worrying about accidentally breaking production backups. Mutable actions are planned for later versions.</p><h4>Emergent behavior</h4><p>The interesting part came when I realized Claude could answer questions I hadn’t explicitly coded for, and which would require multiple bconsole queries. Ask it “Which clients haven’t backed up in the last 24 hours?” and it will:</p><ol><li>Call list_jobs to get recent jobs</li><li>Call list_clients to get all clients</li><li>Compare the two</li><li>Provide an answer</li></ol><p>I built primitive tools; the AI combines them to answer complex queries. That’s the real value of MCP: you’re building composable primitives, not a comprehensive API.</p><h3>What I learned</h3><h4>Tool design matters</h4><p>The quality of tool descriptions directly impacts how well the AI uses them. Vague descriptions lead to mistakes. Clear, specific descriptions with parameter explanations work reliably.</p><p>For example:</p><ul><li>Don’t do this: “List jobs”</li><li>Do this: “List recent backup jobs. Use the limit parameter to control how many jobs are returned (default: 50)”</li></ul><h4>Testing without an AI assistant</h4><p>You can test MCP servers with just echo and pipes:</p><pre>echo &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:1,&quot;method&quot;:&quot;tools/list&quot;,&quot;params&quot;:{}}&#39; | \<br>./bareos-mcp-server</pre><p>No need to configure Claude Desktop or spin up a full client. Just send JSON-RPC over stdin. It is actually how Claude will interact with the server, and it is very useful for debugging.</p><h4>Build for composition</h4><p>Don’t try to predict every query users might want. Build small, focused tools that can be combined. The AI is surprisingly good at figuring out how to compose them.</p><h3>Recommendations for building MCP servers</h3><ul><li>Start with a tool you already use. Pick something you interact with regularly, you’ll understand the use cases and catch issues faster.</li><li>Begin with one tool. Get one tool working end-to-end before adding more. I started with list_jobs and expanded from there.</li><li>Write clear descriptions. Tool descriptions are the AI’s only guide. Be specific about parameters, formats, and return values.</li><li>Test with raw JSON-RPC first. Verify your tools work with manual calls before involving an AI assistant. Faster iteration, clearer debugging.</li><li>Start read-only if safety matters. Read-only operations let you learn the protocol without risking production systems. Add mutations once you’re confident.</li></ul><h3>Try it yourself</h3><p>The code is open source at <a href="https://github.com/edeckers/bareos-mcp-server">https://github.com/edeckers/bareos-mcp-server</a> with installation instructions for both Claude Code and Claude Desktop.</p><h3>Useful resources</h3><p>Building your own MCP server? These resources helped me:</p><ul><li><a href="https://modelcontextprotocol.io/">https://modelcontextprotocol.io/</a></li><li><a href="https://docs.anthropic.com/claude/docs">https://docs.anthropic.com/claude/docs</a></li><li><a href="https://github.com/modelcontextprotocol/typescript-sdk">https://github.com/modelcontextprotocol/typescript-sdk</a></li><li><a href="https://github.com/modelcontextprotocol/servers">https://github.com/modelcontextprotocol/servers</a></li></ul><p><strong>Built something with MCP or considering it? Let me know in the comments!</strong></p><p>If the Dutch language doesn’t scare you, and you’d like to know more about what keeps me busy aside from my pet projects, check my company website <a href="https://branie.it/">https://branie.it</a>! Maybe we can work together on something someday :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26a24ecf103e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Flipr: a URL shortener, one commit at a time]]></title>
            <link>https://edeckers.medium.com/building-flipr-a-url-shortener-one-commit-at-a-time-6b972c5fe9d6?source=rss-635a48996a6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b972c5fe9d6</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ely]]></dc:creator>
            <pubDate>Sun, 09 Nov 2025 20:22:04 GMT</pubDate>
            <atom:updated>2025-11-11T14:18:48.740Z</atom:updated>
            <content:encoded><![CDATA[<h4>Part 1: the simplest thing that could possibly work</h4><p>Welcome to the first post in a series that dives into the world of distributed systems building on Kubernetes, using as a subject <strong>the “Todo application” of systems design</strong>: a URL shortener we’ll call <strong>Flipr </strong>🐬.</p><p>The goal is to build an actual, functioning, deployable system, designed to scale from a single instance to a distributed cluster on Kubernetes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1peNiIz2rMzalSs6" /><figcaption>Photo by <a href="https://unsplash.com/@louangm?utm_source=medium&amp;utm_medium=referral">Louan García</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>What this series is and what it is not</h3><p>This series focuses on building a distributed, scalable URL shortener and the architectural decisions behind it. To keep that focus sharp, I’m intentionally omitting several things that would be critical in a production system, such as:</p><ul><li><strong>No unit tests:</strong> focus is on architectural evolution, not a production-ready codebase</li><li><strong>Minimal input validation:</strong> basic checks only, not production-grade security hardening</li><li><strong>No abuse prevention:</strong> there will be rate limiting, but anti-spam measures won’t be covered</li><li><strong>No user accounts:</strong> this is a simple shortener demonstrating distributed systems concepts</li></ul><p>So, if you’re looking for a complete, production-ready URL shortener, <a href="https://github.com/topics/url-shortener">check GitHub and take your pick</a>. But if you want to understand how distributed systems are built and how to benchmark architectural improvements, you’re in the right place!</p><h3>Requirements &amp; scale targets</h3><p>Before we write any code, let’s define what we’re building toward. I’m intentionally keeping the performance targets vague, because actual throughput and latency will depend entirely on the hardware you deploy to.</p><p>And while we don’t define hard performance targets upfront, we’ll be benchmarking each iteration and comparing results throughout this series. This way, we can demonstrate that our architectural evolution actually improves performance and scalability, not just adds complexity.</p><p><strong>Functional Requirements:</strong></p><ul><li><strong>Short Code Specifications:<br></strong>- Length: 6–7 characters<br>- Character set: a-z, A-Z, 0–9 (62 characters)<br>- Namespace: 62⁷ = ~3.5 trillion possible codes</li><li><strong>URL Constraints:</strong><br>- Max original URL length: 2,048 characters (browser-safe)<br>- Short code lifetime: Indefinite (no expiration)</li></ul><p><strong>Design Goals:</strong></p><ul><li><strong>Horizontal Scalability:</strong> add more instances to handle increased load, rather than relying on bigger servers</li><li><strong>Read-Heavy Workload:</strong> expect redirects to vastly outnumber shortening requests (typical 10:1 ratio or higher)</li><li><strong>Storage Growth:</strong> design for millions of short codes with room to grow</li><li><strong>Low Latency:</strong> keep both shortening and redirects fast (sub-100ms when possible)</li></ul><h3>So where do we start?</h3><p>The best place to start is with the simplest possible implementation of the core functionality: shortening URLs and redirecting to them. From here, we can iteratively add features, optimizations, and infrastructure components, each time motivated by a real need that arises from the limitations of the previous version.</p><p><strong>Before we dive into code, a quick note on approach (you should skip this if you don’t care for me getting all philosophical)</strong></p><p>When you start simple and get something working, storage methods, scaling strategies, and database schemas follow naturally from the problems you encounter, not from upfront speculation.</p><p>Over my career, I’ve met countless developers who approach this in the exact reverse order, and<em> </em>I used to be one of them: I’d start with the database model, design the perfect schema, plan the caching strategy, and then try to build the application around it.</p><p>Starting with the database model, however, locks you in early. For starters it decides <em>that</em> you’ll be using a database, maybe even a particular brand. <strong>But an application should dictate storage, not the other way around.</strong></p><p>Now I build production applications differently: I build the simplest thing that works, and let the architecture emerge from real constraints. It’s not just an approach for this blog series, it’s how I work day-to-day.</p><p>I know this isn’t some kind of mind-blowing revelation, but if you’ve never tried it, I highly recommend it: it’s allowed me to demonstrate and discuss with stakeholders early-on, and it’s kept my pet projects from stalling out, because when you see something working quickly, you keep those <em>sweet-sweet endorphins</em> pumping instead of getting stuck in architecture decisions and losing interest.</p><p>Alright, enough with the philosophical digression, let’s finally see some code 😅</p><h3>Flipr v0: let’s go ephemeral!</h3><p>Let’s take a look at the actual code we’re talking about here. As promised, this first version is intentionally minimal, without any external dependencies such as databases or caching layers: pure business logic and a simple HTTP server. Everything lives in memory, which means it all disappears when the server restarts. Exactly how we like it for now :)</p><h4>The Stack</h4><p>Nothing fancy, just solid, battle-tested tools that get the job done!</p><ul><li><strong>TypeScript</strong> for adding some sanity ontop of JavaScript</li><li><strong>Node.js</strong> as the runtime</li><li><strong>Express</strong> for the HTTP server</li><li><strong>Winston</strong> for structured logging</li><li><strong>Zod</strong> for rudimentary request validation</li></ul><h4>Business logic</h4><p>Let’s start with the core: the Shortener class, which is where all the URL shortening logic lives, completely independent of HTTP, databases, or any infrastructure concerns.</p><p>By keeping this business logic separate from transport and storage, the code stays clean and testable. As a bonus, we could reuse it in other contexts later, like a CLI tool or a different web framework.</p><pre>import { validator } from &#39;./validator&#39;;<br><br>const NUMBER_OF_CODE_GENERATOR_RETRIES = 10;<br><br>type ShortRecord = {<br>  code: string;<br>  url: string;<br>};<br><br>export class CodeRestrictedError extends Error {<br>  constructor(message: string) {<br>    super(message);<br>    this.name = &#39;CodeRestrictedError&#39;;<br>  }<br>}<br><br>export class FailedUrlRetrievalError extends Error {<br>  constructor(message: string) {<br>    super(message);<br>    this.name = &#39;FailedUrlRetrievalError&#39;;<br>  }<br>}<br><br>export class ShortCodeNotFoundError extends Error {<br>  constructor(message: string) {<br>    super(message);<br>    this.name = &#39;ShortCodeNotFoundError&#39;;<br>  }<br>}<br><br>const lookup: { [key: string]: ShortRecord } = {};<br><br>const generateShortCode = (length: number) =&gt; {<br>  const chars =<br>    &#39;abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789&#39;;<br>  let code = &#39;&#39;;<br>  for (let i = 0; i &lt; length; i++) {<br>    code += chars.charAt(Math.floor(Math.random() * chars.length));<br>  }<br>  return code;<br>};<br><br>const exists = (code: string) =&gt; !!lookup[code];<br><br>const insert = (code: string, url: string) =&gt; {<br>  lookup[code] = { code, url };<br>};<br><br>const get = (code: string): ShortRecord =&gt; lookup[code];<br><br>const generateShortCodeWithRetry = (<br>  length: number,<br>  validate: (code: string) =&gt; boolean,<br>) =&gt; {<br>  let code = generateShortCode(length);<br>  let attempts = 0;<br>  while (attempts &lt; NUMBER_OF_CODE_GENERATOR_RETRIES) {<br>    if (validate(code)) {<br>      return code;<br>    }<br><br>    code = generateShortCode(length);<br>    attempts++;<br>  }<br><br>  throw new Error(&#39;Failed to generate a unique short code&#39;);<br>};<br><br>type CodeBlockList = {<br>  reserved: Set&lt;string&gt;;<br>  offensive: Set&lt;string&gt;;<br>  protected: Set&lt;string&gt;;<br>};<br><br>export type ShortenerConfig = {<br>  shortcodeLength: number;<br>  codeBlockList: CodeBlockList;<br>};<br><br>export class Shortener {<br>  private readonly validate: (code: string) =&gt; boolean;<br><br>  public constructor(private readonly config: ShortenerConfig) {<br>    this.validate = validator(<br>      this.config.codeBlockList.reserved,<br>      this.config.codeBlockList.offensive,<br>      this.config.codeBlockList.protected,<br>    );<br>  }<br>  <br>  private test = (code: string) =&gt; this.validate(code) &amp;&amp; !exists(code);<br><br>  public shorten = (url: string, customCode?: string): ShortRecord =&gt; {<br>    if (customCode &amp;&amp; !this.test(customCode)) {<br>      throw new CodeRestrictedError(&#39;Custom code is restricted&#39;);<br>    }<br><br>    let newShortCode =<br>      customCode ||<br>      generateShortCodeWithRetry(this.config.shortcodeLength, this.test);<br><br>    insert(newShortCode, url);<br><br>    const r = get(newShortCode);<br>    if (!r) {<br>      throw new FailedUrlRetrievalError(&#39;Failed to retrieve the shortened URL&#39;);<br>    }<br><br>    return {<br>      code: r.code,<br>      url: r.url,<br>    };<br>  };<br><br>  public resolve = (shortCode: string): ShortRecord =&gt; {<br>    if (!exists(shortCode)) {<br>      throw new ShortCodeNotFoundError(&#39;Short code not found&#39;);<br>    }<br><br>    return get(shortCode);<br>  };<br>}</pre><h4>Let’s break this down</h4><p><strong>Storage:</strong> the lookup object is our entire database. It’s a simple key-value store mapping short codes to URLs. When the server restarts, everything disappears. Perfect for now.</p><p><strong>Code Generation:</strong> the generateShortCode function creates random strings from a 64-character alphabet (a-z, A-Z, 0–9). With a default length of 7 characters, that gives us 62⁷ = ~3.5 trillion possible codes. Plenty of headroom.</p><p><strong>Collision Handling:</strong> the generateShortCodeWithRetry function tries up to 10 times to generate a valid code. “Valid” means it passes the blocklist check <em>and</em> doesn’t already exist in our lookup. If we can’t find a valid code after 10 attempts, we throw an error. In practice, with trillions of possible codes and an empty database, collisions are very unlikely.</p><p><strong>Blocklists:</strong> the imported validator function checks three lists:</p><ul><li><strong>Reserved:</strong> things like api, health, admin that can be used to claim authority and exploit unsuspecting users</li><li><strong>Offensive:</strong> self-explanatory</li><li><strong>Protected:</strong> codes we might want to use for special purposes later, or might be exploited by confusing people, such as names of well-known social media sites</li></ul><p><strong>Custom codes:</strong> users can optionally provide their own short code, e.g. flipr.io/mysite. We validate it the same way as generated codes. If it’s restricted or already taken, we throw a CodeRestrictedError.</p><p><strong>Error types:</strong> three custom error classes let the HTTP layer distinguish between different failure modes:</p><ul><li>CodeRestrictedError : the custom code is blocked or taken (422 Unprocessable Entity)</li><li>ShortCodeNotFoundError : the code doesn’t exist (404 Not Found)</li><li>FailedUrlRetrievalError : something went wrong after insertion (500 Internal Server Error)</li></ul><p>This separation keeps the business logic clean. The Shortener class doesn’t know anything about HTTP status codes.</p><h4>Wiring it up with Express</h4><p>The Express server is straightforward. Here are the two main endpoints:</p><p><strong>Shortening a URL:</strong></p><pre>app.post(&#39;/api/shorten&#39;, async (req, res) =&gt; {<br>  logger.info(&#39;URL shortening request&#39;, {<br>    type: &#39;shortening_try&#39;,<br>    originalUrl: req.body.url,<br>    customCode: req.body.custom_code,<br>  });<br><br>  try {<br>    const { url, custom_code } = URLRequest.parse(req.body);<br><br>    const r = shortener.shorten(url, custom_code);<br>    const shortUrl = `${baseUrl}/${r.code}`;<br><br>    logger.info(&#39;URL shortened successfully&#39;, {<br>      type: &#39;shortening_success&#39;,<br>      shortCode: r.code,<br>    });<br><br>    res.json({<br>      short_code: r.code,<br>      short_url: shortUrl,<br>      original_url: r.url,<br>    });<br>  } catch (error) {<br>    logger.error(&#39;API shorten error:&#39;, { type: &#39;shortening_error&#39;, error });<br><br>    if (error instanceof CodeRestrictedError) {<br>      res.status(422).json({ error: &#39;Custom code restricted&#39; });<br>      return;<br>    }<br><br>    if (error instanceof FailedUrlRetrievalError) {<br>      res.status(500).json({ error: &#39;Failed to retrieve the shortened URL&#39; });<br>      return;<br>    }<br><br>    throw error;<br>  }<br>});</pre><p>We validate the request body with <a href="https://github.com/colinhacks/zod">Zod</a>, call shortener.shorten(), and return the result. If the shortener throws one of our custom errors, we map it to the appropriate HTTP status code.</p><p><strong>Resolving a short code:</strong></p><pre>app.get(&#39;/:shortCode&#39;, async (req, res) =&gt; {<br>  logger.info(&#39;Redirection request&#39;, {<br>    type: &#39;redirect_try&#39;,<br>    shortCode: req.params.shortCode,<br>  });<br><br>  try {<br>    const r = shortener.resolve(req.params.shortCode);<br><br>    logger.info(&#39;Redirection successful&#39;, {<br>      type: &#39;redirect_success&#39;,<br>      shortCode: req.params.shortCode,<br>      destinationUrl: r.url,<br>    });<br><br>    res.redirect(302, r.url);<br>  } catch (error) {<br>    logger.error(&#39;Redirect error:&#39;, { type: &#39;redirect_error&#39;, error });<br><br>    if (error instanceof ShortCodeNotFoundError) {<br>      res.status(404).send(&#39;&lt;h1&gt;Short URL not found&lt;/h1&gt;&#39;);<br>      return;<br>    }<br><br>    throw error;<br>  }<br>});</pre><p>This is the redirect endpoint. When someone visits flipr.io/abc123, we look up the code and send a 302 redirect to the original URL. If the code doesn’t exist, we return a 404.</p><p>The rest of the Express setup is standard boilerplate: CORS headers, static file serving for a simple web UI, a health check endpoint, and <a href="https://github.com/winstonjs/winston">Winston</a> logging throughout. <a href="https://github.com/edeckers/flipr-distributed-url-shortener">You can see the full server code in this GitHub repo</a>.</p><h3>Running it locally</h3><p>Want to try Flipr yourself? The code is open source and ready to run.</p><p><strong>Clone and install:</strong></p><pre>git clone https://github.com/edeckers/flipr-distributed-url-shortener.git<br>cd flipr<br>git checkout part-1-ephemeral<br>npm install</pre><p><strong>Start the server:</strong></p><p>npm start</p><p>The server will start on <a href="http://localhost:3000`">http://localhost:8000</a>. You’ll see Winston logging output in your terminal.</p><p><strong>Shorten a URL:</strong></p><pre>curl -X POST http://localhost:8000/api/shorten \<br> -H &quot;Content-Type: application/json&quot; \<br> -d &#39;{&quot;url&quot;: &quot;https://example.com/some/very/long/url&quot;}&#39;</pre><p>You’ll get back a response like:</p><pre>{<br> &quot;short_code&quot;: &quot;aB3xY9&quot;,<br> &quot;short_url&quot;: &quot;http://localhost:8000/aB3xY9&quot;,<br> &quot;original_url&quot;: &quot;https://example.com/some/very/long/url&quot;<br>}</pre><p><strong>Test the redirect:</strong></p><p>Visit <a href="http://localhost:3000/aB3xY9%60">http://localhost:8000/aB3xY9</a> in your browser, or use curl:</p><p>curl -L <a href="http://localhost:3000/aB3xY9">http://localhost:3000/aB3xY9</a></p><p><strong>Try a custom code:</strong></p><pre>curl -X POST http://localhost:8000/api/shorten \<br> -H &quot;Content-Type: application/json&quot; \<br> -d &#39;{&quot;url&quot;: &quot;https://example.com&quot;, &quot;custom_code&quot;: &quot;mysite&quot;}&#39;</pre><p>If you have the web UI enabled, you can also visit <a href="http://localhost:3000`">http://localhost:8000</a> in your browser for a simple form interface.</p><h3>What’s next</h3><p>In the next post, we’ll containerize Flipr and create basic Kubernetes configurations using Kustomize. We’ll explore how to package the application for deployment and set up the foundation for running it in a distributed environment.</p><p>The code evolves in branches on GitHub, so you can follow along commit by commit, deploy it yourself, or jump to any stage that interests you. This is designed as a learning resource for understanding distributed systems architecture, and it’s fully open source under the MPL-2.0 license.</p><p>If you spot issues, have suggestions, or want to contribute, open an issue or PR on the repo. I’m building this in public as both a learning exercise and a reference implementation for self-hosting.</p><h3>Wrapping it up</h3><p>We started with a simple question: what’s the minimum viable URL shortener? Turns out, it’s about 150 lines of TypeScript.</p><p>This ephemeral version won’t survive a restart, and it won’t scale beyond a single instance, but that’s fine and intended: we’ve proven the concept works, and we have a solid foundation to build on.</p><p>Next part of this series, we’ll dockerize the application and add a basic Kubernetes configuration. See you then!</p><p><strong>Have you ever started a project by building the database schema first, only to realize later that your application logic didn’t quite fit? Or do you prefer starting with the data model? I’d love to hear how you approach greenfield projects in the comments!</strong></p><p>If the Dutch language doesn’t scare you, and you’d like to know more about what keeps me busy aside from writing these blog posts, <a href="https://branie.it/">check my company website branie.it</a>! Maybe we can work together on something someday :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b972c5fe9d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stopping bad actors: inside 1Password’s security model]]></title>
            <link>https://edeckers.medium.com/stopping-bad-actors-inside-1passwords-security-model-8c65c6acb9ff?source=rss-635a48996a6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c65c6acb9ff</guid>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[password-manager]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Ely]]></dc:creator>
            <pubDate>Fri, 10 Oct 2025 18:50:02 GMT</pubDate>
            <atom:updated>2026-01-05T22:10:36.865Z</atom:updated>
            <content:encoded><![CDATA[<h4>“That’s encryption, baby!”</h4><blockquote><strong>This post is </strong><a href="https://medium.branie.it/how-building-useless-software-made-me-a-better-developer-98e9c5f6cbc4"><strong>part of a series on my pet projects</strong></a><strong> that I’ve worked on over the years and I feel would be nice to showcase. So if you like this idea, make sure to </strong><a href="https://medium.branie.it/recreating-my-first-computer-an-atari-2600-emulator-7b72279a4afd"><strong>check out my Atari 2600 emulator from my previous post</strong></a><strong>!</strong></blockquote><p><strong>Fun fact:</strong> this blogpost was featured on <a href="https://typescript.fm/39#t=33m25s">episode 39 of TypeScript.fm</a>.</p><p><strong>I’ve been using password managers for many years, trusting them with literally everything: from my bank accounts to my inbox; my entire digital life actually. And since you’re reading this, you probably do too.</strong></p><p><strong>From the moment I started using a password manager, I wondered:<em> how does this actually work</em>? Why is this secure, <em>is</em> this secure? I pieced together a pretty firm idea of how things must work under the hood. And as it turns out, I wasn’t too far off.</strong></p><p><strong>But there’s a difference between having a mental model and really understanding something. For me, the best way to bridge such a gap is to build it. So I created a </strong><a href="https://github.com/edeckers/lib1password-unofficial"><strong>fully 1Password-compatible TypeScript library</strong></a><strong> and turned it into an </strong><a href="https://passwords.lgtm.it/"><strong>interactive explainer</strong></a><strong>. I’m a web developer, not a cryptographer, which means security-wise it will leave something to be desired, but the implementation works with real 1Password data, which means I must have understood <em>something</em> 😅</strong></p><p><strong>Let me walk you through the process, using the credentials of the one and only <em>legendary actor and director</em> Tommy Wiseau, </strong><a href="https://www.youtube.com/watch?v=7h7QG7W14qs"><strong>an avid 1Password user and ambassador himself!</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Fag_baCKX_XVl-BF" /><figcaption>Photo by <a href="https://unsplash.com/@tinaflour?utm_source=medium&amp;utm_medium=referral">Kristina Flour</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Protecting Tommy Wiseau’s scripts and your passwords</h4><p>Imagine you’re <em>the</em> <strong>Tommy Wiseau</strong>: you’re between takes on your latest project, and you need to access your script notes. But here’s the thing: you can’t afford to have your scripts leaked. Your creative process is <em>unique</em>. Your dialogue is <em>distinctive</em>. One leak and the internet would have a field day.</p><blockquote>Tommy Wiseau famously starred in the <a href="https://www.youtube.com/watch?v=7h7QG7W14qs">Stopping Bad Actors</a> commercial for 1Password, check it out!</blockquote><p>So, naturally, you use a password manager, 1Password in particular. But how does 1Password actually protect Tommy’s precious scripts? How does it keep his passwords secure even from 1Password themselves? Let’s find out.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F15698522&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fi-cant-tell-you-confidential-tommy-wiseau-gif-15698522&amp;image=https%3A%2F%2Fmedia.tenor.com%2FnLaQWRX52-gAAAAN%2Fi-cant-tell-you-confidential.png&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/7da33266c1acfee228eb72b6d71c4a6d/href">https://medium.com/media/7da33266c1acfee228eb72b6d71c4a6d/href</a></iframe><h4>The Journey: from curiosity to code</h4><p>Tommy’s passwords are stored on 1Password’s servers, but they claim they can’t decrypt his vault even if they wanted to. How does that work? What’s stopping a rogue employee from accessing his script for “The Room 2”? <em>(hey, one can dream)</em></p><p>I found my answer in 1Password’s <a href="https://1passwordstatic.com/files/security/1password-white-paper.pdf">Security Design white paper</a>. It’s an excellent read and it’s pretty palatable, much more so than I expected beforehand. A recommended read for sure!</p><p>But understanding theory is one thing. I wanted to implement it. Because for me, the best way to truly understand something is to build it. So I set out to create a <strong>TypeScript library</strong> that implements 1Password’s security model, <strong>which is capable of decrypting actual 1Password vault data</strong>; if my implementation couldn’t handle the real thing, how would I know I truly understood it?</p><blockquote>A pleasant surprise: the Web Crypto API, <a href="https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto">SubtleCrypto</a> in particular, handles all the heavy lifting. <a href="https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto#supported_algorithms">PBKDF2, AES-256-GCM, RSA-OAEP, it’s all built into every modern browser</a>. No external crypto libraries needed.</blockquote><h4>And so I verified it can process actual 1Password data</h4><p>To verify full compatibility, I created a test account, intercepted the encrypted data using <a href="https://en.wikipedia.org/wiki/Burp_Suite">Burp Suite</a> and the <a href="https://github.com/1Password/burp-1password-session-analyzer">1Password Session Analyzer plugin</a> to strip away the custom in-transit encryption layer on top of TLS, and <a href="https://github.com/edeckers/lib1password-unofficial/blob/980b6c2115f4ae738a5a4e7753d1c78e45015ff5/spec/actualPasswordScenario.spec.ts">wrote a test that decrypts the data using my library</a>. The test passes, because the implementation is byte-for-byte compatible with 1Password’s production encryption. Pretty cool, right?</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3o751TCniN0ZuTFkVW%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2Ftheroom-the-room-tommy-wiseau-3o751TCniN0ZuTFkVW&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExd3V0amxteTNrYnRvNW5tYnlsOW5jOWd2cXg3cG1zbzUwczhjcG1lNSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F3o751TCniN0ZuTFkVW%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="246" frameborder="0" scrolling="no"><a href="https://medium.com/media/bdaa6a5472afbc1881467835fb2ec07c/href">https://medium.com/media/bdaa6a5472afbc1881467835fb2ec07c/href</a></iframe><h4>“But I don’t want to look at code, just explain it to me”</h4><p>Fair enough, let’s step through the process of what happens when Tommy unlocks his 1Password vault.</p><blockquote>It’s important to realize that aside from the Account Password, <strong>each of the keys</strong> in the steps below<strong> is randomly generated on your device</strong> when you create your account; 1Password only ever sees their encrypted versions.</blockquote><p><strong>1. Account Password + Secret Key = Account Unlock Key (AUK)</strong></p><p>Tommy’s password and his Secret Key are combined <em>on his device</em> using PBKDF2 (650,000 iterations), plus some salts here and there, to create the AUK. Which is an intentionally expensive operation, happening once per session. It keeps brute-force attacks at bay, and his Account Password and Secret Key a secret from 1Password.</p><p><strong>2. AUK decrypts a keyset’s Symmetric Key</strong></p><p>The AUK unlocks a fast <a href="https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt#aes-gcm">AES-256-GCM symmetric key</a>. This key protects Tommy’s <a href="https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/encrypt#rsa-oaep_2">RSA private key</a>, while also making it easy to change the <em>Account Password</em> or <em>Secret Key</em>: only the <em>Keyset Access Key</em> needs to be re-encrypted with the new <em>AUK</em>. Everything downstream stays untouched. No need to re-encrypt your entire account.</p><p><strong>3. Symmetric Key decrypts RSA Private Key</strong></p><p>The symmetric key unlocks Tommy’s RSA private key. Together with the public key, this keypair can decrypt his vault-specific keys without exposing his <em>Account Password</em>.</p><p><strong>4. RSA Keypair decrypts Vault Keys, which encrypt Tommy’s Data</strong></p><p>Each of Tommy’s vaults has its own <em>AES-256-GCM</em> key, encrypted by his RSA public key. These vault keys finally decrypt his actual passwords and data, including those precious script notes.</p><p>Here’s what this looks like in the actual, albeit simplified, response from 1Password’s servers:</p><pre>{<br> &quot;uuid&quot;: &quot;rv4ge63poeyompbhty2efk5xxi&quot;,<br> &quot;encryptedBy&quot;: &quot;mp&quot;, // mp / auk<br> <br> // Layer 2: Symmetric key (encrypted by AUK)<br> &quot;encSymKey&quot;: {<br> &quot;alg&quot;: &quot;PBES2g-HS256&quot;,<br> &quot;data&quot;: &quot;xKj4pR0Ws-FyikpQGSxGk...&quot;, // Encrypted symmetric key<br> &quot;p2c&quot;: 650000 // PBKDF2 iterations<br><br>// ...<br><br> },<br> <br> // Layer 3: RSA private key (encrypted by symmetric key)<br> &quot;encPriKey&quot;: {<br> &quot;data&quot;: &quot;UN1mx3kJh_Qeqdyt-7Jvq...&quot;, // Encrypted private key<br> &quot;kid&quot;: &quot;rv4ge63poeyompbhty2efk5xxi&quot;,<br><br> // ...<br><br> },<br> <br> // Layer 3: RSA public key (unencrypted)<br> &quot;pubKey&quot;: {<br> &quot;alg&quot;: &quot;RSA-OAEP&quot;,<br> &quot;n&quot;: &quot;rwVd9EM4bEwLAI4QWzJhq...&quot;,<br><br> // ...<br><br> }<br>}</pre><p><strong>Why four layers?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*547axYC7B80S2mbEkCxtEw.png" /><figcaption>A screenshot of the key hierarchy from my Interactive 1Password Explainer</figcaption></figure><ul><li><strong>PBKDF2 is slow by design</strong> which adds protection against brute force</li><li><strong>Symmetric crypto is fast</strong>, perfect for protecting the larger RSA private key</li><li><strong>RSA enables sharing</strong>: vaults can be shared without sending Vault Passwords in plaintext or revealing your Account Password</li><li><strong>Per-vault keys</strong> mean compromising one vault doesn’t compromise others</li><li><strong>Rolling Account Credentials is simple </strong>only the Keyset Access Key needs to be re-encrypted with the new AUK</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F6oyHViE7fvjYk%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPWVjZjA1ZTQ3b2FqYnY1cXNjZGg3MDU5ZGJoeGdkY2lqcWEzbW1xa2dseGR1c2RtcSZlcD12MV9naWZzX3JlbGF0ZWQmY3Q9Zw%2F6oyHViE7fvjYk%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExOHZ2c3UxYnN0bTJhZzNzdGh6cHBvejcybzZibDdvYzV1dTNsNjA0NSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F6oyHViE7fvjYk%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="246" frameborder="0" scrolling="no"><a href="https://medium.com/media/22fc2ebe3f038899aff0cfe5fc5143a4/href">https://medium.com/media/22fc2ebe3f038899aff0cfe5fc5143a4/href</a></iframe><h4><strong>Try It Yourself</strong></h4><p>Want to see this encryption chain in action? Head over to <a href="https://passwords.lgtm.it/">my interactive 1Password explainer</a>. You’ll see each layer of the encryption process unfold step by step.</p><h3>That’s Encryption, Baby!</h3><p>Building this TypeScript implementation helped me understand what the 1Password Security Model looks like and why each layer exists. PBKDF2 slows down attackers and hides your password an secret key from 1Password. Symmetric crypto protects your private key efficiently. RSA enables secure sharing. Per-vault keys contain breaches.</p><p>Seeing how these pieces fit together and getting it to work with real 1Password data, turned abstract concepts into some pretty thorough understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qLTnU-WSPHDoj9KA" /><figcaption>Still from “The Room” by Tommy Wiseau</figcaption></figure><p>If you’re curious about the implementation details or want to integrate 1Password vault decryption into your own projects, the full TypeScript library is available at <a href="https://github.com/edeckers/lib1password-unofficial">https://github.com/edeckers/lib1password-unofficial</a>. It’s fully compatible with real 1Password data, just don’t use it in production, and obviously don’t trust a library by some internet stranger like myself with your actual credentials and secrets.</p><p>For a deeper dive into 1Password’s security model, particularly how it works in local client applications, <a href="https://darthnull.org/inside-1password/">David Schuetz’s deep dive series</a> is an excellent resource. <strong>Fun fact:</strong> I found his series because I encountered the string <em>“Obfuscation Does Not Provide Security But It Doesn’t Hurt”</em> (pretty funny, I think) in the source of the 1Password site, and Googling it, his site was the only hit. <a href="https://darthnull.org/1pass-misc/">He touches on it briefly</a> :)</p><p>Did this post spark your curiosity about cryptography or password security? Are you working on similar projects, or do you have questions about the implementation? Let me know in the comments!</p><p>If the Dutch language doesn’t scare you, and you’d like to know more about what keeps me busy aside from my pet projects, <a href="https://branie.it/">check my company website branie.it</a>! Maybe we can work together on something someday :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c65c6acb9ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How building useless software made me a better developer]]></title>
            <link>https://edeckers.medium.com/how-building-useless-software-made-me-a-better-developer-98e9c5f6cbc4?source=rss-635a48996a6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/98e9c5f6cbc4</guid>
            <category><![CDATA[pet-project]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ely]]></dc:creator>
            <pubDate>Thu, 24 Jul 2025 15:28:31 GMT</pubDate>
            <atom:updated>2025-11-09T22:34:54.429Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building useless software made me a better developer</h3><h4>Virtues of <em>the pet project life</em></h4><p><strong>At any given time I have one or more software development pet projects going on, usually involving concepts that seem somewhat magical to me. The goal is always the same: work with them until the magic turns into knowledge.</strong></p><blockquote>I’ve learned easily as much from pet projects as I did on my fulltime software developer job for the past 15+ years.</blockquote><p><strong>I’ve been doing this for years, but I’ve never really shared the results, after all, the projects were meant for learning. Recently though, I decided to start showcasing some of these projects, because they keep coming up in conversations and I have nothing to actually show for them.</strong></p><p><strong>So that’s what this series is about. Starting with my thoughts on pet projects in general, then diving into the specific projects themselves. First up: </strong><a href="https://medium.branie.it/recreating-my-first-computer-an-atari-2600-emulator-7b72279a4afd"><strong>an Atari 2600 emulator that strengthened my understanding of the workings of CPUs and memory</strong></a><strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_mW3KQa_S8pGA_wo" /><figcaption>Photo by <a href="https://unsplash.com/@gidlark?utm_source=medium&amp;utm_medium=referral">Олександр К</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Pet projects, fun and educational</h3><p>If you’re a developer reading this post and you’re not doing so yet, I cannot recommend enough you work on your own pet projects to explore concepts and technologies. Even if you don’t intend on ever sharing the results with anyone. I’ve learned easily as much from pet projects as I did on my fulltime software developer job for the past 15+ years.</p><h4>Finding your niche</h4><p>It can be hard though, to select a project. I know I’ve struggled with it for many reasons; I really had to find the type of projects that pique my interest and keep me engaged. But since I found that niche I don’t recall ever abandoning one again.</p><blockquote>Me learning something sould be my primary motivation for pet projects, but somehow I kept making up all these secondary goals that are about other people!</blockquote><p>For the longest time, I was asking myself the wrong questions:</p><ul><li>Would anyone actually care about my project?</li><li>What is an idea that is unique enough that it is ‘mine’?</li><li>How can I monetize this idea?</li></ul><p>It took me a while to realize that <em>me learning something</em> should be my primary motivation for pet projects, but somehow I kept making up all these secondary goals that are about <em>other people</em>! Think about it:</p><ul><li><strong>Why should this project be cared for by anyone but me </strong>if the goal is for me to learn something?</li><li><strong>Why should this project be unique</strong> if the goal is for me to learn something?</li><li><strong>Why should this project be monetizable</strong> if the goal is for me to learn something?</li></ul><p>Dumb as it may sound, I needed this realization for it to become clear to me that I can pick literally anything that <em>I feel</em> is a technical subject that <em>I want to learn more about</em> — which is pretty much an endless stream.</p><p>I’d think back about my university days and go “‘hey I remember enjoying Compiler Construction a lot, let’s see if that knowledge still lurks somewhere in my mind”, or I’d compress a file at work and think “that’s pretty amazing; I know the theory, but how hard would it be to actually implement an existing compression algorithm”, and so on.</p><p>So I’d define my main niche as topics that fall outside of my regular job description, which I don’t fully grok or that feel like ‘magic’, and that I want to explore.</p><h4>Find out what project types lose your interest</h4><p>Of course, finding that niche isn’t always straightforward. You’ll probably start and abandon a few projects before you figure out what keeps you engaged. I wouldn’t fret too much about it, but simply write down — I have <a href="https://medium.com/@edeckers/organizing-your-thoughts-with-zettelkasten-using-vim-obsidian-syncthing-and-git-ef47b7736eea">a blogpost for Zettelkasten</a> which might be interesting — what the goal was, why it didn’t stick and then forget about it. After a few encounters like these, you might start seeing a pattern which helps you refine your niche.</p><p>For me it was building webapplications as pet projects that never really worked out, since that is my day-job. Which meant that even though I’m passionate about both my job and the project, it felt like working in my spare time which is less than ideal for winding down.</p><p>Don’t get me wrong, I often experiment with new architectures, design patterns and ideas that I encounter and feel are interesting for my day-job, before applying them in actual production code. But these projects usually don’t last much longer than a week — as intended — whereas pet projects can keep me occupied for months.</p><h4>Just start, and set small but satisfying goals</h4><p>But don’t let the search for the perfect niche paralyze you. I think the most important thing is to actually start something. Just having the realization that you can start and stop your own projects at any time, determine your own goals, and ignore external factors — that’s half the work right there.</p><p>And when you do start, set small but satisfying goals. Start with the simplest goal you can imagine, something in the vein of: “I don’t care what the actual implementation looks like, might be a single script with global mutable variables all over the place, as long as I get X to work”.</p><blockquote>Point is to be kind to yourself and savor those successes, don’t care too much about the end product.</blockquote><p>That’s pretty much how I implemented my first CPU operation in <a href="https://atari2600.lgtm.it/">my Atari 2600 emulator</a>: I simply created a few global variables for the available registers, and updated these in accordance with the specs of the processor. It was not until much later that I started bothering with a cleaner approach, allowing me to fit the individual ‘hardware’ components together. This way the entire process felt like a flow of mini-successes.</p><p>Point is to be kind to yourself and savor those successes, don’t care too much about the end product.</p><h3>Showcasing the results</h3><p>Over the years my pet projects involved such ‘magic’ subjects as compilers, encryption, compression, neural networks, and emulation. I thoroughly enjoyed each of them and learned an awful lot, which was the whole point, so goal achieved.</p><p>But every once in a while they came up in conversation with friends, colleagues or in an interview, and it always felt a little underwhelming and unsatisfying not being able to actually show any results, because the projects often didn’t even have any UIs — that was not the point after all.</p><p>This is why I decided to revisit some of the projects that I feel I can showcase and write about them. The first candidate being my JavaScript Atari 2600 emulator .</p><p><a href="https://medium.branie.it/recreating-my-first-computer-an-atari-2600-emulator-7b72279a4afd">In my next post, I’ll take you through the journey of building this emulator from scratch</a>, the challenges I faced, and what I learned along the way. Or if you simply want to see the result first, you can check it out at <a href="https://atari2600.lgtm.it/">https://atari2600.lgtm.it</a></p><h3>In conclusion</h3><p>Looking back, these seemingly pointless projects have shaped how I think about code, problem-solving, and learning itself. They’ve made me more curious, more willing to dig into unfamiliar territory, and I strongly believe, a better developer overall.</p><p>So if you’ve been on the fence about starting your own “useless” project, hopefully this post inspires you to follow through. Pick something that feels like magic, and start turning it into knowledge. You might be surprised by what you learn along the way. Enjoy!</p><p><strong>Did this post push you over the edge to finally start your own pet project? Or do you have plenty experience with pet projects, and have some valuable tips for newcomers? Let me know in the comments!</strong></p><p>If the Dutch language doesn’t scare you, and you’d like to know more about what keeps me busy aside from my pet projects, <a href="https://branie.it/">check my company website branie.it!</a> Maybe we can work together on something someday :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98e9c5f6cbc4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Recreating my first computer: an Atari 2600 Emulator]]></title>
            <link>https://edeckers.medium.com/recreating-my-first-computer-an-atari-2600-emulator-7b72279a4afd?source=rss-635a48996a6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b72279a4afd</guid>
            <category><![CDATA[emulator]]></category>
            <category><![CDATA[hobby]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[pet-project]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Ely]]></dc:creator>
            <pubDate>Thu, 24 Jul 2025 15:26:49 GMT</pubDate>
            <atom:updated>2025-07-27T13:00:44.384Z</atom:updated>
            <content:encoded><![CDATA[<h4>My journey and takeaways</h4><p><a href="https://medium.branie.it/how-building-useless-software-made-me-a-better-developer-98e9c5f6cbc4"><strong>In my recent post about pet projects, I promised to showcase some of mine</strong></a><strong>. The first candidate and subject of this blogpost is my JavaScript Atari 2600 emulator!</strong></p><blockquote>Don’t you think that it’s fascinating that a computer can be emulated on another computer? It definitely is to me!</blockquote><p><strong>Join me on my journey and takeaways of building it in this article. Or if you simply want to see the result, you can check it out at </strong><a href="https://atari2600.lgtm.it/"><strong>https://atari2600.lgtm.it</strong></a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*b7dNM0ySMVQyQjVc" /><figcaption>Photo by <a href="https://unsplash.com/@kshar2?utm_source=medium&amp;utm_medium=referral">kiryl</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Why an emulator?</h3><p>Don’t you think that it’s fascinating that a computer can be emulated on another computer? It definitely is to me: how do you take one machine and make it perfectly pretend to be a completely different machine? How does my modern laptop convince a decades-old game that it’s running on vintage hardware? Reason enough for me to explore this topic in a pet project!</p><p><strong>When it came to choosing a system to emulate, there was really only one option: the Atari 2600</strong>. It was the first computer I ever encountered in my whole life at a friend’s place, and I was absolutely mesmerized. To be able to tell a machine what to do with a joystick and it would display the result on the screen immediately; it could actually play games, can you imagine?!</p><p>My parents noticed my fascination and surprised me with my own console on my birthday. This led to some of my fondest childhood memories of playing Combat, or taking turns on Frogger with my father.</p><h4>A word of warning for those of you aspiring to build an emulator</h4><p>If you’re considering building an emulator for the learning experience, the Atari 2600 might not be your best starting point. While it taught me an incredible amount, <a href="https://en.wikipedia.org/wiki/CHIP-8">I’d honestly recommend starting with CHIP-8 instead</a>.</p><p>CHIP-8 is much simpler while also teaching you the same fundamental concepts such as instruction decoding, memory management, display rendering, and timing. You’ll get to understand emulation, without being frustrated with the many side quests like getting CPU cycles just right for displaying pixels in the correct position.</p><p><strong>What makes building an Atari 2600 emulator so difficult in comparison?</strong> You might assume it’s the 6507 CPU, but that wasn’t the problem. Implementing the MOS 6502 instruction set — the MOS 6507 used in the Atari 2600 is actually a MOS 6502 processor with fewer address lines — is actually quite straightforward and well-documented.</p><p>The real challenge was the <strong>TIA (Television Interface Adapter)</strong>, which is a very unique beast you’ll not find on another console — as far as I’m aware anyway, but please inform me if I’m wrong.</p><h3>The Journey</h3><p>So here we are, energized and in good spirits to learn once and for all how an emulator works! <em>Yes! Let’s go!</em> … Where will we start though?</p><p>Well, if I remember correctly I started this journey by googling for developer manuals for the Atari 2600. I studied computer science in university, so I had some theoretical understanding of how a CPU worked, which is why I figured I would be able to connect both.</p><p>It must have been <a href="https://problemkaputt.de/2k6specs.htm">the problemkaputt.de website</a> that gave me the first ‘yes, I’m onto something here’ feeling. On this site you’ll find all instructions that the MOS6507 chip — the Atari 2600 CPU — supports, explanations of memory layout, how does the Television Interface Adapter (TIA) work, controllers, etc.</p><p><strong>Fun fact:</strong> the site mentioned is actually the result of another developer’s — Martin Korth — Atari 2600 emulator endeavors. Thanks a bunch Martin!</p><h4>Implement CPU basics and a first instruction</h4><p>The first goal I set myself was to implement a single CPU instruction, didn’t really matter which one; preferably one of the simpler ones. So I started taking inventory of the available instructions, because that would give me an idea of the ‘moving parts’ of the system.</p><blockquote>Less intimidating than you might think isn’t it? It’s really all about bookkeeping.</blockquote><p><strong>Moving parts</strong></p><p>Well, apparently <a href="https://en.wikipedia.org/wiki/MOS_Technology_6502#Registers">the MOS 6502 uses 6 registers</a>:</p><ul><li>PC — 16 bit program counter</li><li>S — 8 bit stack pointer</li><li>P — 7 bits processor flags</li><li>A — 8 bit accumulator</li><li>X — 8 bit index</li><li>Y — 8 bit index</li></ul><p>And as for memory, the machine itself puts 128 bytes of RAM at your disposal, which some games such as H.E.R.O. and Pitfall! expand on with external RAM built into their cartridge. And usually there is 4K of ROM available. However, through a technique called bank switching you can have a multitude of it available — many games use this.</p><p>And that’s pretty much it as far as CPU computations go: the PC register points to a position in ROM, your CPU implementation reads the operation and optional operand at this location, updates the registers and memory, and point the PC to the next instruction in ROM. Less intimidating than you might think isn’t it? It’s really all about bookkeeping.</p><p><strong>An example instruction</strong></p><p>Let’s say for example <a href="https://www.pagetable.com/c64ref/6502/?tab=2#LDX">we take a look at the LDX instruction</a>:</p><p>LDX #$10</p><p>This is a 2 byte instruction consisting of an operation (byte 1) and an operand (byte 2), which stores the hexadecimal value $10 in the X register and updates Zero and Negative flags of the P register accordingly.</p><p>So all I had to do to execute this command in JavaScript, was to set a globally defined variable RX to 0x10 and change the globally defined flag variables FZ = 0 (0x10 != 0) and FN = 0 (bit 7 of 0x10 = 0). Finally I’d point globally defined variable PC to it’s current value + 2, because the LDX instruction is 2 bytes long as explained above.</p><p>Here’s what that would look like in JavaScript:</p><pre>let rx = 0;<br>let pc = 0;<br><br>let fz = false;<br>let fn = false;<br><br>const ldx = (v) =&gt; {<br>  rx = v;<br><br>  fz = v === 0;<br>  fn = (rx &amp; 0x80) === 0x80;<br><br>  pc += 2;<br>}</pre><p>Of course there’s more to it, but in essence this is pretty much the whole trick to emulating this CPU :)</p><h4>Disassembly</h4><p>We might be able to work with the raw binary ROM data, but it’s much easier to debug your code when you know what you’re working with. Anybody who ever had to fix an issue on production without sufficient logging will agree that flying blind brings back terrible memories.</p><p>So after implementing an instruction, I would add a disassembly action. This enabled me to load a binary ROM from memory and then actually see the code — well… assembly — that I’m working with instead of hexadecimal or binary representation. Absolute necessity to get my emulator to do anything useful. Actually I eventually even created a debugger so I could step through applications; <a href="https://atari2600.lgtm.it/">you can see it in the demo</a>.</p><p>Just make sure you start with some simple ROMS, the older the better. Because the older ROMs didn’t use <a href="https://www.masswerk.at/nowgobang/2021/6502-illegal-opcodes">too many undocumented instructions</a> or exploit the system by adding extra RAM or bank switching for example. These things are partially and crudely implemented in my emulator but are out of scope for this post.</p><p><strong>Tip:</strong> <a href="https://forums.atariage.com/topic/27194-session-8-our-first-kernel">the kernels from the “2600 Programming for Newbies” guide</a> by Andrew Davie were very useful starting points for me.</p><h4><strong>The Real Challenge: The TIA</strong></h4><p>With basic CPU instructions working, I thought the hard part was over. I was very wrong.</p><p>The TIA is fascinating. Instead of a traditional frame buffer, it generates video in real-time, scanline by scanline. You have exactly 76 CPU cycles per scanline to tell it what to draw. Miss your timing window by even one cycle, and you get glitched graphics, missing sprites, or blank screens.</p><blockquote>With basic CPU instructions working, I thought the hard part was over. I was very wrong.</blockquote><p>This was where things got really tricky for me, because I made the assumption that the graphics work as you’d expect — you draw stuff to memory, then display it? Alas, the TIA doesn’t work like that at all. It’s painting the screen as it goes, and if you’re not feeding it the right data at exactly the right moment, you get anything from garbled graphics to rolling screens, blank screens and everything in between.</p><p>I spent more hours than I care to admit debugging why sprites would flicker, or why colors would be wrong, or why entire sections of the screen would just be blank. It all came down to timing or misinterpreting the documentation I was using, or faults in said documentation. The games themselves had to be incredibly clever — they’d change sprite positions and colors mid-frame, all timed to the exact CPU cycle when the TV’s electron beam reached that spot on screen.</p><p>The TIA forces you to think like a 1970s hardware engineer — every cycle matters, every memory access is precisely timed, and the slightest timing error cascades into visual chaos. It’s simultaneously fascinating and maddening.</p><h3>Controllers</h3><p>When I had the TIA working with some basic playfield graphics and player sprites, and got the syncing between the CPU close enough to emulate Frogger, I added a controller.</p><p>There had been several breakthrough moments, but this was really a special moment where I had a fully functional machine. Bar the audio, which is still on my todo list.</p><h3>What I Learned</h3><p>Atari 2600 developers were artists pushing the boundaries of the extremely limited resources of the machine, and managed to pull off visual tricks that shouldn’t be possible, like the multiple sprites in Space Invaders or the scrolling backgrounds in Pitfall!</p><p>I also learned a thing or two about low level coding, like how you can make a loop faster by 2 cycles per loop if you craft it correctly. Mostly irrelevant and not applicable with today’s technology and languages, but for programming the Atari 2600 fitting extra cycles in a line can make all the difference.</p><p>Using predefined data for division or simulating sines were pretty cool discoveries as well. All this made me really appreciate what developers of the day could squish out of the machine.</p><p><strong>Bonus tip: </strong>even today there are people in the demo scene pushing the Atari 2600 to the limit, <a href="https://youtu.be/irAmqaDqSIw?si=O6cYA3pkqvl-MXKW">I can highly recommend you check them out on YouTube!</a></p><h3><strong>Recommendations for aspiring emulator developers</strong></h3><p>If you’re thinking about diving into emulator development after reading all this, here are some things that helped me along the way:</p><p><strong>Start ridiculously simple.</strong> Throw everything into global variables — CPU registers, ROM and RAM all in the same globally defined array. You’ll have your first instruction implemented in no time which will give you instant gratification, confidence you can crack this, and it makes it dead simple to understand how the CPU and instructions actually function. You can always clean it up later once you have instructions executing and see what is happening.</p><p><strong>Pick your first instruction carefully.</strong> Go for something dead simple like LDA (load accumulator) with immediate addressing, or maybe even CLD (clear decimal flag). Avoid anything that touches the stack or does complex memory operations until you’re comfortable with the basics.</p><p><strong>Build a disassembler early.</strong> Being able to see the actual assembly code instead of raw hex bytes will save your sanity. It’s the difference between debugging blind and actually understanding what your emulator is trying to execute. From there it felt natural for me to develop a debugger, which helped me a lot analyzing games that would trip my emulator in any way.</p><p><strong>Don’t get hung up on perfection.</strong> Can’t get the CPU timing exactly right? Is your performance a bit off, but games are mostly playable? <em>Move on</em>. Focus on implementing different addressing modes, or tackle bank switching, or get controllers working. Returning to those tricky issues with a deeper understanding of the system, I’d often find the solution became obvious.</p><p><strong>Don’t be afraid to use existing emulators as reference.</strong> <a href="https://8bitworkshop.com/">Sites like 8bitworkshop.com have been incredibly valuable to me</a> for verifying behavior and debugging issues. I drew the line at looking at actual emulator source code, but you might even consider doing that when you’re truly stuck. Better to peek and learn something than abandon the project entirely.</p><p><strong>Test with the simplest ROMs you can find.</strong> Start with basic games from the late 70s that don’t use fancy tricks. Save the advanced stuff for when you’re not pulling your hair out over basic instruction decoding.</p><p>The goal is to get that first “wow, it’s actually working” moment as quickly as possible. Everything else can be cleaned up later.</p><h3>Current State</h3><p>My emulator was tested in Chrome and Firefox, and currently supports <strong>eight classic games</strong>: Bowling, Combat, Frogger, Moon Patrol, Pong Sports, Tennis, Tic Tac Toe 3D, and Super Breakout.</p><p><strong>What’s working</strong></p><ul><li>Cycle-accurate 6507 CPU emulation</li><li>TIA graphics rendering</li><li>Controller input</li><li>ROM loading</li></ul><p><strong>What’s planned</strong></p><ul><li>Performance optimization</li><li>Audio support (the TIA’s sound channels)</li><li>Additional game compatibility</li></ul><h3>Try It Yourself</h3><p><a href="https://atari2600.lgtm.it/"><strong>Visit atari2600.lgtm.it to try the emulator</strong></a>. You can play the included games or upload your own ROMs.</p><h3>Invaluable resources</h3><p>Planning to build your own Atari 2600 emulator? Cool! These resources were very helpful to me:</p><ul><li><a href="https://problemkaputt.de/2k6specs.htm">Atari 2600 specs on problemkaputt.de</a></li><li><a href="https://www.pagetable.com/c64ref/6502/?tab=0">6502 Family CPU Reference</a></li><li><a href="https://www.masswerk.at/nowgobang/2021/6502-illegal-opcodes">6502 “Illegal” Opcodes Demystified</a></li><li><a href="https://forums.atariage.com/topic/33233-sorted-table-of-contents/">Atari 2600 programming for newbies</a></li><li><a href="https://8bitworkshop.com/">Emulator + IDE 8bitworkshop.com</a></li></ul><p>Did this post inspire you to work on your own emulator or another pet project? Or do you have some favorite anecdotes about the real machine that you owned back in the day? Let me know in the comments!</p><p>If the Dutch language doesn’t scare you, and you’d like to know more about what keeps me busy aside from my pet projects, <a href="https://branie.it/"><strong>check my company website branie.it</strong></a><strong>!</strong> Maybe we can work together on something someday :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b72279a4afd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I relocated my Jekyll blog — what about SEO?]]></title>
            <link>https://edeckers.medium.com/how-i-moved-my-jekyll-blog-posts-to-a-subdirectory-without-hurting-seo-2f0921faba4b?source=rss-635a48996a6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f0921faba4b</guid>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[blogging]]></category>
            <category><![CDATA[jekyll]]></category>
            <category><![CDATA[static-site]]></category>
            <dc:creator><![CDATA[Ely]]></dc:creator>
            <pubDate>Thu, 19 Dec 2024 19:58:12 GMT</pubDate>
            <atom:updated>2024-12-19T22:33:43.126Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>A while ago </strong><a href="https://medium.com/@edeckers/moving-from-next-js-to-jekyll-a1427b9c7938"><strong>I migrated my company website from NextJS to Jekyll</strong></a><strong>, and so far I have no regrets: for a static website generator, Jekyll is pretty flexible and suits all my needs.</strong></p><p><strong>I did run into an issue though when I wanted to move my blog posts to a subdirectory of my website without sacrificing search rankings — Jekyll’s static nature definitely makes this a little tricky, but not impossible. I’ll tell you how I went about it in this post.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LekWBg-vMpn9R1TZ" /><figcaption>Photo by <a href="https://unsplash.com/@molefrog?utm_source=medium&amp;utm_medium=referral">Alexey Taktarov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Last week I realized that the url to my blog was <a href="https://branie.it/blog/">https://branie.it/blog/</a>, but my actual posts resided in https://branie.it/:year:/:month:/:day:/name-of-a-blogpost.html i.e. <em>without</em> the /blog prefix — this discrepancy doesn’t hurt anyone, not even search rankings, but it annoyed me enough to want to do something about it.</p><h3>The challenge: preserve SEO and avoid broken links</h3><p>When you change the URL structure of your site, search engines might treat old links as broken, which could cause your search rankings to drop. Furthermore, any external links pointing to your old blog post URLs will no longer work.</p><p>I knew that if I wanted to restructure my blog while keeping my search rankings intact, I needed to set up proper redirects from the old URLs to the new ones, but how would I do that in a static website where I only have static content at my disposal, and unable to use .htacccess and the like? Luckily, Jekyll makes it easy to handle this with a little customization.</p><h3>Why existing options didn’t work for me</h3><p>The goto solution for this situation seems to be the <a href="https://github.com/jekyll/jekyll-redirect-from">jekyll-redirect-from</a> plugin, which would actually solve my exact problem. Blogpost over, right?</p><p>Alas, it wasn’t that easy, because I wasn’t fully on board with their approach: to create one or more redirects to a particular post, you need to add one or more aliases to the Front Matter of each individual page. But what I was looking for was a way to configure redirects in a central place like _config.yml.</p><p>So, I figured “how hard could it be” and started working on my own solution — it turned out to be pretty straight-forward 😄</p><h3>Rolling my own</h3><h4>Step 1: find out how the jekyll-redirect-from plugin solves the problem</h4><p>We only have static content at our disposal, so how will we use it to create redirects? The answer I found in the source of the jekyll-redirect-from plugin was to use a &lt;meta http-equiv=&quot;refresh&quot; ... header with a 0 seconds timeout.</p><p>But that’s not a 301 or 302redirect, which is what I would have used were I not using a static website. What does Google think of this? Well, apparently <a href="https://developers.google.com/search/docs/crawling-indexing/301-redirects#metarefresh">it treats </a><a href="https://developers.google.com/search/docs/crawling-indexing/301-redirects#metarefresh">meta refresh with a timout of </a><a href="https://developers.google.com/search/docs/crawling-indexing/301-redirects#metarefresh">0 seconds like a </a><a href="https://developers.google.com/search/docs/crawling-indexing/301-redirects#metarefresh">301 redirect</a>:</p><blockquote><strong>Instant </strong><strong>meta refresh redirect</strong>: Triggers as soon as the page is loaded in a browser. Google Search interprets instant meta refresh redirects as permanent redirects.</blockquote><p>Great! So I can use pure HTML to achieve the same 301 redirects I would have used, were I using a dynamic website 🎉</p><p>With this knowledge, <a href="https://github.com/jekyll/jekyll-redirect-from/blob/master/lib/jekyll-redirect-from/redirect.html">I took the layout from </a><a href="https://github.com/jekyll/jekyll-redirect-from/blob/master/lib/jekyll-redirect-from/redirect.html">jekyll-redirect-from plugin</a>, copied it to _layouts/redirector.html and adapted it to my own liking:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ce339ce98d2bf528ce3d0e5158a23ea4/href">https://medium.com/media/ce339ce98d2bf528ce3d0e5158a23ea4/href</a></iframe><h4>Step 2: generating a yaml configuration containing all redirects</h4><p>Ok, so we have a redirect layout, now we need to generate some pages for it. As I mentioned earlier I’m looking for a solution where I can define my redirects in _config.yml, which is why I wrote the quick-and-dirty Python script below, which takes care of generating a redirector config section, where all existing blogposts are mapped to their new location.</p><p>You just run it the first time you move your blogposts to a subdirectory, so existing url’s aren’t lost. New url’s don’t need a mapping, because they never existed in another place, so no need to update the config.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c45a78cc35bd84ca5678c79b2ce4983/href">https://medium.com/media/1c45a78cc35bd84ca5678c79b2ce4983/href</a></iframe><p>Simply run it with:</p><ul><li>--path-to-posts set to the absolute path to the _posts directory of your Jekyll installation</li><li>--target-url set to the new <em>relative</em> base url for your blogposts</li></ul><p>Which might look something like this:</p><pre>redirector_config_generator.py \<br>  --path-to-posts /local/path/to/jekyll/_posts \<br>  --target-url /blog</pre><p>And you’ll end up with an output like the snippet below, which you should copy to your _config.yml.</p><pre>redirector:<br>  - from: /2024/12/19/some-blogpost-about-jekyll.html<br>    to: /blog/2024/12/19/some-blogpost-about-jekyll.html<br>  - from: ...<br>    to: ...<br><br>...</pre><h4>Step 3: install the redirector plugin hook</h4><p>And the final step is to generate static, instantmeta-refresh redirect pages in the locations defined by the mapping we just added to _config.yml in the previous step.</p><p>I wrote the Jekyll hook plugin below, that you simply copy to _plugins/redirector.rb after which you’re all set!</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c050199c4313006b087443da5f4772e1/href">https://medium.com/media/c050199c4313006b087443da5f4772e1/href</a></iframe><h3>Results</h3><ol><li><strong>No Broken Links</strong>: All the old blog URLs now redirect correctly to the new /blog paths.</li><li><strong>SEO Retention</strong>: By setting up 301 redirects through the use of meta refresh, I preserved the link equity and rankings for my old blog posts.</li></ol><h3>Conclusion</h3><p>Migrating your Jekyll blog posts to a subdirectory doesn’t have to be complicated. With a little effort, and applying the steps layed out in this article, Jekyll makes it easy to implement clean redirects that keep your site’s structure organized without sacrificing SEO.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f0921faba4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Zettelkasten using Vim, Obsidian, Syncthing and Git]]></title>
            <link>https://edeckers.medium.com/organizing-your-thoughts-with-zettelkasten-using-vim-obsidian-syncthing-and-git-ef47b7736eea?source=rss-635a48996a6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef47b7736eea</guid>
            <category><![CDATA[notes]]></category>
            <category><![CDATA[notetaking]]></category>
            <category><![CDATA[zettelkasten]]></category>
            <category><![CDATA[tools]]></category>
            <dc:creator><![CDATA[Ely]]></dc:creator>
            <pubDate>Wed, 13 Nov 2024 20:46:08 GMT</pubDate>
            <atom:updated>2024-11-19T06:41:13.262Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Lately I’ve been using a more organized approach to note-taking than simply jotting things down in a text file or a scrap of paper and then archive or discard them once they’re not immediately relevant to me anymore — let me briefly introduce you to the </strong><a href="https://en.wikipedia.org/wiki/Zettelkasten"><strong>Zettelkasten method</strong></a><strong> for note-taking, my approach for syncing notes between devices, and securely storing them on an offsite Git-repository.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jDmOcJzb_JesI8ab" /><figcaption>Photo by <a href="https://unsplash.com/@qwitka?utm_source=medium&amp;utm_medium=referral">Maksym Kaharlytskyi</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Whenever I’m in the research phase of working on something I tend to write many notes, from todo’s, to links to relevant blogpost, to little tidbits I need to remember — this helps me to organize my thoughts. As soon as I’m done with the particular job though, I move everything to an unorganized archive or simply discard the information, which is fine most of the time. But still, many other times I’ve found myself circling back to a particular subject at a later time and thinking “I definitley remember there being a very helpful blogpost about this subject the last time I researched it”, and then having to Google for it for 20 minutes before finding it again. I figured there’s room for improvement there :)</p><p>So <a href="https://medium.com/@edeckers/building-a-10-shelf-mounted-homelab-rack-587d57e081a7">when I was working on my homelab earlier this year</a>, I decided to look for some tooling to host on it, that could facilitate this wish. In particular I was looking for tooling that could help me connect notes, preferably with an ‘evidence board’-like visualizer, so I can feel like the often most sane characters on TV shows who make those boards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gd4UczzT4OI-WPe7.jpg" /><figcaption>See, perfectly sane. — Still from <a href="https://www.imdb.com/title/tt1290725/">It’s Always Sunny in Philadelphia S4E10</a></figcaption></figure><p>This led me to <a href="https://zettelkasten.de/introduction/">Niklas Luhmann’s Zettelkasten method</a>, which scratched my itch nearly perfectly. Foremost because many other people also happen to find it a very useful approach to note-taking, and therefore a lot of FOSS tooling has been created around it.</p><p>I’m not going to delve too deep into the method here, because there are many resources on it explaining it a lot better than I can in a single blogpost — the page I linked earlier in previous paragraph does a good job for example.</p><p>So, in a nutshell: you write down your thoughts in non-divisible units and string them together as hypertext, forming a web of thoughts. In the days of Luhmann you’d achieve that by using an index card and uniquely identified little scraps of paper that you’d then put in a box with little drawers — one might call it a… <a href="https://de.wikipedia.org/wiki/Zettelkasten"><em>Zettelkasten</em></a><em> — </em>so you could easily retrieve them, but today you simply use tags and hyperlinks in your note-taking tool of choice.</p><h3>My setup</h3><p>Now you’re familiar with what<em> </em>I was hoping to achieve, let’s move on to how I achieved it. Also, this seems like a good time to list the other demands I had aside from simply ‘organizing notes’:</p><ol><li>Must support Markdown</li><li>Must have reasonable Neovim support for note management and searching</li><li>Must be usable on Linux</li><li>Must be usable on Android</li><li>Must be easily syncable between devices</li><li>Must be easily versionable with Git or alike</li><li>Must be transparently encryptable at rest offsite</li></ol><p>Luckily, I was able to find a solution that checks all of these boxes.</p><p><a href="https://github.com/zk-org/zk-nvim"><strong>Zk </strong></a>— A command line application that allows you to create and manage notes. These notes will be stored as a text file with a preconfigured file extension in a directory of choice. In my case I have it generate a Markdown file with a random name containing nothing more than a template that looks like the snippet below.</p><pre>---<br>title: <br>date: &lt;today&gt;<br>tags: []<br>---</pre><p>So whenever I feel like writing a note, I simply run the zkn alias I created for zk new and start writing my thougths in Markdown format in the predefined template. Pretty nice.</p><p><a href="https://github.com/zk-org/zk-nvim"><strong>Zk-Nvim</strong></a> — Supports pretty much all the actions that <strong>Zk</strong> brings, which means you can easily create a new note with preset template, display links and backlinks, follow said links, filter files by tags, and more.</p><p><a href="https://github.com/artempyanykh/marksman"><strong>Marksman</strong></a> — Provides completion, goto definition, find references, rename refactoring, diagnostics, and more in your favorite editor using <a href="https://microsoft.github.io/language-server-protocol/">LSP</a>. In addition to regular Markdown, it also supports wiki-link-style references.</p><p><a href="https://syncthing.net/"><strong>Syncthing</strong></a> — When I’m not on my laptop — don’t worry, just <em>hypothetically </em>— and only have my phone nearby, I still want to be able to take notes. And I don’t want to manually sync the notes between my devices, because I will definitely forget about that. So I setup a Syncthing server that constantly and immediately syncs specified directories between devices whenever they’re connected to my home WiFi, or VPN when I’m outside — again, <em>hypothetical scenario</em>, of course.</p><p>I paired it with both my laptop and my phone — on my laptop I simply run another Syncthing instance to stay in sync and on my Android Phone I use <a href="https://play.google.com/store/apps/details?id=com.github.catfriend1.syncthingandroid">Syncthing-Fork</a>.</p><p><a href="https://obsidian.md/"><strong>Obsidian</strong></a> — This is the app that I use for note-taking on my phone, it supports all the stuff <strong>Zk-Nvim</strong> does and more. It will store your notes as Markdown files in a directory you specify, which you then sync with Syncthing. And not to forget, it includes an <a href="https://help.obsidian.md/Plugins/Graph+view"><em>interactive graph</em></a> of all your notes, which comes pretty close to my ‘evidence board’-fantasy I mentioned earlier!</p><p><a href="https://en.wikipedia.org/wiki/Git"><strong>Git</strong></a> — To version my notes and store them offsite, I use Git with the <a href="https://github.com/spwhitton/git-remote-gcrypt">Git Remote GCrypt remote helper</a>, to push the versioned notes GnuPG-encrypted (AES256) to a private GitHub-repository. So now I have the full version history of all my notes stored offsite, without having to worry about someone breaking into my GitHub account and retrieving all my notes.</p><p><a href="https://emanote.srid.ca/"><strong>Emanote</strong></a><strong> (optional) </strong>— Generate a <em>searchable</em> static website from your notes. I love to use it on my desktop, because even though the <strong>Zk-Nvim</strong> and <strong>Marksman</strong> allow navigation of notes very well, I really like the <a href="https://emanote.srid.ca/guide/html-template/uptree">Uplink trees</a> it creates for your notes.</p><h3>Word of caution</h3><p>I must stress that should you decide to use the setup described above, you <strong><em>please configure somekind of automated, periodic and offsite backup</em></strong>: just one of your devices running Syncthing needs to be compromised and all your notes are lost forever, or only taken hostage for ransom if you’re lucky.</p><p>Syncing with <em>versioned — </em>so files cannot inadvertently or not-so-inadvertently be overwritten<em> — </em><a href="https://docs.aws.amazon.com/cli/latest/reference/s3/sync.html">S3 storage</a>, using a user without delete permissions would be an affordable and pragmatic way to go about that. I like to use <a href="https://duplicity.gitlab.io/">Duplicity</a> for this myself.</p><p>Also, don’t forget that <strong><em>your notes are only encrypted on your remote Git repository — files in your local repository aren’t</em>.</strong> So make sure to take necessary precautions there as well, e.g. use full disk encryption, make sure your network security is in check, etc.</p><h3>Conclusion</h3><p>If you’re looking for a way to up your note-taking game, consider using the approach I described in this post. I’ve been using it for some time now and I’m very happy with it.</p><p>Just make sure to also work on your backup-game, because otherwise there’ll be tears when ransomware hijacks your virtual Zettelkasten.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef47b7736eea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Correlating X-Ray and CloudWatch Logs with OpenTelemetry in Python]]></title>
            <link>https://edeckers.medium.com/correlating-x-ray-and-cloudwatch-logs-with-open-telemetry-in-python-82f50eed0f23?source=rss-635a48996a6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/82f50eed0f23</guid>
            <category><![CDATA[tracing]]></category>
            <category><![CDATA[opentelemetry]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws-xray]]></category>
            <category><![CDATA[logging]]></category>
            <dc:creator><![CDATA[Ely]]></dc:creator>
            <pubDate>Thu, 05 Sep 2024 19:36:00 GMT</pubDate>
            <atom:updated>2024-09-14T13:30:31.525Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Since you ended up on this page, chances are that at this particular moment you feel just as mystified as I did when I got OpenTelemetry (OTel) in Python working with X-Ray, but <em>somehow the CloudWatch logs weren’t linked to my X-Ray traces in the AWS Console, although “the Logs-section is right there, and omg why don’t you correlate already, pls!” — </em>Fear not, I’ve got you covered 🎉</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zE21nfyJ_G91eU1P" /><figcaption>Photo by <a href="https://unsplash.com/@maxberg?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Maxim Berg</a> on <a href="https://unsplash.com/photos/a-colorful-abstract-background-with-wavy-lines-Ac02zYZs22Y?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><p>For this post I presume you already have <a href="https://github.com/open-telemetry/opentelemetry-python">a Python application running on AWS and instrumented it with some<em> </em>OpenTelemetry traces</a> that nicely show up in X-Ray. Whatsmore, you’ve sprinkled some log messages inside your spans and they nicely end up in CloudWatch — great! Now <em>why on earth</em> does the message in the Logs-section of ServiceLens under your X-Ray trace straightup lie and tell you “No logs to display for these resources”?!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s4ufhY_dwVPn8XZU.png" /><figcaption>Screenshot by <a href="https://github.com/nikhil-pandey">@nikhil-pandey</a> on <a href="https://github.com/aws-observability/aws-otel-collector/issues/1766?ref=blog.makerx.com.au#issuecomment-1396506093">GitHub</a></figcaption></figure><p>In a nutshell the problem boils down to either the AWS-XRAY-TRACE-ID missing from the log message, so we need to slap that on every message we send to CloudWatch. Or we didn’t tell X-Ray which logs to scan for the given AWS-XRAY-TRACE-ID. Or very possibly a combination of both.</p><p>So if we’d create an <em>OTel Trace Id to AWS-XRAY-TRACE-ID converter</em> like so:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/15e40341cd08132110845d23ba63cdd3/href">https://medium.com/media/15e40341cd08132110845d23ba63cdd3/href</a></iframe><p>And we were to apply it like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1b22a7476f4e1fa24818ee7826cfe6a2/href">https://medium.com/media/1b22a7476f4e1fa24818ee7826cfe6a2/href</a></iframe><p>In combination with a Resource attribute aws.log.group.names configured like in the snippet below, where config[“x_ray_matching_log_groups”] contains a list of CloudWatch absolute log group names:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0198b192ae13136736f49981595f7ce/href">https://medium.com/media/f0198b192ae13136736f49981595f7ce/href</a></iframe><p>Then your spans in X-Ray would be correlated to the tagged logs, and we’d be done!</p><p>If that’s what you came here for: happy to help, have a nice one! But if you’re looking for a little more sophisticated approach, don’t leave just yet — the following section is for you 😄</p><h3>Combining X-Ray, CloudWatch and Structlog</h3><p>Since I wasn’t too keen on the idea of having to remember to manually add a span-specific AWS-XRAY-TRACE-ID to every log message, I figured that I should somehow be able to <a href="https://www.structlog.org/">harness the capabilities of the Structlog library</a> I was already using, and sure enough I was!</p><p>There were roughly two approaches I was thinking of, both by <a href="https://www.structlog.org/en/stable/processors.html">leveraging the Processors-functionality of Structlog</a>. Approach (1) would be simply adding the custom processor displayed below to the structlog.config(processors=[... statement in my logging bootstrapper, and solution (2) would be the instrumenting the Structlog configuration <em>after </em>bootstrapping.</p><p>I went with the latter, because it seemed less intrusive than the former — plus it fits nicely with <a href="https://opentelemetry-python-contrib.readthedocs.io/en/latest/index.html">all existing instrumentation extensions that are available for the Python OpenTelemetry library</a>. Then again: <em>is it really less intrusive</em> when you implicitly and perhaps unexpectedly overwrite a Structlog configuration from out of nowhere? I’ll leave that up to you — you can still always opt for approach (1), which saves you the 10-ish lines of code of the _prepend_processor as well.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b45313bec1b42e5c8b8c84569bbd3ca/href">https://medium.com/media/4b45313bec1b42e5c8b8c84569bbd3ca/href</a></iframe><h3>In conclusion</h3><p>Although out-of-the-box the official OpenTelemetry Python Sdk doesn’t seem to be fully compatible with X-Ray — the spans show up, but the log messages are not correlated in ServiceLens — I demonstrated in this blog post that with a little help, correlating CloudWatch logs with their respective X-Ray traces works absolutely fine!</p><h3>Relevant posts and acknowledgements</h3><ul><li><a href="https://github.com/aws/aws-xray-sdk-python/issues/188">https://github.com/aws/aws-xray-sdk-python/issues/188</a> problem and solution are pretty much discussed here, but focus is on X-Ray Sdk instead of OTel sdk</li><li><a href="https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/24634#issuecomment-2039421166">https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/24634</a> discussion about the problem in the OTel Python sdk</li><li><a href="https://stackoverflow.com/a/72178525">https://stackoverflow.com/a/72178525</a> probably adapted the _convert_otel_trace_id_to_xray from here, but I’m really not sure anymore</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82f50eed0f23" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a 10" shelf-mounted homelab rack]]></title>
            <link>https://edeckers.medium.com/building-a-10-shelf-mounted-homelab-rack-587d57e081a7?source=rss-635a48996a6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/587d57e081a7</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[patch-panel]]></category>
            <category><![CDATA[homelab]]></category>
            <category><![CDATA[cable-management]]></category>
            <category><![CDATA[diy]]></category>
            <dc:creator><![CDATA[Ely]]></dc:creator>
            <pubDate>Fri, 07 Jun 2024 12:05:44 GMT</pubDate>
            <atom:updated>2024-06-07T12:29:47.357Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Earlier this year I moved into a new place which fortunately is very lovely, but not so fortunately only has a wired Internet connection on the ground floor, with the other two stories being dependent on wifi.</strong></p><blockquote>“Bad signal will never be a thing ‘round these parts”</blockquote><p><strong>Since I’m planning on staying in my new home for at least a couple years, I decided to spend some money on installing a proper wired network and a 10&quot; network rack, so bad signal will never be a thing <em>‘round these parts.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_IQ4f_UHc0LWE1z_P0TEKw.png" /><figcaption>The finished 10&quot; rack, which allows me to manage cables througout my house</figcaption></figure><p>In the center of my house, there’s a small pantry that contains the fuse box and a few shelves. It provides just enough space to store some buckets and a vacuum cleaner.</p><p>Since it’s so central to the house, and very much out-of-sight, it would be the ideal location to tie the entire network together. But because it’s so tiny, I’m not willing to sacrifice any significant storage space.</p><p>I figured that if I could hang a small 10&quot; patch panel from the bottom shelf, instead of a regular-sized — and may I say <em>ginormous —</em> 19“ panel, that would be perfect!</p><blockquote>“The only rack that came close to what I was looking for was 19 inches in size”</blockquote><p>Armed with these parameters I boldy went on my quest for <em>eternal wiredness</em>, but things weren’t as simple as I hoped. Because even though many 10&quot; rack mountable <em>appliances</em> exist, the choice for actual <em>10&quot; racks</em> is surprisingly lacking — I spent a couple hours looking for a suitable rack, but <a href="https://www.amazon.nl/DSIT-4U-Wall-Mount-Bracket/dp/B0CW66CHFP">the only rack that came close to what I was looking for</a> was 19 inches in size. Pity.</p><p>I’ve contemplated several times just throwing the towel and going with a 19&quot; rack instead, even though that would be ridiculous for the space I wanted to mount it in. And I’ve considered buying <a href="https://www.amazon.nl/10-inch-254-rack-stand/dp/B07BP8Q1TH">this desktop mount</a>, even though that didn’t fit my purposes entirely and was pretty expensive. Then I got a bright idea: what if I could shrink the otherwise perfect 19 inch rack to 10 inches?</p><p>So I bought the 3U 19&quot; rack, grabbed my trusty metal saw and removed about 13 inches from the middle of the top bar, and <em>presto</em>: I now got a rack that scales from 6 to infinite inches. Beautiful!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*TiuMLjbflYlO3VS7RRhC4A.png" /><figcaption>Looks a bit … ‘ghetto’ with the saw marks, but I couldn’t be bothered to fix it, since the top of the rack is almost permanently out of sight. Should be easy to avoid these marks when you go a bit gently about shrinking your own rack</figcaption></figure><p>I slapped a <a href="https://www.bol.com/nl/nl/p/10-inch-patch-panel-1u-voor-12-keystone-modules-met-kabelgeleiding-zwart/9300000139431822/">12 keystone modules patch panel</a> in there, a <a href="https://www.bol.com/nl/nl/p/intellinet-714020-10-inch-stekkerdoos-voor-patchkast-incl-2-metalen-houders-voor-10-kasten-aluminium-zwart/9200000084511642/">power strip with four sockets</a> and a <a href="https://www.onlinekabelshop.nl/inline-10-shelf-160mm-10kg-1u-ral-9005-black.html">rack shelf</a> to hold my router and switch. Then I got <a href="https://www.gamma.nl/assortiment/hettich-ladegeleider-type-h-met-kogellagers-250-410-mm-max-10-kg/p/B140279">some drawer guides from the DIY store</a> which I attached to both sides of the rack.</p><p>Eventually I took the entire thing and screwed that under of the bottom shelf in my pantry, and there we have it: a small and simple rack that fits almost anywhere, with easy access for cable management. Cost without keystones is 70-ish euros, which I think makes it pretty affordable as well!</p><h3>A word on cabling</h3><p>Now, the story could have ended here, but I’d like to give other aspiring amateur network aficionados like myself some tips I learned during this endeavour. Tips that would have saved me a couple hours and euros. The most important point being: <em>understand the cable types you’re installing</em> — knowing the CAT-type you need is not enough, because “All CAT6a cables are equal, but some CAT6a are more equal than others”. I hope I reproduced that quote correctly.</p><blockquote>“All CAT6a cables are equal, but some CAT6a are more equal than others” — actual quote from the famous e-book “LAN-farm” by Gorgious Connectwell</blockquote><p>I learned this the hard way when I installed <em>stranded</em> cables in my wall instead of <em>solid</em> ones, which keystones and most other wallmounted terminators don’t attach to particularly well, because they’re built with solid cables in mind. Multiple forums and blogs tell me <a href="https://www.reddit.com/r/HomeNetworking/comments/huv1rp/what_type_of_cat_cable_should_i_get_for_inside/">I’m</a> <a href="https://www.reddit.com/r/HomeNetworking/comments/x7nyqf/is_the_keystone_supposed_to_have_metal_contact/indjqxi/">not</a> <a href="https://forums.anandtech.com/threads/can-stranded-cat5e-cable-be-used-inside-rj45-keystone-jacks.1008383/#post-6914445">the</a> <a href="https://www.reddit.com/r/HomeNetworking/comments/k3nbee/keystone_connectors_not_working/">only</a> <a href="https://www.reddit.com/r/HomeNetworking/comments/huyybq/punching_down_stranded_cat6_how_screwed_am_i/">one</a> making that mistake and then having to replace all their cables, so I figured I would give you a headsup so you can avoid making the same mistake.</p><p>As for U/UTP vs S/FTP et al: you’re probably fine with U/UTP for your home, unless you’re running 10s of cables bundled together. That’s the consensus I find anyway, e.g. <a href="https://www.reddit.com/r/homelab/comments/t5mked/should_i_wire_my_house_with_cat6a_sftp_or_cat6a/">this post on Reddit</a>. Speaking from my own experience, I installed <a href="https://www.kabelshop.nl/Goobay-Netwerkkabel-Cat6a-U-UTP-50-meter-Stugge-kern-100-koper-Eca-LSZH-96092-i9690-t25090.html">three U/UTP cables</a> that run through my crawling space, through walls and a floor, in some places parallel to a couple of PVC-enclosed electrical wires, and everything <em>seems</em> to work just fine when I test for speed and packet loss.</p><p>And finally, you do <em>not ever</em> want to use <a href="https://www.reddit.com/r/HomeNetworking/comments/17y5zk8/why_do_people_hate_copper_clad_aluminum_ethernet/">subpar</a>, <a href="https://www.linkedin.com/pulse/cca-cable-101-all-things-you-should-know-newlinko-cabling/">non-standardized</a>, <a href="https://cablenet.co.uk/news/detail/id/41">quickly degrading</a> and <a href="https://www.truecable.com/blogs/cable-academy/cca-vs-solid-copper">fire hazard prone</a> Copper Clad Aluminum (CCA) cables. Always use 100% copper (CU) cabling instead. In all honesty I don’t speak from personal experience here, but took the many, many warnings I read to heart — I might have fallen victim to a <em>clever ruse</em> by <em>Big Copper</em> though, so don’t take my word for it. Maybe someone with some actual expertise can add some nuance to these criticisms in the comments?</p><h3>In conclusion</h3><p>When you have little space available, and your budget is tight, you might find that a network rack is just not in the cards for your home. But with a little creativity, determination and a metal saw you might turn your luck around :)</p><p>Also, make sure you know the difference in cable types, and install the proper ones: it might save you a lot of time, money and even house fires if I’m to believe the warnings by Internet strangers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=587d57e081a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Provisioning EFS from S3 with CloudFormation]]></title>
            <link>https://edeckers.medium.com/provisioning-efs-from-s3-with-cloudformation-f7afcace80bf?source=rss-635a48996a6b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7afcace80bf</guid>
            <category><![CDATA[ecs-fargate]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[elastic-file-system]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloudformation]]></category>
            <dc:creator><![CDATA[Ely]]></dc:creator>
            <pubDate>Mon, 01 Apr 2024 23:56:26 GMT</pubDate>
            <atom:updated>2024-04-02T12:49:51.673Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Today I worked on a CloudFormation template to deploy an ECS cluster that runs Grafana and Prometheus using their vanilla Docker images. This proved to be more of a hassle than I expected beforehand, so I figured I’d share my results on here — it might benefit somebody else. Or I might learn a thing or two through comments from people who had success with alternative solutions :)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*4kFoL2bmIxNhiDIF" /><figcaption>Photo by <a href="https://unsplash.com/@fletcher_pride?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Fletcher Pride</a> on <a href="https://unsplash.com/photos/shallow-focus-photo-of-rubiks-cubes-liMvhbUq4Xg?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash">Unsplash</a></figcaption></figure><h3>What did I hope to accomplish?</h3><p>Basically I wanted to deploy the stack defined in <a href="https://github.com/Kludex/fastapi-prometheus-grafana">https://github.com/Kludex/fastapi-prometheus-grafana</a> to an AWS Elastic Container Services Cluster — just the Grafana and Prometheus parts even. No problems so far! The Task part of the template looks something like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/05e0753d99082c76f45c37e249e09ca8/href">https://medium.com/media/05e0753d99082c76f45c37e249e09ca8/href</a></iframe><h3>And why did my dreams of accomplishing anything today shatter?</h3><p>But then it took all of two minutes and I got all needy and “this wasn’t good enough for me” and “no way will I live my life a pleb!”. No sir, I wanted data persistence and the ability to tweak the settings of Grafana and Prometheus. Gimme!</p><p>Anyway: we just create an EFS volume, attach it, slap some data on it and call it a day right? Wrong. …well, not <em>wrong</em> exactly, as this is the actual solution I used, but it wasn’t trivial. To me, that is.</p><p>The problem is the chicken-egg situation where the volume will initially be empty, but we don’t want an empty volume, we want a volume with the necessary configs for both Grafana and Prometheus. Because said applications need actual config files or they won’t start.</p><p>Fine! We’ll provision the newly created EFS volume with the desired configurations first. But how do we go about that? There’s no such thing as a ProvisionWithDataFromLocalPath-setting on AWS::EFS::FileSystem or AWS::EFS::MountTarget which would work as advertised on the tin. Nor did I find ‘this is the way!’ documentation or forum posts — Let’s ignore for the sake of this blogpost that this usually means you’re doing something you aren’t supposed to be doing :)</p><h3>So, how did I eventually manage to accomplish something nonetheless?</h3><p>Eventually I ended up creating and deploying two separate CloudFormation stacks. The first one is nothing more than a definition of a dedicated S3 bucket that hosts the initial directory structure and files for the empty EFS. And the second stack still contains the definitions of the actual monitoring resources, such as Grafana and Prometheus. Although I had to expand it a little with a few AWS::EFS::AccessPoint and a AWS::ECS::ContainerDefinition running amazon/aws-cli.</p><p>This helped me to tackle the problem by following these steps:</p><ol><li>Deploy an S3-bucket branie-monitoring-config using aws cloudformation deploy --template-file branie-monitoring-config-s3.cfn.yml (...)</li><li>Use aws s3 sync /path/to/local/initial/data s3://branie-monitoring-config to send the desired initial data structure to the dedicated S3 bucket</li><li>Add a non-essential amazon/aws-clicontainer to your Task, to which you attache the EFS volume, so you can sync the S3 data by providing the Command [“s3&quot;, &quot;sync&quot;, &quot;s3://branie-mon-configs&quot;, &quot;/mnt/preparable&quot;]</li><li>Deploy the stack containing the task using aws cloudformation deploy --template-file branie-monitoring.cfn.yml (...)</li></ol><p>And that’s basically it! But make sure you use AWS::EFS::AccessPoints for each of the MountPoints in your containers though. You can’t just attach the same volume multiple times with a different RootDirectory , because then you still run into the chicken-egg situation where the required directories don’t exist on the volume yet and that will crash the deployment <em>only after some time</em> with an NFS error. Ask me how I know.</p><p>The final result would look something like:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c32d306af9a0d11e2cc64f0729089896/href">https://medium.com/media/c32d306af9a0d11e2cc64f0729089896/href</a></iframe><h3>Are there more roads to accomplishment?</h3><p>Another obvious solution to achieve my goal would have been to roll my own Docker-images / ECR based on the vanilla Grafana and Prometheus images, containing their respective configurations.</p><p>To be honest, this doesn’t sound like the worst idea, and maybe it’s even the intended way to go about this problem. But I felt like that would strip away some of my flexibility and add extra maintenance compared to the solution I’m presenting in this blogpost.</p><h3>In conclusion, what did we accomplish?</h3><p>There you have it, a way to host your Grafana and Prometheus instances on ECS with persistence and configurability.</p><p>Is it the most elegant or desirable solution? I’m not sure, I hope to hear your thoughts on that. But for now, it does solve the situation I am dealing with, and hopefully it will help somebody else reading this!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7afcace80bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>