Skip to content

Conversation

budde377
Copy link

@budde377 budde377 commented Aug 22, 2025

Description

Extract task definitions into their own submodule (just like container definitions) and allow creating task definitions directly on the cluster.

Motivation and Context

We are looking to run scheduled tasks through AWS EventBridge following this approach. This change will allow us to define a task independently of a service reusing all the heavy lifting of this module wrt. e.g. iam policies.

Breaking Changes

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

@budde377 budde377 changed the title Feat add task definition feat: add separate task definition Aug 22, 2025
@budde377 budde377 force-pushed the feat-add-task-definition branch from 64d2283 to 81c74b1 Compare August 22, 2025 15:49
@bryantbiggs
Copy link
Member

we already support this today

################################################################################
# Standalone Task Definition (w/o Service)
################################################################################
module "ecs_task_definition" {
source = "../../modules/service"
# Service
name = "${local.name}-standalone"
cluster_arn = module.ecs_cluster.arn
create_service = false
# Task Definition
volume = {
ex-vol = {}
}
runtime_platform = {
cpu_architecture = "ARM64"
operating_system_family = "LINUX"
}
# Container definition(s)
container_definitions = {
al2023 = {
image = "public.ecr.aws/amazonlinux/amazonlinux:2023-minimal"
mountPoints = [
{
sourceVolume = "ex-vol",
containerPath = "/var/www/ex-vol"
}
]
command = ["echo hello world"]
entrypoint = ["/usr/bin/sh", "-c"]
}
}
subnet_ids = module.vpc.private_subnets
security_group_egress_rules = {
all = {
ip_protocol = "-1"
cidr_ipv4 = "0.0.0.0/0"
}
}
tags = local.tags
}

@budde377
Copy link
Author

Excelent, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants