Skip to content

Commit

Permalink
Allow environment variables in app container definition
Browse files Browse the repository at this point in the history
* This allows adding environment variables using the app.json.tpl
  container defintion template
* We can then reuse this container definition for tasks that won't be
  using an S3 environment variable file (eg. passing in environment
  variables from Terraform)
  • Loading branch information
Stretch96 committed Jul 24, 2024
1 parent 58b14bc commit c74d76f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions container-definitions/app.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
}
],
%{ endif }
%{ if environment != "[]" }
"environment": "${environment},
%{ endif }
%{ if environment_file_s3 != "" }
"environmentFiles": [
{
Expand Down
1 change: 1 addition & 0 deletions ecs-cluster-infrastructure-service-scheduled-task.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ resource "aws_ecs_task_definition" "infrastructure_ecs_cluster_service_scheduled
image = aws_ecr_repository.infrastructure_ecs_cluster_service[each.value["container_name"]].repository_url
entrypoint = each.value["entrypoint"] != null ? jsonencode(each.value["entrypoint"]) : "[]"
environment_file_s3 = "${aws_s3_bucket.infrastructure_ecs_cluster_service_environment_files[0].arn}/${each.value["container_name"]}.env"
environment = jsonencode([])
container_port = 0
extra_hosts = each.value["extra_hosts"] != null ? jsonencode([
for extra_host in each.value["extra_hosts"] : {
Expand Down
1 change: 1 addition & 0 deletions ecs-cluster-infrastructure-service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ resource "aws_ecs_task_definition" "infrastructure_ecs_cluster_service" {
image = aws_ecr_repository.infrastructure_ecs_cluster_service[each.key].repository_url
entrypoint = each.value["container_entrypoint"] != null ? jsonencode(each.value["container_entrypoint"]) : "[]"
environment_file_s3 = "${aws_s3_bucket.infrastructure_ecs_cluster_service_environment_files[0].arn}/${each.key}.env"
environment = jsonencode([])
container_port = each.value["container_port"] != null ? each.value["container_port"] : 0
extra_hosts = each.value["container_extra_hosts"] != null ? jsonencode([
for extra_host in each.value["container_extra_hosts"] : {
Expand Down

0 comments on commit c74d76f

Please sign in to comment.