-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathboostrap.tf
49 lines (46 loc) · 1.41 KB
/
boostrap.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
locals {
bootstrap = {
overrides = {
containerOverrides = [
{
name = "sync"
command = [
"./ptctl",
"workspaces",
"provision",
"--name=${var.polytomic_workspace_name}",
"--domain=${var.polytomic_sso_domain}",
"--workos_id=${var.polytomic_workos_org_id}",
"--users=${var.polytomic_root_user}",
"--yes",
]
}
]
}
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" "boostrap" {
count = var.polytomic_bootstrap ? 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 Bootstrap" \
--overrides '${jsonencode(local.bootstrap.overrides)}' \
--network-configuration '${jsonencode(local.bootstrap.network_config)}' \
--region '${var.region}' \
--profile '${var.aws_profile}'
EOF
}
}