Files
zabbix-server/main.tf
Vassiliy Yegorov 14e6ae1973 - move scripts from folder to git-repo
- install script manual only
2019-07-13 11:10:56 +07:00

69 lines
1.4 KiB
HCL

#===============================================
# Create firefall for all
#===============================================
resource "google_compute_firewall" "firewall_vpn" {
name = "allow-zabbix"
# name of net
network = "default"
allow {
protocol = "tcp"
ports = [
"443", "80", "10050"
]
}
source_ranges = ["0.0.0.0/0"]
target_tags = ["${var.zabbix_tag}"]
}
#===============================================
# Create zabbix server
#===============================================
resource "google_compute_instance" "zabbix" {
name = "app-zabbix"
machine_type = "g1-small"
zone = "${var.zone_instance}"
tags = ["${var.zabbix_tag}"]
# add image disk
boot_disk {
initialize_params {
image = var.disk_image
}
}
# add network
network_interface {
network = "default"
access_config {
}
}
# ssh_key
metadata = {
sshKeys = "${var.default_user}:${file("~/.ssh/id_rsa.pub")}"
}
connection {
host = self.network_interface.0.access_config.0.nat_ip
type = "ssh"
user = "${var.default_user}"
private_key = "${file("~/.ssh/id_rsa")}"
}
provisioner "file" {
source = "scripts/setupzabbix.sh"
destination = "~/setupzabbix.sh"
}
# provisioner "remote-exec" {
# inline = ["${file("scripts/setupzabbix.sh")}"]
# }
provisioner "file" {
source = "scripts/zabconf"
destination = "~/"
}
}