Skip to content

Commit e605544

Browse files
authored
Update README.md
1 parent 141fc14 commit e605544

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,75 @@ variable "project_id" {
3737
}
3838
```
3939
Add 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+
```

0 commit comments

Comments
 (0)