forked from mrjgreen/aws-docker-swarm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
85 lines (68 loc) · 2.5 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
provider "aws" {
#allowed_account_ids = ["${var.account_id}"]
max_retries = 5
region = "${var.region}"
}
data "aws_availability_zones" "available" {}
module "ami" {
source = "./modules/ami/amazon"
}
module "vpc" {
source = "./modules/vpc/public-only"
name = "${ var.application }-main-vpc"
application = "${ var.application }"
provisionersrc = "${ var.provisionersrc }"
azs = "${ data.aws_availability_zones.available.names }"
cidr = "${ var.vpc_cidr_block }"
}
module "s3-vpc-endpoint" {
source = "./modules/vpc/s3-endpoint"
vpc_id = "${module.vpc.id}"
region = "${var.region}"
route_table_ids = ["${module.vpc.route-table-id-main}"]
}
module "manager" {
source = "./modules/swarm-manager"
name = "${ var.application }-swarm-manager"
application = "${ var.application }"
provisionersrc = "${ var.provisionersrc }"
ami-id = "${ module.ami.image_id }"
key-name = "${ var.key_name }"
size = "${var.swarm_manager_count}"
volume_size = "${var.volume_size}"
instance-type = "${ var.instance_type }"
security-group-ids = ["${ aws_security_group.app.id }"]
subnet-ids = ["${ module.vpc.subnet-ids-public }"]
vpc-id = "${ module.vpc.id }"
}
module "worker" {
source = "./modules/swarm-worker"
name = "${ var.application }-swarm-worker"
application = "${ var.application }"
provisionersrc = "${ var.provisionersrc }"
ami-id = "${ module.ami.image_id }"
key-name = "${ var.key_name }"
size = "${var.swarm_worker_count}"
volume_size = "${var.volume_size}"
instance-type = "${ var.instance_type }"
security-group-ids = ["${ aws_security_group.app.id }"]
subnet-ids = ["${ module.vpc.subnet-ids-public }"]
vpc-id = "${ module.vpc.id }"
swarm-security-group-id = "${ module.manager.swarm-security-group-id }"
discovery-bucket = "${ module.manager.discovery-bucket }"
}
# Use autoscaling lifecycle rules to fire a lambda
# to update our DNS record
module "manager-auto-dns" {
source = "./modules/asg-lifecycle-lambda-update-dns"
name = "${ var.application }-swarm-manager-asg-dns"
application = "${ var.application }"
provisionersrc = "${ var.provisionersrc }"
group_names = ["${ module.manager.autoscaling-group-name }"]
zone_id = "${var.route53_zone_id}"
record = {
ttl = 300
name = "${var.domain}"
type = "A"
}
}