-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
29 lines (24 loc) · 881 Bytes
/
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
#######################################################################
## a VM on GCP to serve as the origin webserver
#######################################################################
resource "google_compute_instance" "demo_origin_instance" {
name = "${var.site_name}-origin"
machine_type = "n2-standard-8"
zone = "us-west1-a"
tags = ["https-server"]
boot_disk {
initialize_params {
image = "ubuntu-os-cloud/ubuntu-2310-amd64"
}
}
# give it a public IP
network_interface {
network = "default"
access_config {}
}
metadata = {
ssh-keys = "ubuntu:${file("${var.ssh_pub_key}")}"
}
# configure a minmial secure webserver
metadata_startup_script = "apt update && apt -y upgrade && apt -y install apache2 && a2enmod ssl && a2ensite default-ssl && a2dissite 000-default && service apache2 restart"
}