File tree Expand file tree Collapse file tree 1 file changed +72
-0
lines changed Expand file tree Collapse file tree 1 file changed +72
-0
lines changed Original file line number Diff line number Diff line change @@ -37,3 +37,75 @@ variable "project_id" {
3737}
3838```
3939Add the following to the _ main.tf_ file:
40+ ```
41+ terraform {
42+ required_providers {
43+ google = {
44+ source = "hashicorp/google"
45+ version = "3.55.0"
46+ }
47+ }
48+ }
49+
50+ provider "google" {
51+ project = var.project_id
52+ region = var.region
53+ zone = var.zone
54+ }
55+
56+
57+ module "instances" {
58+ source = "./modules/instances"
59+ }
60+ ```
61+ Run "_ terraform init_ " in Cloud Shell in the root directory to initialize terraform.
62+ ```
63+ terraform init
64+ ```
65+ TASK 1: Import infrastructure <br />
66+ Navigate to _ Compute Engine > VM Instances_ . Click on _ tf-instance-1_ . Copy the _ Instance ID_ down somewhere to use later. <br />
67+ Navigate to _ Compute Engine > VM Instances_ . Click on _ tf-instance-2_ . Copy the _ Instance ID_ down somewhere to use later. <br />
68+ Next, navigate to _ modules/instances/instances.tf_ . Copy the following configuration into the file:
69+ ```
70+ resource "google_compute_instance" "tf-instance-1" {
71+ name = "tf-instance-1"
72+ machine_type = "n1-standard-1"
73+
74+ boot_disk {
75+ initialize_params {
76+ image = "debian-cloud/debian-10"
77+ }
78+ }
79+
80+ network_interface {
81+ network = "default"
82+ }
83+
84+ metadata_startup_script = <<-EOT
85+ #!/bin/bash
86+ EOT
87+
88+ allow_stopping_for_update = true
89+ }
90+
91+ resource "google_compute_instance" "tf-instance-2" {
92+ name = "tf-instance-2"
93+ machine_type = "n1-standard-1"
94+
95+ boot_disk {
96+ initialize_params {
97+ image = "debian-cloud/debian-10"
98+ }
99+ }
100+
101+ network_interface {
102+ network = "default"
103+ }
104+
105+ metadata_startup_script = <<-EOT
106+ #!/bin/bash
107+ EOT
108+
109+ allow_stopping_for_update = true
110+ }
111+ ```
You can’t perform that action at this time.
0 commit comments