-
Notifications
You must be signed in to change notification settings - Fork 31
/
ecs-service-discovery.tf
58 lines (46 loc) · 1.38 KB
/
ecs-service-discovery.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
/**
* Copyright (C) 2018-2020 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
resource "aws_service_discovery_private_dns_namespace" "apiary" {
count = var.hms_instance_type == "ecs" ? 1 : 0
name = "${local.instance_alias}-${var.aws_region}.${var.ecs_domain_extension}"
vpc = var.vpc_id
}
resource "aws_service_discovery_service" "hms_readwrite" {
count = var.hms_instance_type == "ecs" ? 1 : 0
name = "hms-readwrite"
dns_config {
namespace_id = aws_service_discovery_private_dns_namespace.apiary[0].id
dns_records {
ttl = 10
type = "A"
}
routing_policy = "MULTIVALUE"
}
health_check_custom_config {
failure_threshold = 1
}
}
resource "aws_service_discovery_service" "hms_readonly" {
count = var.hms_instance_type == "ecs" ? 1 : 0
name = "hms-readonly"
dns_config {
namespace_id = aws_service_discovery_private_dns_namespace.apiary[0].id
dns_records {
ttl = 10
type = "A"
}
routing_policy = "MULTIVALUE"
}
health_check_custom_config {
failure_threshold = 1
}
}
resource "aws_route53_zone_association" "secondary" {
count = var.hms_instance_type == "ecs" ? length(var.secondary_vpcs) : 0
zone_id = aws_service_discovery_private_dns_namespace.apiary[0].hosted_zone
vpc_id = element(var.secondary_vpcs, count.index)
vpc_region = var.aws_region
}