My Shitty Code

Embracing the Messiness in Search of Epic Solutions

Category: Cloud

  • GCP Stackdriver Agent: “write_gcm: can not take infinite value” Error

    PROBLEM When running the stackdriver-agent (v6.x), the log file contains the following errors:- SOLUTION By default, the swap metric is enabled. To verify, go to /etc/stackdriver/collectd.conf and locate the following configuration:- This error occurs because the VM instance does not have swap memory, hence this metric plugin tries to divide by 0. To verify the […]

  • 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 […]

  • 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, […]

  • 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: […]

  • 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 […]

  • 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 […]