You must be logged in to view saved presets
Sets up a Batch Job Definition with Fargate platform capabilities, including IAM roles and policies for task execution.
data "aws_iam_policy_document" "assume_role_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
identifiers = ["ecs-tasks.amazonaws.com"]
type = "Service"
}
}
}
resource "aws_batch_job_definition" "test" {
container_properties = jsonencode({
command = ["echo", "test"]
image = "busybox"
jobRoleArn = "arn:aws:iam::123456789012:role/AWSBatchS3ReadOnly"
fargatePlatformConfiguration = {
platformVersion = "LATEST"
}
resourceRequirements = [
{
type = "VCPU"
value = "0.25"
},
{
type = "MEMORY"
value = "512"
}
]
executionRoleArn = aws_iam_role.ecs_task_execution_role.arn
})
name = "tf_test_batch_job_definition"
platform_capabilities = ["FARGATE"]
type = "container"
}
resource "aws_iam_role" "ecs_task_execution_role" {
assume_role_policy = data.aws_iam_policy_document.assume_role_policy.json
name = "tf_test_batch_exec_role"
}
resource "aws_iam_role_policy_attachment" "ecs_task_execution_role_policy" {
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
role = aws_iam_role.ecs_task_execution_role.name
}