-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathcloudmap.tf
41 lines (36 loc) · 1.31 KB
/
cloudmap.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
///////////////////////////////////////////////////////[ CLOUDMAP DISCOVERY ]/////////////////////////////////////////////
# # ---------------------------------------------------------------------------------------------------------------------#
# Create CloudMap discovery service with private dns namespace
# # ---------------------------------------------------------------------------------------------------------------------#
resource "aws_service_discovery_private_dns_namespace" "this" {
name = "${var.brand}.internal"
description = "Namespace for ${local.project}"
vpc = aws_vpc.this.id
tags = {
Name = "${local.project}-namespace"
}
}
resource "aws_service_discovery_service" "this" {
for_each = {
for entry in setproduct(keys(var.ec2), slice(keys(data.aws_availability_zone.all), 0, 2)) :
"${entry[0]}-${entry[1]}" => {
service = entry[0],
az = entry[1]
}
}
name = ${local.project}-${each.value.service}-${each.value.az}
dns_config {
namespace_id = aws_service_discovery_private_dns_namespace.this.id
dns_records {
type = "A"
ttl = 10
}
}
health_check_custom_config {
failure_threshold = 1
}
force_destroy = true
tags = {
Name = "${local.project}-${each.value.service}-${each.value.az}-service"
}
}