-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
75 lines (63 loc) · 1.91 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
provider "google" {
}
resource "random_id" "suffix" {
byte_length = 4
}
terraform {
backend "gcs" {
bucket = "tfstate-bucket-demo-249805"
}
}
#resource "google_project" "project" {
# name = "tf-demo-${random_id.suffix.hex}"
# project_id = "tf-demo-${random_id.suffix.hex}"
# org_id = "${var.org}"
# billing_account = "${var.billacc}"
# auto_create_network = false
#}
resource "google_compute_instance" "tf_test_vm" {
name = "tf-test-vm"
project = "${var.project-id}"
machine_type = "n1-standard-1"
zone = "${var.zone}"
boot_disk {
initialize_params {
image = "debian-cloud/debian-9"
}
}
metadata_startup_script = "echo 'Created by Terraform' > /test.txt"
network_interface {
subnetwork = "${google_compute_subnetwork.tf_subnet.self_link}"
}
}
resource "google_compute_network" "tf_network" {
name = "tf-network"
project = "${var.project-id}"
auto_create_subnetworks = "false"
}
resource "google_compute_subnetwork" "tf_subnet" {
name = "tf-subnet"
ip_cidr_range = "10.2.0.0/24"
network = "${google_compute_network.tf_network.name}"
project = "${var.project-id}"
region = "${var.region}"
}
resource "google_storage_bucket" "tf_test_bucket" {
name = "tf-bucket-1-${random_id.suffix.hex}"
location = "${var.region}"
storage_class = "REGIONAL"
project = "${var.project-id}"
}
resource "google_storage_bucket" "tf_test_bucket_2" {
name = "tf-bucket-2-${random_id.suffix.hex}"
location = "${var.region}"
storage_class = "REGIONAL"
project = "${var.project-id}"
}
#module demo
module "container-vm" {
source = "./instance"
instance_name = "sgp-container-vm"
instance_zone = "asia-southeast1-c"
instance_subnetwork = google_compute_subnetwork.tf_subnet.self_link
}