forked from rohit9211/gcp-terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
instance-bastion.tf
60 lines (49 loc) · 1.82 KB
/
instance-bastion.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
resource "template_file" "bastion-write_files" {
template = "${file("config/write_files/bastion.yml")}"
}
resource "template_file" "bastion-units" {
template = "${file("config/units/bastion.yml")}"
}
module "bastion-coreos-user-data" {
source = "git::https://github.com/brandfolder/terraform-coreos-user-data.git?ref=master"
etcd2_discovery = "${var.etcd_discovery_url}"
etcd2_listen-client-urls = "http://0.0.0.0:2379,http://0.0.0.0:4001"
etcd2_proxy = "on"
flannel_interface = "var!private_ipv4"
fleet_metadata = "role=bastion"
fleet_public_ip = "var!private_ipv4"
fleet_engine_reconcile_interval = "10"
fleet_etcd_request_timeout = "5.0"
fleet_agent_ttl = "120s"
write_files = "${template_file.bastion-write_files.rendered}"
units = "${template_file.bastion-units.rendered}"
}
resource "google_compute_instance" "bastion" {
name = "${replace("${var.prefix}-bastion", "/^-/", "")}"
description = "Bastion host"
zone = "${element(split(",", var.zones), 0)}"
tags = ["bastion"]
machine_type = "${coalesce(var.bastion-instance-type, var.default-instance-type)}"
scheduling {
automatic_restart = true
on_host_maintenance = "MIGRATE"
}
disk {
type = "pd-ssd"
auto_delete = true
size = 50
image = "${coalesce(var.bastion-image, var.default-image)}"
}
network_interface {
subnetwork = "${element(google_compute_subnetwork.primary.*.name, 0)}"
access_config {
// Ephemeral IP
}
}
metadata {
user-data = "${module.bastion-coreos-user-data.user-data}"
}
service_account {
scopes = ["userinfo-email", "compute-ro", "storage-ro"]
}
}