-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpreflight.tf
45 lines (41 loc) · 1.18 KB
/
preflight.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
locals {
preflight = {
overrides = {
containerOverrides = [
{
name = "sync"
command = [
"./ptctl",
"sync",
"preflight"
]
}
]
}
network_config = {
awsvpcConfiguration : {
assignPublicIp = "DISABLED"
subnets = aws_ecs_service.sync.network_configuration[0].subnets
securityGroups = aws_ecs_service.sync.network_configuration[0].security_groups
}
}
}
}
resource "null_resource" "preflight" {
count = var.polytomic_preflight_check ? 1 : 0
provisioner "local-exec" {
interpreter = ["/bin/bash", "-c"]
command = <<EOF
set -e
aws ecs run-task \
--cluster ${var.ecs_cluster_name == "" ? module.ecs[0].cluster_arn : data.aws_ecs_cluster.cluster[0].arn} \
--task-definition ${aws_ecs_task_definition.sync.family}:${aws_ecs_task_definition.sync.revision} \
--launch-type FARGATE \
--started-by "Polytomic Terraform Preflight" \
--overrides '${jsonencode(local.preflight.overrides)}' \
--network-configuration '${jsonencode(local.preflight.network_config)}' \
--region '${var.region}' \
--profile '${var.aws_profile}'
EOF
}
}