Provision a Compute Engine Instance in GCP
In the "Code Editor" tab, edit the following files:
variables.tf: Define input variablesproject_id(string, no default),region(string, default:us-central1),vm_name(string, default:my-vm), andmachine_type(string, default:e2-micro), each with appropriate descriptions.outputs.tf: Define outputsvm_instance_name(VM name) andvm_external_ip(VM external IP).main.tf: Configure a Compute Engine VM using the defined variables, with thedebian-cloud/debian-11image, connected to the default VPC network.terraform.tfvars: Setproject_id = "my-gcp-project".
The provider.tf file is pre-configured and read-only.
GitOps Repository
- 📁 /root/learn-terraform-gcp-compute-engine
- 📄 provider.tf
- 📄 main.tf
- 📄 variables.tf
- 📄 outputs.tf
- 📄 terraform.tfvars