Category: Programming Language
-
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…
-
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…