Welcome to my encyclopedia of shitty code!
-
Terraform: Handling Errors with try(…)
PROBLEM Given the following output block:- Sometimes, during an apply or destroy, we may get this error:- One way to fix this is to do conditional expressions like this, but it’s not pretty:- SOLUTION Since Terraform v0.12.20, we can solve this with try and achieve the same outcome:- Read More…
-
GCP: Deleting Project with Lien… Quickly
PROBLEM The whole idea of placing a lien on a project is to prevent accidental deletion. But, sometimes it’s a little pain in the ass to attempt a project deletion in GCP Console only to find out a lien was set, especially during the development phase. Then, we grumpily open up Cloud Shell and run… Read More…
-
Terraform: Skipping Buggy Provider Version
PROBLEM Given the following required_providers block… … it will allow the following Google provider version: >= 3.8, < 4.0. As of today (May 10), the latest Google provider is 3.20.0. A quick terraform init confirms that. However, sometimes, there’s a need to skip a buggy version. For example, 3.20.0 breaks google_compute_firewall. SOLUTION To achieve that,… Read More…
-
GCP + Terraform: Running Terraform Commands with a Service Account
PROBLEM When running these commands… … it allows terraform apply to provision the infrastructure using your credential. However, sometimes there’s a need to run Terraform using a service account. SOLUTION First, identify the service account you want to use… for example: [email protected]. Then, create and download the private key for the service account. Command: Output:… Read More…
-
GCP + Kitchen Terraform: Local Development Workflow
INTRODUCTION Here’s a typical workflow for implementing and running Kitchen Terraform tests outside of the GCP environment, for example, from an IDE on a Mac laptop. Enable “gcloud” Access Command: The first step is to ensure we can interact with GCP using the gcloud command using our user credential. This is needed because the tests… Read More…
-
Git: Configuring Different Git User Info Depending on Projects
PROBLEM Given, the following global config stored under ~/.gitconfig… When committing any code, the above user info will always be used. However, there are times you want to use a different user info depending on projects (ex: work projects, GitHub projects, etc) SOLUTION This is one of many ways to solve this problem. Let’s assume… Read More…
-
Terragrunt: “plan-all” while Passing Outputs between Modules
PROBLEM Terragrunt has a feature that allows one module to pass outputs to another module. For example, if “project-prod” module wants to consume “subfolders” output from “folder” module, it can be done like this in “project-prod” module’s terragrunt.hcl:- The challenge is when running commands such as plan-all, it will fail with the following error:- SOLUTION… Read More…
-
GCP + Terraform: “google: could not find default credentials” Error
PROBLEM When running any Terraform commands (init, plan, etc) from a different server, the following error is thrown:- SOLUTION One recommended way is to set up a service account by following the instruction from the above link. Another way, for developement purpose, is to install Google Cloud SDK and run the following gcloud command, which… Read More…
-
Terraform: “Error acquiring the state lock” Error
PROBLEM When running terraform plan, the following error is thrown:- SOLUTION One way is to disable locking by passing -lock=false flag. However, if you are sure the lock isn’t properly released, to perform a force unlock, run this command: In this case… Read More…
About Author
This author has 20+ years of experience in software engineering and cloud engineering. In an industry where knowledge becomes obsolete in the next three months, he learns anything that crosses his path indiscriminately. He floats from one technology to another like a moth and stings the problem sets like a mosquito. This author codes Java while drinking Espresso and writes Spock specifications while listening to Groovy beats. He masters Google Cloud Platform just like how he masters the art of predicting the movement of dark clouds over his backyard, where 60% of the time, he is right every time.
This author suffers from the Dunning-Kruger effect, where he overestimates his competence and underestimates his ignorance. Technology buzzwords never faze him, for he does not know enough to be afraid of in the first place. GCP, GCS, GCR, GKE, GWT… everything sounds the same to him. He never fears acronyms, synonyms, or antonyms, for he has ChatGPT in his back pocket. This author is a jack of all trades but a master of none. He writes like he knows all the answers, yet he googles for better solutions from elsewhere. He fakes it until he makes it; if he doesn’t, that’s okay because he has the attention span of a squirrel. The blog posts are his buried walnuts, in case he needs them one day.
In conclusion, this author is full of something. He apologizes in advance if you are trying to solve your company’s real problems with his shitty solutions. There, he has successfully written paragraphs of nonsense because every professional blogging website needs a section about the author, with a too-cool-to-smile portrait staring sideways into the abyss.