Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Vrtak-CZ
Created November 25, 2021 19:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Vrtak-CZ/000d4cfdc184e4634c6538196e40f48f to your computer and use it in GitHub Desktop.
Save Vrtak-CZ/000d4cfdc184e4634c6538196e40f48f to your computer and use it in GitHub Desktop.
ECS Task
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