Created
November 25, 2021 19:54
-
-
Save Vrtak-CZ/000d4cfdc184e4634c6538196e40f48f to your computer and use it in GitHub Desktop.
ECS Task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
locals { | |
task_definition_family = "${local.prefix}-${var.ecs_task_name}" | |
} | |
data "aws_region" "current" {} | |
data "aws_caller_identity" "current" {} | |
data "aws_ecs_task_definition" "hack_get_image" { | |
count = var.preserve_image ? 1 : 0 | |
task_definition = local.task_definition_family | |
} | |
data "aws_ecs_container_definition" "hack_get_image" { | |
count = var.preserve_image ? 1 : 0 | |
task_definition = var.preserve_image ? "arn:aws:ecs:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:task-definition/${local.task_definition_family}:${data.aws_ecs_task_definition.hack_get_image[0].revision}" : "" | |
container_name = var.container_name | |
} | |
resource "aws_ecs_task_definition" "main" { | |
family = local.task_definition_family | |
container_definitions = templatefile('...', { | |
container_image = var.preserve_image ? data.aws_ecs_container_definition.hack_get_image[0].image : var.container_image | |
}); | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment