-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
55 lines (43 loc) · 1.17 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
module "container-server" {
source = "../.."
domain = "app.${var.domain}"
container = {
image = "nginxdemos/hello"
}
}
/* Instance ----------------------------------------------------------------- */
resource "google_compute_instance" "app" {
name = "app"
project = var.project
zone = "${var.region}-a"
machine_type = "e2-small"
tags = ["ssh", "http-server", "https-server"]
metadata = {
user-data = module.container-server.cloud_config
}
boot_disk {
initialize_params {
image = data.google_compute_image.cos.self_link
}
}
network_interface {
subnetwork = var.subnet_name
subnetwork_project = var.project
access_config {
// Ephemeral IP
}
}
}
data "google_compute_image" "cos" {
project = "cos-cloud"
family = "cos-81-lts"
}
/* DNS ---------------------------------------------------------------------- */
resource "google_dns_record_set" "app" {
project = var.project
name = "app.${var.domain}."
managed_zone = var.cloud_dns_zone
type = "A"
ttl = 300
rrdatas = [google_compute_instance.app.network_interface[0].access_config[0].nat_ip]
}