Try setting up GAE on GCP with terraform

Development

I decided to use terraform at work, so I started up a terraform environment to study it myself.

This time, I will use terraform to set up GAE on GCP.

Installing CloudSDK

CloudSDK is a necessary tool to use GCP's gcloud command.I think that's fine.

Even if you want to manipulate GCP resources with terraform, you can't do it without this tool.

Google documentationInstall the required tools according to the instructions.

Download the package, unzip the tar file, and run the installation shell in the google-cloud-sdk directory.

tar -zxvf ~/Downloads/google-cloud-sdk-370.0.0-darwin-arm.tar.gz # Unzip the downloaded file./google-cloud-sdk/install.sh # Run shell

Authentication for gcloud commands

After that, pass the authentication using the gloud command. When you run the following command, the browser will display a Google account authorization screen.

gcloud auth application-default login

Create main.tf

Then, create the following main.tf in the terraform root directory (this is the beginning, so any directory is fine as long as it's empty). (reference)

terraform { required_providers { google = { source = "hashicorp/google" } } } provider "google" { project = var.project region = "asia-northeast1" } resource "google_project" "test_project" { name = "test" // A project with this name will be launched project_id = "test-project-id1" // The project ID with this name (numbers, hyphens, and lowercase letters are required) is the same as above} resource "google_app_engine_application" "app" { project = google_project.test_project.project_id location_id = "asia-northeast1" } variable "project" { type = string }

Finally, run terraform. During apply, you will be asked if you are OK with the settings, so enter yes if you are OK with this.

terraform init terraform fmt terraform plan terraform apply

When I checked GCP on the browser side, I was able to confirm that it was running.

summary

This time, I tried launching GAE using terraform on GCP.

Next time, I will install Google's server-side GTM on top of this.

わたろー
Wataro

It's not a big deal once you do it, but there were some parts that were difficult to understand at first...

Quickstart: Install the Google Cloud CLI | Google Cloud CLI Documentation

comment

Copied title and URL