Remove a resource from the Terraform state

Sometimes you’re working on a codebase new to you and terraform destroy fails with a weird error like: 1 2 3 4 5 6 7 8 ╷ │ Error: Get "http://localhost/api/v1/namespaces/kube-public/configmaps/local-registry-hosting": dial tcp [::1]:80: connect: connection refused │ │ with kubernetes_config_map.registry, │ on main.tf line 97, in resource "kubernetes_config_map" "registry": │ 97: resource "kubernetes_config_map" "registry" { │ ╵ This is probably an edge case in the kubernetes_config_map combined with EKS. You should fix the root cause, but if it’s late and all you want is tear down the test EKS cluster, you can remove the offending configmap from the state: ...

July 7, 2025 · 1 min · 161 words · Maurizio Branca

How to build Go containers

I used Docker to containerize projects like Bender and my custom OTel Collector. However, after glancing at one of the projects my teammates were working on, I decided to take a look at ko. Oh my gosh! Ko is such a magnificent tool! It brings the simplicity, efficiency, and fun of Go to containerization. If you need to build a container for your Go app, stop searching and start using ko. To build a container, you don’t need Docker. Pick your favorite registry, for example, the GitHub Container Registry, and: ...

February 17, 2025 · 1 min · 187 words · Maurizio Branca

How to inspect a GitHub token

Sometimes, you stumble upon a GitHub token that you don’t know where it’s coming from or to whom it belongs. Here’s how to discover the owner: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 export GITHUB_TOKEN="<your GitHub token goes here>" $ curl -H "Authorization: bearer ${GITHUB_TOKEN}" https://api.github.com/user { "login": "zmoog", "id": 25941, "avatar_url": "https://avatars.githubusercontent.com/u/25941?v=4", "gravatar_id": "", "url": "https://api.github.com/users/zmoog", "html_url": "https://github.com/zmoog", "followers_url": "https://api.github.com/users/zmoog/followers", "following_url": "https://api.github.com/users/zmoog/following{/other_user}", "gists_url": "https://api.github.com/users/zmoog/gists{/gist_id}", "starred_url": "https://api.github.com/users/zmoog/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/zmoog/subscriptions", "organizations_url": "https://api.github.com/users/zmoog/orgs", "repos_url": "https://api.github.com/users/zmoog/repos", "events_url": "https://api.github.com/users/zmoog/events{/privacy}", "received_events_url": "https://api.github.com/users/zmoog/received_events", "type": "User", "user_view_type": "public", "site_admin": false, "name": "Maurizio Branca", "company": "Elastic", "blog": "https://zmoog.dev", "location": "Verolengo, Turin, Italy", "hireable": null, "bio": "I'm a software engineer from Italy. Passionate about programming, video games, bots, and note-taking.", "twitter_username": null, "notification_email": "maurizio.branca@gmail.com", "public_repos": 102, "public_gists": 9, "followers": 36, "following": 35, "created_at": "2008-09-23T17:16:36Z", "updated_at": "2025-02-13T11:31:19Z" }

February 16, 2025 · 1 min · 158 words · Maurizio Branca

Sort values as version numbers using the sort command

Earlier today, I was listing the releases in a GitHub repo: 1 2 3 4 5 6 7 8 9 10 11 $ gh release list --limit 10 | awk -F ' ' '{print $2}' 8.12.2 8.12.1 7.17.18 7.17.17 8.12.0 8.11.4 8.11.3 7.17.16 8.11.2 7.17.15 The GitHub CLI returns the release in chronologica order, which makes perfercly sense for releases. However, I needed them version order, so I tried my old friend sort: ...

March 8, 2024 · 2 min · 245 words · Maurizio Branca

Install a custom integration package into a cluster on Elastic Cloud

I need to install a development version of an integration package into a cluster running on Elastic Cloud. Build Build the package using elastic-package and copy the .zip file in a safe place: 1 2 3 4 5 6 7 8 9 10 11 12 # # If you don't already have it, clone the Elastic Agent # integrations repo: # # git clone git@github.com:elastic/integrations.git # cd packages/kubernetes elastic-package build cp ../../build/packages/kubernetes-1.44.0.zip /somewhere/safe/ Deploy Set up the required environment variables: ...

January 19, 2024 · 1 min · 161 words · Maurizio Branca

How to replace an external Go dependency with a local copy

The Problem You’re using a great open source library in your project, and then, one day, you find yourself thinking: “Oh, wouldn’t be great if the author just added a tiny little log statement in that function?”. Yeah, it really would, this would allow me to trace the value of that variable or try a small change. What can you do: fork the library? Nope. Don’t do that. Replace it! You can temporarily replace the original module with a local copy, changing one line in your go.mod file. ...

February 5, 2021 · 2 min · 220 words · Maurizio Branca