Skip to content

Commit

Permalink
Generalised naming
Browse files Browse the repository at this point in the history
  • Loading branch information
DrizzlyOwl committed Sep 20, 2024
1 parent e585e42 commit 9828be7
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 38 deletions.
23 changes: 10 additions & 13 deletions container-definitions/app.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"containerPort": ${container_port}
}
],
%{ if enable_nginx_frontend },
%{ if enable_sidecar_container },
"healthCheck": {
"command": ["CMD-SHELL", "curl -f localhost:${container_port} || exit 1]
},
Expand Down Expand Up @@ -74,10 +74,10 @@
"memoryReservation": 16,
"essential": true
}
%{ if enable_nginx_frontend },
{% if enable_sidecar_container },
{
"image": "nginx:${nginx_image_tag}",
"name": "${container_name}-nginx",
"image": "${sidecar_image}",
"name": "${sidecar_container_name}",
%{ if syslog_address != "" }
"logConfiguration": {
"logDriver": "syslog",
Expand Down Expand Up @@ -111,23 +111,20 @@
"containerPort": 8080
}
],
%{ if nginx_environment != "[]" }
"environment": ${nginx_environment},
%{ if sidecar_environment != "[]" }
"environment": ${sidecar_environment},
%{ endif }
%{if nginx_entrypoint != "[]"}
"entrypoint": ${nginx_entrypoint},
%{if sidecar_entrypoint != "[]"}
"entrypoint": ${sidecar_entrypoint},
%{ endif }
"memoryReservation": 16,
"essential": true.
"healthCheck": {
"command": ["CMD-SHELL", "service", "nginx", "status"]
},
"essential": true,
"dependsOn": [
{
"containerName": "${container_name}",
"condition": "HEALTHY"
}
]
}
%{ endif }
{% endif }
]
8 changes: 4 additions & 4 deletions ecs-cluster-infrastructure-logspout-service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ resource "aws_ecs_task_definition" "infrastructure_ecs_cluster_logspout" {
cloudwatch_log_group = ""
awslogs_stream_prefix = ""
region = local.aws_region
enable_nginx_frontend = false
nginx_image_tag = ""
nginx_environment = "[]"
nginx_entrypoint = "[]"
sidecar_container_name = false
sidecar_image = ""
sidecar_environment = "[]"
sidecar_entrypoint = "[]"
}
)

Expand Down
8 changes: 4 additions & 4 deletions ecs-cluster-infrastructure-service-scheduled-task.tf
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ resource "aws_ecs_task_definition" "infrastructure_ecs_cluster_service_scheduled
cloudwatch_log_group = !local.infrastructure_ecs_cluster_logspout_enabled ? each.value["enable_cloudwatch_logs"] == true ? aws_cloudwatch_log_group.infrastructure_ecs_cluster_service[each.value["container_name"]].name : "" : ""
awslogs_stream_prefix = ""
region = local.aws_region
enable_nginx_frontend = false
nginx_image_tag = ""
nginx_environment = "[]"
nginx_entrypoint = "[]"
sidecar_container_name = false
sidecar_image = ""
sidecar_environment = "[]"
sidecar_entrypoint = "[]"
}
)
execution_role_arn = aws_iam_role.infrastructure_ecs_cluster_service_task_execution[each.value["container_name"]].arn
Expand Down
19 changes: 10 additions & 9 deletions ecs-cluster-infrastructure-service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,16 @@ resource "aws_ecs_task_definition" "infrastructure_ecs_cluster_service" {
linux_parameters = each.value["enable_execute_command"] == true ? jsonencode({
initProcessEnabled = true
}) : "{}"
syslog_address = !local.infrastructure_ecs_cluster_logspout_enabled ? local.infrastructure_ecs_cluster_syslog_docker_address : ""
syslog_tag = "${local.resource_prefix}-${each.key}-{{.ID}}"
cloudwatch_log_group = !local.infrastructure_ecs_cluster_logspout_enabled ? each.value["enable_cloudwatch_logs"] == true ? aws_cloudwatch_log_group.infrastructure_ecs_cluster_service[each.key].name : "" : ""
awslogs_stream_prefix = ""
region = local.aws_region
enable_nginx_frontend = each.value["enable_nginx_frontend"]
nginx_image_tag = each.value["nginx_image_tag"]
nginx_environment = "[]"
nginx_entrypoint = "[]"
syslog_address = !local.infrastructure_ecs_cluster_logspout_enabled ? local.infrastructure_ecs_cluster_syslog_docker_address : ""
syslog_tag = "${local.resource_prefix}-${each.key}-{{.ID}}"
cloudwatch_log_group = !local.infrastructure_ecs_cluster_logspout_enabled ? each.value["enable_cloudwatch_logs"] == true ? aws_cloudwatch_log_group.infrastructure_ecs_cluster_service[each.key].name : "" : ""
awslogs_stream_prefix = ""
region = local.aws_region
enable_sidecar_container = each.value["enable_sidecar_container"]
sidecar_container_name = "${each.key}-sidecar"
sidecar_image = each.value["sidecar_image"]
sidecar_environment = "[]"
sidecar_entrypoint = "[]"
}
)
execution_role_arn = aws_iam_role.infrastructure_ecs_cluster_service_task_execution[each.key].arn
Expand Down
8 changes: 4 additions & 4 deletions rds-infrastructure-s3-backups-task-definition.tf
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ resource "aws_ecs_task_definition" "infrastructure_rds_s3_backups_scheduled_task
cloudwatch_log_group = aws_cloudwatch_log_group.infrastructure_rds_s3_backups[each.key].name
awslogs_stream_prefix = "${local.resource_prefix}-rds-s3-backups-${each.key}"
region = local.aws_region
enable_nginx_frontend = false
nginx_image_tag = ""
nginx_environment = "[]"
nginx_entrypoint = "[]"
sidecar_container_name = false
sidecar_image = ""
sidecar_environment = "[]"
sidecar_entrypoint = "[]"
}
)
execution_role_arn = aws_iam_role.infrastructure_rds_s3_backups_task_execution[each.key].arn
Expand Down
8 changes: 4 additions & 4 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,8 @@ variable "infrastructure_ecs_cluster_services" {
container_count: Number of containers to launch for the service
container_heath_check_path: Destination for the health check request
container_heath_grace_period: Seconds to ignore failing load balancer health checks on newly instantiated tasks to prevent premature shutdown
enable_nginx_frontend: Launch an nginx sidecar container that will act as a proxy for all incoming traffic
nginx_image_tag: A specific Docker tag to use for the nginx container (eg. 1.27.1)
enable_sidecar_container: Launch a sidecar container that will act as a proxy for all incoming traffic
sidecar_image: A specific Docker tag to use for the sidecar container. Defaults to nginx:stable (eg. nginx:1.27.1)
scheduled_tasks: A map of scheduled tasks that use the same image as the service defined eg. { "name" => { "entrypoint" = ["bundle", "exec", "run_jobs"], "schedule_expression" = "cron(* * * * ? *)" } }
domain_names: Domain names to assign to CloudFront aliases, and the Application Load Balancer's `host_header` condition
enable_cloudfront: Enable CloudFront for the service
Expand Down Expand Up @@ -613,8 +613,8 @@ variable "infrastructure_ecs_cluster_services" {
container_count = optional(number, null)
container_heath_check_path = optional(string, null)
container_heath_grace_period = optional(number, null)
enable_nginx_frontend = optional(bool, false)
nginx_image_tag = optional(string, "stable")
enable_sidecar_container = optional(bool, false)
sidecar_image = optional(string, "nginx:stable")
scheduled_tasks = optional(map(object({
entrypoint = list(string)
schedule_expression = string
Expand Down

0 comments on commit 9828be7

Please sign in to comment.