This repository has been archived by the owner on Feb 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
tmate-production.tf
97 lines (81 loc) · 2.3 KB
/
tmate-production.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#
# DNS
#
resource "aws_route53_record" "tmate-edge-production" {
zone_id = "${var.external_zone_id}"
name = "tmate.travisci.net"
type = "A"
ttl = "300"
records = [
"${google_compute_address.tmate-edge-production-ip.address}",
"${aws_eip.tmate-production-ip.public_ip}"
]
}
resource "aws_route53_record" "tmate-edge-production-gce" {
zone_id = "${var.external_zone_id}"
name = "tmate-gce.travisci.net"
type = "A"
ttl = "300"
records = ["${google_compute_address.tmate-edge-production-ip.address}"]
}
resource "aws_route53_record" "tmate-edge-production-aws" {
zone_id = "${var.external_zone_id}"
name = "tmate-aws.travisci.net"
type = "A"
ttl = "300"
records = ["${aws_eip.tmate-production-ip.public_ip}"]
}
#
# GCE
#
resource "google_compute_instance" "tmate-edge-production" {
count = 1
name = "tmate-edge-production"
machine_type = "${var.tmate_gce_machine_type}"
zone = "us-central1-b"
tags = ["tmate-edge"]
disk {
auto_delete = true
image = "${atlas_artifact.tmate-edge-gce-image.metadata_full.project_id}/${atlas_artifact.tmate-edge-gce-image.metadata_full.name}"
type = "pd-standard"
}
network_interface {
network = "default"
access_config {
nat_ip = "${google_compute_address.tmate-edge-production-ip.address}"
}
}
metadata_startup_script = <<EOT
#!/usr/bin/env bash
echo 127.0.1.1 tmate-gce.travisci.net tmate-gce >> /etc/hosts
hostname tmate-gce
${file(format("cloud-init/travis-tmate-edge-production"))}
EOT
}
resource "google_compute_address" "tmate-edge-production-ip" {
name = "tmate-edge-production-ip"
region = "us-central1"
}
#
# AWS
#
resource "aws_instance" "tmate-edge-aws-production" {
ami = "${atlas_artifact.tmate-edge-aws-image.metadata_full.ami_id}"
instance_type = "${var.tmate_aws_machine_type}"
tags {
Name = "tmate-edge-production"
}
availability_zone = "${var.aws_public_subnet_az}"
subnet_id = "${var.aws_public_subnet_id}"
vpc_security_group_ids = ["${aws_security_group.tmate-edge.id}"]
user_data = <<EOT
#!/usr/bin/env bash
echo 127.0.1.1 tmate-aws.travisci.net tmate-aws >> /etc/hosts
hostname tmate-aws
${file(format("cloud-init/travis-tmate-edge-production"))}
EOT
}
resource "aws_eip" "tmate-production-ip" {
instance = "${aws_instance.tmate-edge-aws-production.id}"
vpc = true
}