-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
62 lines (51 loc) · 1.3 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
56
57
58
59
60
61
62
provider "aws" {
region = "${var.region}"
profile = "${var.profile}"
}
resource "aws_key_pair" "gocd_instance_keypair" {
key_name = "instance_keypair"
public_key = "${file("${path.module}/ssh/instance_keypair.pub")}"
}
resource "aws_route53_record" "build_server_record" {
zone_id = "${data.aws_route53_zone.route_53_zone.id}"
name = "build.teleimpact.io"
type = "A"
alias {
evaluate_target_health = true
name = "${aws_lb.gocd_lb.dns_name}"
zone_id = "${aws_lb.gocd_lb.zone_id}"
}
}
resource "aws_instance" "gocd_instance" {
ami = "${data.aws_ami.ubuntu.id}"
instance_type = "${var.ec2_instance_size}"
key_name = "${aws_key_pair.gocd_instance_keypair.key_name}"
tags {
Name = "GoCDServer"
}
connection {
type = "ssh"
user = "ubuntu"
private_key = "${file("${path.module}/ssh/instance_keypair")}"
}
provisioner "file" {
destination = "/tmp/setup-docker.sh"
source = "./scripts/setup-docker.sh"
}
provisioner "file" {
destination = "/tmp/setup-gocd.sh"
source = "./scripts/setup-gocd.sh"
}
provisioner "remote-exec" {
inline = [
"chmod +x /tmp/setup-docker.sh",
"/tmp/setup-docker.sh"
]
}
provisioner "remote-exec" {
inline = [
"chmod +x /tmp/setup-gocd.sh",
"/tmp/setup-gocd.sh"
]
}
}