File tree Expand file tree Collapse file tree 3 files changed +56
-6
lines changed Expand file tree Collapse file tree 3 files changed +56
-6
lines changed Original file line number Diff line number Diff line change
1
+ # First Tutorial
2
+
3
+ ## First step
4
+
5
+ Hello World
6
+
7
+ ### Part 1
8
+
9
+ Part One Instructions.
10
+
11
+ ```
12
+ terraform init
13
+ ```
14
+
15
+ ```
16
+ terraform plan
17
+ ```
18
+
19
+ ```
20
+ terraform apply
21
+ ```
22
+
23
+ ### Part 2
24
+
25
+ Part Two Instructions.
26
+
27
+ ## Conclusion
28
+
29
+ Done!
Original file line number Diff line number Diff line change 1
1
provider "google" {
2
- # project = "{{YOUR GCP PROJECT}} "
2
+ project = " my-google-cloud-project "
3
3
region = " us-central1"
4
4
zone = " us-central1-c"
5
5
}
@@ -8,7 +8,7 @@ resource "google_compute_instance" "vm_instance" {
8
8
name = " terraform-instance"
9
9
machine_type = " f1-micro"
10
10
11
- labels {
11
+ labels = {
12
12
billing_department = " education"
13
13
}
14
14
@@ -20,17 +20,34 @@ resource "google_compute_instance" "vm_instance" {
20
20
21
21
network_interface {
22
22
# A default network is created for all GCP projects
23
- network = " ${ google_compute_network . vpc_network . self_link } "
24
- access_config = {
23
+ network = google_compute_network. vpc_network . self_link
24
+ access_config {
25
25
}
26
26
}
27
+
28
+ metadata_startup_script = " echo 'Hello Terraform on GCP!' > index.html; python -m SimpleHTTPServer 9000 &"
27
29
}
28
30
29
31
resource "google_compute_network" "vpc_network" {
30
32
name = " terraform-network"
31
33
auto_create_subnetworks = " true"
32
34
}
33
35
34
- output "network_ip" {
35
- value = " ${ google_compute_instance . vm_instance . network_interface . 0 . network_ip } "
36
+ resource "google_compute_firewall" "default" {
37
+ name = " terraform-firewall"
38
+ network = google_compute_network. vpc_network . self_link
39
+
40
+ allow {
41
+ protocol = " tcp"
42
+ ports = [" 9000" ]
43
+ }
44
+ }
45
+
46
+ output "private_ip" {
47
+ value = google_compute_instance. vm_instance . network_interface [0 ]. network_ip
48
+ }
49
+
50
+ output "website_url" {
51
+ value = " http://${ google_compute_instance . vm_instance . network_interface [0 ]. access_config [0 ]. nat_ip } :9000"
36
52
}
53
+
Original file line number Diff line number Diff line change
1
+
2
+ terraform {
3
+ required_version = " >= 0.12"
4
+ }
You can’t perform that action at this time.
0 commit comments