JobDefinition class

Provides a Batch Job Definition resource.

Example Usage

Job definition of type container

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const test = new aws.batch.JobDefinition("test", {
    name: "my_test_batch_job_definition",
    type: "container",
    containerProperties: JSON.stringify({
        command: [
            "ls",
            "-la",
        ],
        image: "busybox",
        resourceRequirements: [
            {
                type: "VCPU",
                value: "0.25",
            },
            {
                type: "MEMORY",
                value: "512",
            },
        ],
        volumes: [{
            host: {
                sourcePath: "/tmp",
            },
            name: "tmp",
        }],
        environment: [{
            name: "VARNAME",
            value: "VARVAL",
        }],
        mountPoints: [{
            sourceVolume: "tmp",
            containerPath: "/tmp",
            readOnly: false,
        }],
        ulimits: [{
            hardLimit: 1024,
            name: "nofile",
            softLimit: 1024,
        }],
    }),
});
import pulumi
import json
import pulumi_aws as aws

test = aws.batch.JobDefinition("test",
    name="my_test_batch_job_definition",
    type="container",
    container_properties=json.dumps({
        "command": [
            "ls",
            "-la",
        ],
        "image": "busybox",
        "resourceRequirements": [
            {
                "type": "VCPU",
                "value": "0.25",
            },
            {
                "type": "MEMORY",
                "value": "512",
            },
        ],
        "volumes": [{
            "host": {
                "sourcePath": "/tmp",
            },
            "name": "tmp",
        }],
        "environment": [{
            "name": "VARNAME",
            "value": "VARVAL",
        }],
        "mountPoints": [{
            "sourceVolume": "tmp",
            "containerPath": "/tmp",
            "readOnly": False,
        }],
        "ulimits": [{
            "hardLimit": 1024,
            "name": "nofile",
            "softLimit": 1024,
        }],
    }))
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var test = new Aws.Batch.JobDefinition("test", new()
    {
        Name = "my_test_batch_job_definition",
        Type = "container",
        ContainerProperties = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["command"] = new[]
            {
                "ls",
                "-la",
            },
            ["image"] = "busybox",
            ["resourceRequirements"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["type"] = "VCPU",
                    ["value"] = "0.25",
                },
                new Dictionary<string, object?>
                {
                    ["type"] = "MEMORY",
                    ["value"] = "512",
                },
            },
            ["volumes"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["host"] = new Dictionary<string, object?>
                    {
                        ["sourcePath"] = "/tmp",
                    },
                    ["name"] = "tmp",
                },
            },
            ["environment"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["name"] = "VARNAME",
                    ["value"] = "VARVAL",
                },
            },
            ["mountPoints"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["sourceVolume"] = "tmp",
                    ["containerPath"] = "/tmp",
                    ["readOnly"] = false,
                },
            },
            ["ulimits"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["hardLimit"] = 1024,
                    ["name"] = "nofile",
                    ["softLimit"] = 1024,
                },
            },
        }),
    });

});
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/batch"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"command": []string{
				"ls",
				"-la",
			},
			"image": "busybox",
			"resourceRequirements": []map[string]string{
				{
					"type":  "VCPU",
					"value": "0.25",
				},
				{
					"type":  "MEMORY",
					"value": "512",
				},
			},
			"volumes": []map[string]interface{}{
				map[string]interface{}{
					"host": map[string]string{
						"sourcePath": "/tmp",
					},
					"name": "tmp",
				},
			},
			"environment": []map[string]string{
				{
					"name":  "VARNAME",
					"value": "VARVAL",
				},
			},
			"mountPoints": []map[string]interface{}{
				map[string]interface{}{
					"sourceVolume":  "tmp",
					"containerPath": "/tmp",
					"readOnly":      false,
				},
			},
			"ulimits": []map[string]interface{}{
				map[string]interface{}{
					"hardLimit": 1024,
					"name":      "nofile",
					"softLimit": 1024,
				},
			},
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		_, err = batch.NewJobDefinition(ctx, "test", &batch.JobDefinitionArgs{
			Name:                pulumi.String("my_test_batch_job_definition"),
			Type:                pulumi.String("container"),
			ContainerProperties: pulumi.String(json0),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_batch_jobdefinition" "test" {
  name = "my_test_batch_job_definition"
  type = "container"
  container_properties = jsonencode({
    "command" = ["ls", "-la"]
    "image"   = "busybox"
    "resourceRequirements" = [{
      "type"  = "VCPU"
      "value" = "0.25"
      }, {
      "type"  = "MEMORY"
      "value" = "512"
    }]
    "volumes" = [{
      "host" = {
        "sourcePath" = "/tmp"
      }
      "name" = "tmp"
    }]
    "environment" = [{
      "name"  = "VARNAME"
      "value" = "VARVAL"
    }]
    "mountPoints" = [{
      "sourceVolume"  = "tmp"
      "containerPath" = "/tmp"
      "readOnly"      = false
    }]
    "ulimits" = [{
      "hardLimit" = 1024
      "name"      = "nofile"
      "softLimit" = 1024
    }]
  })
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.batch.JobDefinition;
import com.pulumi.aws.batch.JobDefinitionArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var test = new JobDefinition("test", JobDefinitionArgs.builder()
            .name("my_test_batch_job_definition")
            .type("container")
            .containerProperties(serializeJson(
                jsonObject(
                    jsonProperty("command", jsonArray(
                        "ls",
                        "-la"
                    )),
                    jsonProperty("image", "busybox"),
                    jsonProperty("resourceRequirements", jsonArray(
                        jsonObject(
                            jsonProperty("type", "VCPU"),
                            jsonProperty("value", "0.25")
                        ),
                        jsonObject(
                            jsonProperty("type", "MEMORY"),
                            jsonProperty("value", "512")
                        )
                    )),
                    jsonProperty("volumes", jsonArray(jsonObject(
                        jsonProperty("host", jsonObject(
                            jsonProperty("sourcePath", "/tmp")
                        )),
                        jsonProperty("name", "tmp")
                    ))),
                    jsonProperty("environment", jsonArray(jsonObject(
                        jsonProperty("name", "VARNAME"),
                        jsonProperty("value", "VARVAL")
                    ))),
                    jsonProperty("mountPoints", jsonArray(jsonObject(
                        jsonProperty("sourceVolume", "tmp"),
                        jsonProperty("containerPath", "/tmp"),
                        jsonProperty("readOnly", false)
                    ))),
                    jsonProperty("ulimits", jsonArray(jsonObject(
                        jsonProperty("hardLimit", 1024),
                        jsonProperty("name", "nofile"),
                        jsonProperty("softLimit", 1024)
                    )))
                )))
            .build());

    }
}
resources:
  test:
    type: aws:batch:JobDefinition
    properties:
      name: my_test_batch_job_definition
      type: container
      containerProperties:
        fn::toJSON:
          command:
            - ls
            - -la
          image: busybox
          resourceRequirements:
            - type: VCPU
              value: '0.25'
            - type: MEMORY
              value: '512'
          volumes:
            - host:
                sourcePath: /tmp
              name: tmp
          environment:
            - name: VARNAME
              value: VARVAL
          mountPoints:
            - sourceVolume: tmp
              containerPath: /tmp
              readOnly: false
          ulimits:
            - hardLimit: 1024
              name: nofile
              softLimit: 1024

Job definition of type multinode

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const test = new aws.batch.JobDefinition("test", {
    name: "tf_test_batch_job_definition_multinode",
    type: "multinode",
    nodeProperties: JSON.stringify({
        mainNode: 0,
        nodeRangeProperties: [
            {
                container: {
                    command: [
                        "ls",
                        "-la",
                    ],
                    image: "busybox",
                    memory: 128,
                    vcpus: 1,
                },
                targetNodes: "0:",
            },
            {
                container: {
                    command: [
                        "echo",
                        "test",
                    ],
                    image: "busybox",
                    memory: 128,
                    vcpus: 1,
                },
                targetNodes: "1:",
            },
        ],
        numNodes: 2,
    }),
});
import pulumi
import json
import pulumi_aws as aws

test = aws.batch.JobDefinition("test",
    name="tf_test_batch_job_definition_multinode",
    type="multinode",
    node_properties=json.dumps({
        "mainNode": 0,
        "nodeRangeProperties": [
            {
                "container": {
                    "command": [
                        "ls",
                        "-la",
                    ],
                    "image": "busybox",
                    "memory": 128,
                    "vcpus": 1,
                },
                "targetNodes": "0:",
            },
            {
                "container": {
                    "command": [
                        "echo",
                        "test",
                    ],
                    "image": "busybox",
                    "memory": 128,
                    "vcpus": 1,
                },
                "targetNodes": "1:",
            },
        ],
        "numNodes": 2,
    }))
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var test = new Aws.Batch.JobDefinition("test", new()
    {
        Name = "tf_test_batch_job_definition_multinode",
        Type = "multinode",
        NodeProperties = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["mainNode"] = 0,
            ["nodeRangeProperties"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["container"] = new Dictionary<string, object?>
                    {
                        ["command"] = new[]
                        {
                            "ls",
                            "-la",
                        },
                        ["image"] = "busybox",
                        ["memory"] = 128,
                        ["vcpus"] = 1,
                    },
                    ["targetNodes"] = "0:",
                },
                new Dictionary<string, object?>
                {
                    ["container"] = new Dictionary<string, object?>
                    {
                        ["command"] = new[]
                        {
                            "echo",
                            "test",
                        },
                        ["image"] = "busybox",
                        ["memory"] = 128,
                        ["vcpus"] = 1,
                    },
                    ["targetNodes"] = "1:",
                },
            },
            ["numNodes"] = 2,
        }),
    });

});
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/batch"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		tmpJSON0, err := json.Marshal(map[string]interface{}{
			"mainNode": 0,
			"nodeRangeProperties": []map[string]interface{}{
				map[string]interface{}{
					"container": map[string]interface{}{
						"command": []string{
							"ls",
							"-la",
						},
						"image":  "busybox",
						"memory": 128,
						"vcpus":  1,
					},
					"targetNodes": "0:",
				},
				map[string]interface{}{
					"container": map[string]interface{}{
						"command": []string{
							"echo",
							"test",
						},
						"image":  "busybox",
						"memory": 128,
						"vcpus":  1,
					},
					"targetNodes": "1:",
				},
			},
			"numNodes": 2,
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		_, err = batch.NewJobDefinition(ctx, "test", &batch.JobDefinitionArgs{
			Name:           pulumi.String("tf_test_batch_job_definition_multinode"),
			Type:           pulumi.String("multinode"),
			NodeProperties: pulumi.String(json0),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_batch_jobdefinition" "test" {
  name = "tf_test_batch_job_definition_multinode"
  type = "multinode"
  node_properties = jsonencode({
    "mainNode" = 0
    "nodeRangeProperties" = [{
      "container" = {
        "command" = ["ls", "-la"]
        "image"   = "busybox"
        "memory"  = 128
        "vcpus"   = 1
      }
      "targetNodes" = "0:"
      }, {
      "container" = {
        "command" = ["echo", "test"]
        "image"   = "busybox"
        "memory"  = 128
        "vcpus"   = 1
      }
      "targetNodes" = "1:"
    }]
    "numNodes" = 2
  })
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.batch.JobDefinition;
import com.pulumi.aws.batch.JobDefinitionArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var test = new JobDefinition("test", JobDefinitionArgs.builder()
            .name("tf_test_batch_job_definition_multinode")
            .type("multinode")
            .nodeProperties(serializeJson(
                jsonObject(
                    jsonProperty("mainNode", 0),
                    jsonProperty("nodeRangeProperties", jsonArray(
                        jsonObject(
                            jsonProperty("container", jsonObject(
                                jsonProperty("command", jsonArray(
                                    "ls",
                                    "-la"
                                )),
                                jsonProperty("image", "busybox"),
                                jsonProperty("memory", 128),
                                jsonProperty("vcpus", 1)
                            )),
                            jsonProperty("targetNodes", "0:")
                        ),
                        jsonObject(
                            jsonProperty("container", jsonObject(
                                jsonProperty("command", jsonArray(
                                    "echo",
                                    "test"
                                )),
                                jsonProperty("image", "busybox"),
                                jsonProperty("memory", 128),
                                jsonProperty("vcpus", 1)
                            )),
                            jsonProperty("targetNodes", "1:")
                        )
                    )),
                    jsonProperty("numNodes", 2)
                )))
            .build());

    }
}
resources:
  test:
    type: aws:batch:JobDefinition
    properties:
      name: tf_test_batch_job_definition_multinode
      type: multinode
      nodeProperties:
        fn::toJSON:
          mainNode: 0
          nodeRangeProperties:
            - container:
                command:
                  - ls
                  - -la
                image: busybox
                memory: 128
                vcpus: 1
              targetNodes: '0:'
            - container:
                command:
                  - echo
                  - test
                image: busybox
                memory: 128
                vcpus: 1
              targetNodes: '1:'
          numNodes: 2

Job Definition of type EKS

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const test = new aws.batch.JobDefinition("test", {
    eksProperties: {
        podProperties: {
            metadata: {
                labels: {
                    environment: "test",
                },
            },
            containers: [{
                resources: {
                    limits: {
                        cpu: "1",
                        memory: "1024Mi",
                    },
                },
                image: "public.ecr.aws/amazonlinux/amazonlinux:1",
                commands: [
                    "sleep",
                    "60",
                ],
            }],
            hostNetwork: true,
        },
    },
    name: " tf_test_batch_job_definition_eks",
    type: "container",
});
import pulumi
import pulumi_aws as aws

test = aws.batch.JobDefinition("test",
    eks_properties={
        "pod_properties": {
            "metadata": {
                "labels": {
                    "environment": "test",
                },
            },
            "containers": [{
                "resources": {
                    "limits": {
                        "cpu": "1",
                        "memory": "1024Mi",
                    },
                },
                "image": "public.ecr.aws/amazonlinux/amazonlinux:1",
                "commands": [
                    "sleep",
                    "60",
                ],
            }],
            "host_network": True,
        },
    },
    name=" tf_test_batch_job_definition_eks",
    type="container")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var test = new Aws.Batch.JobDefinition("test", new()
    {
        EksProperties = new Aws.Batch.Inputs.JobDefinitionEksPropertiesArgs
        {
            PodProperties = new Aws.Batch.Inputs.JobDefinitionEksPropertiesPodPropertiesArgs
            {
                Metadata = new Aws.Batch.Inputs.JobDefinitionEksPropertiesPodPropertiesMetadataArgs
                {
                    Labels =
                    {
                        { "environment", "test" },
                    },
                },
                Containers = new[]
                {
                    new Aws.Batch.Inputs.JobDefinitionEksPropertiesPodPropertiesContainerArgs
                    {
                        Resources = new Aws.Batch.Inputs.JobDefinitionEksPropertiesPodPropertiesContainerResourcesArgs
                        {
                            Limits =
                            {
                                { "cpu", "1" },
                                { "memory", "1024Mi" },
                            },
                        },
                        Image = "public.ecr.aws/amazonlinux/amazonlinux:1",
                        Commands = new[]
                        {
                            "sleep",
                            "60",
                        },
                    },
                },
                HostNetwork = true,
            },
        },
        Name = " tf_test_batch_job_definition_eks",
        Type = "container",
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/batch"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := batch.NewJobDefinition(ctx, "test", &batch.JobDefinitionArgs{
			EksProperties: &batch.JobDefinitionEksPropertiesArgs{
				PodProperties: &batch.JobDefinitionEksPropertiesPodPropertiesArgs{
					Metadata: &batch.JobDefinitionEksPropertiesPodPropertiesMetadataArgs{
						Labels: pulumi.StringMap{
							"environment": pulumi.String("test"),
						},
					},
					Containers: batch.JobDefinitionEksPropertiesPodPropertiesContainerArray{
						&batch.JobDefinitionEksPropertiesPodPropertiesContainerArgs{
							Resources: &batch.JobDefinitionEksPropertiesPodPropertiesContainerResourcesArgs{
								Limits: pulumi.StringMap{
									"cpu":    pulumi.String("1"),
									"memory": pulumi.String("1024Mi"),
								},
							},
							Image: pulumi.String("public.ecr.aws/amazonlinux/amazonlinux:1"),
							Commands: pulumi.StringArray{
								pulumi.String("sleep"),
								pulumi.String("60"),
							},
						},
					},
					HostNetwork: pulumi.Bool(true),
				},
			},
			Name: pulumi.String(" tf_test_batch_job_definition_eks"),
			Type: pulumi.String("container"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_batch_jobdefinition" "test" {
  eks_properties = {
    pod_properties = {
      metadata = {
        labels = {
          "environment" = "test"
        }
      }
      containers = [{
        "resources" = {
          "limits" = {
            "cpu"    = "1"
            "memory" = "1024Mi"
          }
        }
        "image"    = "public.ecr.aws/amazonlinux/amazonlinux:1"
        "commands" = ["sleep", "60"]
      }]
      host_network = true
    }
  }
  name = " tf_test_batch_job_definition_eks"
  type = "container"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.batch.JobDefinition;
import com.pulumi.aws.batch.JobDefinitionArgs;
import com.pulumi.aws.batch.inputs.JobDefinitionEksPropertiesArgs;
import com.pulumi.aws.batch.inputs.JobDefinitionEksPropertiesPodPropertiesArgs;
import com.pulumi.aws.batch.inputs.JobDefinitionEksPropertiesPodPropertiesMetadataArgs;
import com.pulumi.aws.batch.inputs.JobDefinitionEksPropertiesPodPropertiesContainerArgs;
import com.pulumi.aws.batch.inputs.JobDefinitionEksPropertiesPodPropertiesContainerResourcesArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var test = new JobDefinition("test", JobDefinitionArgs.builder()
            .eksProperties(JobDefinitionEksPropertiesArgs.builder()
                .podProperties(JobDefinitionEksPropertiesPodPropertiesArgs.builder()
                    .metadata(JobDefinitionEksPropertiesPodPropertiesMetadataArgs.builder()
                        .labels(Map.of("environment", "test"))
                        .build())
                    .containers(JobDefinitionEksPropertiesPodPropertiesContainerArgs.builder()
                        .resources(JobDefinitionEksPropertiesPodPropertiesContainerResourcesArgs.builder()
                            .limits(Map.ofEntries(
                                Map.entry("cpu", "1"),
                                Map.entry("memory", "1024Mi")
                            ))
                            .build())
                        .image("public.ecr.aws/amazonlinux/amazonlinux:1")
                        .commands(
                            "sleep",
                            "60")
                        .build())
                    .hostNetwork(true)
                    .build())
                .build())
            .name(" tf_test_batch_job_definition_eks")
            .type("container")
            .build());

    }
}
resources:
  test:
    type: aws:batch:JobDefinition
    properties:
      eksProperties:
        podProperties:
          metadata:
            labels:
              environment: test
          containers:
            - resources:
                limits:
                  cpu: '1'
                  memory: 1024Mi
              image: public.ecr.aws/amazonlinux/amazonlinux:1
              commands:
                - sleep
                - '60'
          hostNetwork: true
      name: ' tf_test_batch_job_definition_eks'
      type: container

Fargate Platform Capability

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const assumeRolePolicy = aws.iam.getPolicyDocument({
    statements: [{
        principals: [{
            type: "Service",
            identifiers: ["ecs-tasks.amazonaws.com"],
        }],
        actions: ["sts:AssumeRole"],
    }],
});
const ecsTaskExecutionRole = new aws.iam.Role("ecs_task_execution_role", {
    name: "my_test_batch_exec_role",
    assumeRolePolicy: assumeRolePolicy.then(assumeRolePolicy => assumeRolePolicy.json),
});
const ecsTaskExecutionRolePolicy = new aws.iam.RolePolicyAttachment("ecs_task_execution_role_policy", {
    role: ecsTaskExecutionRole.name,
    policyArn: "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy",
});
const test = new aws.batch.JobDefinition("test", {
    name: "my_test_batch_job_definition",
    type: "container",
    platformCapabilities: ["FARGATE"],
    containerProperties: pulumi.jsonStringify({
        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: ecsTaskExecutionRole.arn,
    }),
});
import pulumi
import json
import pulumi_aws as aws

assume_role_policy = aws.iam.get_policy_document(statements=[{
    "principals": [{
        "type": "Service",
        "identifiers": ["ecs-tasks.amazonaws.com"],
    }],
    "actions": ["sts:AssumeRole"],
}])
ecs_task_execution_role = aws.iam.Role("ecs_task_execution_role",
    name="my_test_batch_exec_role",
    assume_role_policy=assume_role_policy.json)
ecs_task_execution_role_policy = aws.iam.RolePolicyAttachment("ecs_task_execution_role_policy",
    role=ecs_task_execution_role.name,
    policy_arn="arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy")
test = aws.batch.JobDefinition("test",
    name="my_test_batch_job_definition",
    type="container",
    platform_capabilities=["FARGATE"],
    container_properties=pulumi.Output.json_dumps({
        "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": ecs_task_execution_role.arn,
    }))
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var assumeRolePolicy = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Type = "Service",
                        Identifiers = new[]
                        {
                            "ecs-tasks.amazonaws.com",
                        },
                    },
                },
                Actions = new[]
                {
                    "sts:AssumeRole",
                },
            },
        },
    });

    var ecsTaskExecutionRole = new Aws.Iam.Role("ecs_task_execution_role", new()
    {
        Name = "my_test_batch_exec_role",
        AssumeRolePolicy = assumeRolePolicy.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
    });

    var ecsTaskExecutionRolePolicy = new Aws.Iam.RolePolicyAttachment("ecs_task_execution_role_policy", new()
    {
        Role = ecsTaskExecutionRole.Name,
        PolicyArn = "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy",
    });

    var test = new Aws.Batch.JobDefinition("test", new()
    {
        Name = "my_test_batch_job_definition",
        Type = "container",
        PlatformCapabilities = new[]
        {
            "FARGATE",
        },
        ContainerProperties = Output.JsonSerialize(Output.Create(new Dictionary<string, object?>
        {
            ["command"] = new[]
            {
                "echo",
                "test",
            },
            ["image"] = "busybox",
            ["jobRoleArn"] = "arn:aws:iam::123456789012:role/AWSBatchS3ReadOnly",
            ["fargatePlatformConfiguration"] = new Dictionary<string, object?>
            {
                ["platformVersion"] = "LATEST",
            },
            ["resourceRequirements"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["type"] = "VCPU",
                    ["value"] = "0.25",
                },
                new Dictionary<string, object?>
                {
                    ["type"] = "MEMORY",
                    ["value"] = "512",
                },
            },
            ["executionRoleArn"] = ecsTaskExecutionRole.Arn,
        })),
    });

});
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/batch"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		assumeRolePolicy, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Principals: []iam.GetPolicyDocumentStatementPrincipal{
						{
							Type: "Service",
							Identifiers: []string{
								"ecs-tasks.amazonaws.com",
							},
						},
					},
					Actions: []string{
						"sts:AssumeRole",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		ecsTaskExecutionRole, err := iam.NewRole(ctx, "ecs_task_execution_role", &iam.RoleArgs{
			Name:             pulumi.String("my_test_batch_exec_role"),
			AssumeRolePolicy: pulumi.String(assumeRolePolicy.Json),
		})
		if err != nil {
			return err
		}
		_, err = iam.NewRolePolicyAttachment(ctx, "ecs_task_execution_role_policy", &iam.RolePolicyAttachmentArgs{
			Role:      ecsTaskExecutionRole.Name,
			PolicyArn: pulumi.String("arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"),
		})
		if err != nil {
			return err
		}
		_, err = batch.NewJobDefinition(ctx, "test", &batch.JobDefinitionArgs{
			Name: pulumi.String("my_test_batch_job_definition"),
			Type: pulumi.String("container"),
			PlatformCapabilities: pulumi.StringArray{
				pulumi.String("FARGATE"),
			},
			ContainerProperties: ecsTaskExecutionRole.Arn.ApplyT(func(arn string) (pulumi.String, error) {
				var _zero pulumi.String
				tmpJSON0, err := json.Marshal(map[string]interface{}{
					"command": []string{
						"echo",
						"test",
					},
					"image":      "busybox",
					"jobRoleArn": "arn:aws:iam::123456789012:role/AWSBatchS3ReadOnly",
					"fargatePlatformConfiguration": map[string]string{
						"platformVersion": "LATEST",
					},
					"resourceRequirements": []map[string]string{
						{
							"type":  "VCPU",
							"value": "0.25",
						},
						{
							"type":  "MEMORY",
							"value": "512",
						},
					},
					"executionRoleArn": arn,
				})
				if err != nil {
					return _zero, err
				}
				json0 := string(tmpJSON0)
				return pulumi.String(json0), nil
			}).(pulumi.StringOutput),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_iam_getpolicydocument" "assumeRolePolicy" {
  statements {
    principals {
      type        = "Service"
      identifiers = ["ecs-tasks.amazonaws.com"]
    }
    actions = ["sts:AssumeRole"]
  }
}

resource "aws_iam_role" "ecs_task_execution_role" {
  name               = "my_test_batch_exec_role"
  assume_role_policy = data.aws_iam_getpolicydocument.assumeRolePolicy.json
}
resource "aws_iam_rolepolicyattachment" "ecs_task_execution_role_policy" {
  role       = aws_iam_role.ecs_task_execution_role.name
  policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy"
}
resource "aws_batch_jobdefinition" "test" {
  name                  = "my_test_batch_job_definition"
  type                  = "container"
  platform_capabilities = ["FARGATE"]
  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
  })
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.iam.RolePolicyAttachment;
import com.pulumi.aws.iam.RolePolicyAttachmentArgs;
import com.pulumi.aws.batch.JobDefinition;
import com.pulumi.aws.batch.JobDefinitionArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var assumeRolePolicy = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                    .type("Service")
                    .identifiers("ecs-tasks.amazonaws.com")
                    .build())
                .actions("sts:AssumeRole")
                .build())
            .build());

        var ecsTaskExecutionRole = new Role("ecsTaskExecutionRole", RoleArgs.builder()
            .name("my_test_batch_exec_role")
            .assumeRolePolicy(assumeRolePolicy.json())
            .build());

        var ecsTaskExecutionRolePolicy = new RolePolicyAttachment("ecsTaskExecutionRolePolicy", RolePolicyAttachmentArgs.builder()
            .role(ecsTaskExecutionRole.name())
            .policyArn("arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy")
            .build());

        var test = new JobDefinition("test", JobDefinitionArgs.builder()
            .name("my_test_batch_job_definition")
            .type("container")
            .platformCapabilities("FARGATE")
            .containerProperties(ecsTaskExecutionRole.arn().applyValue(_arn -> serializeJson(
                jsonObject(
                    jsonProperty("command", jsonArray(
                        "echo",
                        "test"
                    )),
                    jsonProperty("image", "busybox"),
                    jsonProperty("jobRoleArn", "arn:aws:iam::123456789012:role/AWSBatchS3ReadOnly"),
                    jsonProperty("fargatePlatformConfiguration", jsonObject(
                        jsonProperty("platformVersion", "LATEST")
                    )),
                    jsonProperty("resourceRequirements", jsonArray(
                        jsonObject(
                            jsonProperty("type", "VCPU"),
                            jsonProperty("value", "0.25")
                        ),
                        jsonObject(
                            jsonProperty("type", "MEMORY"),
                            jsonProperty("value", "512")
                        )
                    )),
                    jsonProperty("executionRoleArn", _arn)
                ))))
            .build());

    }
}
resources:
  ecsTaskExecutionRole:
    type: aws:iam:Role
    name: ecs_task_execution_role
    properties:
      name: my_test_batch_exec_role
      assumeRolePolicy: ${assumeRolePolicy.json}
  ecsTaskExecutionRolePolicy:
    type: aws:iam:RolePolicyAttachment
    name: ecs_task_execution_role_policy
    properties:
      role: ${ecsTaskExecutionRole.name}
      policyArn: arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy
  test:
    type: aws:batch:JobDefinition
    properties:
      name: my_test_batch_job_definition
      type: container
      platformCapabilities:
        - FARGATE
      containerProperties:
        fn::toJSON:
          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: ${ecsTaskExecutionRole.arn}
variables:
  assumeRolePolicy:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - principals:
              - type: Service
                identifiers:
                  - ecs-tasks.amazonaws.com
            actions:
              - sts:AssumeRole

Job definition of type container using ecsProperties

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const test = new aws.batch.JobDefinition("test", {
    name: "my_test_batch_job_definition",
    type: "container",
    platformCapabilities: ["FARGATE"],
    ecsProperties: JSON.stringify({
        taskProperties: [{
            executionRoleArn: ecsTaskExecutionRole.arn,
            containers: [
                {
                    image: "public.ecr.aws/amazonlinux/amazonlinux:1",
                    command: [
                        "sleep",
                        "60",
                    ],
                    dependsOn: [{
                        containerName: "container_b",
                        condition: "COMPLETE",
                    }],
                    secrets: [{
                        name: "TEST",
                        valueFrom: "DUMMY",
                    }],
                    environment: [{
                        name: "test",
                        value: "Environment Variable",
                    }],
                    essential: true,
                    logConfiguration: {
                        logDriver: "awslogs",
                        options: {
                            "awslogs-group": "tf_test_batch_job",
                            "awslogs-region": "us-west-2",
                            "awslogs-stream-prefix": "ecs",
                        },
                    },
                    name: "container_a",
                    privileged: false,
                    readonlyRootFilesystem: false,
                    resourceRequirements: [
                        {
                            value: "1.0",
                            type: "VCPU",
                        },
                        {
                            value: "2048",
                            type: "MEMORY",
                        },
                    ],
                },
                {
                    image: "public.ecr.aws/amazonlinux/amazonlinux:1",
                    command: [
                        "sleep",
                        "360",
                    ],
                    name: "container_b",
                    essential: false,
                    resourceRequirements: [
                        {
                            value: "1.0",
                            type: "VCPU",
                        },
                        {
                            value: "2048",
                            type: "MEMORY",
                        },
                    ],
                },
            ],
        }],
    }),
});
import pulumi
import json
import pulumi_aws as aws

test = aws.batch.JobDefinition("test",
    name="my_test_batch_job_definition",
    type="container",
    platform_capabilities=["FARGATE"],
    ecs_properties=json.dumps({
        "taskProperties": [{
            "executionRoleArn": ecs_task_execution_role["arn"],
            "containers": [
                {
                    "image": "public.ecr.aws/amazonlinux/amazonlinux:1",
                    "command": [
                        "sleep",
                        "60",
                    ],
                    "dependsOn": [{
                        "containerName": "container_b",
                        "condition": "COMPLETE",
                    }],
                    "secrets": [{
                        "name": "TEST",
                        "valueFrom": "DUMMY",
                    }],
                    "environment": [{
                        "name": "test",
                        "value": "Environment Variable",
                    }],
                    "essential": True,
                    "logConfiguration": {
                        "logDriver": "awslogs",
                        "options": {
                            "awslogs-group": "tf_test_batch_job",
                            "awslogs-region": "us-west-2",
                            "awslogs-stream-prefix": "ecs",
                        },
                    },
                    "name": "container_a",
                    "privileged": False,
                    "readonlyRootFilesystem": False,
                    "resourceRequirements": [
                        {
                            "value": "1.0",
                            "type": "VCPU",
                        },
                        {
                            "value": "2048",
                            "type": "MEMORY",
                        },
                    ],
                },
                {
                    "image": "public.ecr.aws/amazonlinux/amazonlinux:1",
                    "command": [
                        "sleep",
                        "360",
                    ],
                    "name": "container_b",
                    "essential": False,
                    "resourceRequirements": [
                        {
                            "value": "1.0",
                            "type": "VCPU",
                        },
                        {
                            "value": "2048",
                            "type": "MEMORY",
                        },
                    ],
                },
            ],
        }],
    }))
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var test = new Aws.Batch.JobDefinition("test", new()
    {
        Name = "my_test_batch_job_definition",
        Type = "container",
        PlatformCapabilities = new[]
        {
            "FARGATE",
        },
        EcsProperties = JsonSerializer.Serialize(new Dictionary<string, object?>
        {
            ["taskProperties"] = new[]
            {
                new Dictionary<string, object?>
                {
                    ["executionRoleArn"] = ecsTaskExecutionRole.Arn,
                    ["containers"] = new[]
                    {
                        new Dictionary<string, object?>
                        {
                            ["image"] = "public.ecr.aws/amazonlinux/amazonlinux:1",
                            ["command"] = new[]
                            {
                                "sleep",
                                "60",
                            },
                            ["dependsOn"] = new[]
                            {
                                new Dictionary<string, object?>
                                {
                                    ["containerName"] = "container_b",
                                    ["condition"] = "COMPLETE",
                                },
                            },
                            ["secrets"] = new[]
                            {
                                new Dictionary<string, object?>
                                {
                                    ["name"] = "TEST",
                                    ["valueFrom"] = "DUMMY",
                                },
                            },
                            ["environment"] = new[]
                            {
                                new Dictionary<string, object?>
                                {
                                    ["name"] = "test",
                                    ["value"] = "Environment Variable",
                                },
                            },
                            ["essential"] = true,
                            ["logConfiguration"] = new Dictionary<string, object?>
                            {
                                ["logDriver"] = "awslogs",
                                ["options"] = new Dictionary<string, object?>
                                {
                                    ["awslogs-group"] = "tf_test_batch_job",
                                    ["awslogs-region"] = "us-west-2",
                                    ["awslogs-stream-prefix"] = "ecs",
                                },
                            },
                            ["name"] = "container_a",
                            ["privileged"] = false,
                            ["readonlyRootFilesystem"] = false,
                            ["resourceRequirements"] = new[]
                            {
                                new Dictionary<string, object?>
                                {
                                    ["value"] = "1.0",
                                    ["type"] = "VCPU",
                                },
                                new Dictionary<string, object?>
                                {
                                    ["value"] = "2048",
                                    ["type"] = "MEMORY",
                                },
                            },
                        },
                        new Dictionary<string, object?>
                        {
                            ["image"] = "public.ecr.aws/amazonlinux/amazonlinux:1",
                            ["command"] = new[]
                            {
                                "sleep",
                                "360",
                            },
                            ["name"] = "container_b",
                            ["essential"] = false,
                            ["resourceRequirements"] = new[]
                            {
                                new Dictionary<string, object?>
                                {
                                    ["value"] = "1.0",
                                    ["type"] = "VCPU",
                                },
                                new Dictionary<string, object?>
                                {
                                    ["value"] = "2048",
                                    ["type"] = "MEMORY",
                                },
                            },
                        },
                    },
                },
            },
        }),
    });

});
package main

import (
	"encoding/json"

	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/batch"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		tmpJSON0, err := json.Marshal(map[string][]map[string]interface{}{
			"taskProperties": []map[string]interface{}{
				map[string]interface{}{
					"executionRoleArn": ecsTaskExecutionRole.Arn,
					"containers": []interface{}{
						map[string]interface{}{
							"image": "public.ecr.aws/amazonlinux/amazonlinux:1",
							"command": []string{
								"sleep",
								"60",
							},
							"dependsOn": []map[string]string{
								{
									"containerName": "container_b",
									"condition":     "COMPLETE",
								},
							},
							"secrets": []map[string]string{
								{
									"name":      "TEST",
									"valueFrom": "DUMMY",
								},
							},
							"environment": []map[string]string{
								{
									"name":  "test",
									"value": "Environment Variable",
								},
							},
							"essential": true,
							"logConfiguration": map[string]interface{}{
								"logDriver": "awslogs",
								"options": map[string]string{
									"awslogs-group":         "tf_test_batch_job",
									"awslogs-region":        "us-west-2",
									"awslogs-stream-prefix": "ecs",
								},
							},
							"name":                   "container_a",
							"privileged":             false,
							"readonlyRootFilesystem": false,
							"resourceRequirements": []map[string]string{
								{
									"value": "1.0",
									"type":  "VCPU",
								},
								{
									"value": "2048",
									"type":  "MEMORY",
								},
							},
						},
						map[string]interface{}{
							"image": "public.ecr.aws/amazonlinux/amazonlinux:1",
							"command": []string{
								"sleep",
								"360",
							},
							"name":      "container_b",
							"essential": false,
							"resourceRequirements": []map[string]string{
								{
									"value": "1.0",
									"type":  "VCPU",
								},
								{
									"value": "2048",
									"type":  "MEMORY",
								},
							},
						},
					},
				},
			},
		})
		if err != nil {
			return err
		}
		json0 := string(tmpJSON0)
		_, err = batch.NewJobDefinition(ctx, "test", &batch.JobDefinitionArgs{
			Name: pulumi.String("my_test_batch_job_definition"),
			Type: pulumi.String("container"),
			PlatformCapabilities: pulumi.StringArray{
				pulumi.String("FARGATE"),
			},
			EcsProperties: pulumi.String(json0),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_batch_jobdefinition" "test" {
  name                  = "my_test_batch_job_definition"
  type                  = "container"
  platform_capabilities = ["FARGATE"]
  ecs_properties = jsonencode({
    "taskProperties" = [{
      "executionRoleArn" = ecsTaskExecutionRole.arn
      "containers" = [{
        "image"   = "public.ecr.aws/amazonlinux/amazonlinux:1"
        "command" = ["sleep", "60"]
        "dependsOn" = [{
          "containerName" = "container_b"
          "condition"     = "COMPLETE"
        }]
        "secrets" = [{
          "name"      = "TEST"
          "valueFrom" = "DUMMY"
        }]
        "environment" = [{
          "name"  = "test"
          "value" = "Environment Variable"
        }]
        "essential" = true
        "logConfiguration" = {
          "logDriver" = "awslogs"
          "options" = {
            "awslogs-group"         = "tf_test_batch_job"
            "awslogs-region"        = "us-west-2"
            "awslogs-stream-prefix" = "ecs"
          }
        }
        "name"                   = "container_a"
        "privileged"             = false
        "readonlyRootFilesystem" = false
        "resourceRequirements" = [{
          "value" = "1.0"
          "type"  = "VCPU"
          }, {
          "value" = "2048"
          "type"  = "MEMORY"
        }]
        }, {
        "image"     = "public.ecr.aws/amazonlinux/amazonlinux:1"
        "command"   = ["sleep", "360"]
        "name"      = "container_b"
        "essential" = false
        "resourceRequirements" = [{
          "value" = "1.0"
          "type"  = "VCPU"
          }, {
          "value" = "2048"
          "type"  = "MEMORY"
        }]
      }]
    }]
  })
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.batch.JobDefinition;
import com.pulumi.aws.batch.JobDefinitionArgs;
import static com.pulumi.codegen.internal.Serialization.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var test = new JobDefinition("test", JobDefinitionArgs.builder()
            .name("my_test_batch_job_definition")
            .type("container")
            .platformCapabilities("FARGATE")
            .ecsProperties(serializeJson(
                jsonObject(
                    jsonProperty("taskProperties", jsonArray(jsonObject(
                        jsonProperty("executionRoleArn", ecsTaskExecutionRole.arn()),
                        jsonProperty("containers", jsonArray(
                            jsonObject(
                                jsonProperty("image", "public.ecr.aws/amazonlinux/amazonlinux:1"),
                                jsonProperty("command", jsonArray(
                                    "sleep",
                                    "60"
                                )),
                                jsonProperty("dependsOn", jsonArray(jsonObject(
                                    jsonProperty("containerName", "container_b"),
                                    jsonProperty("condition", "COMPLETE")
                                ))),
                                jsonProperty("secrets", jsonArray(jsonObject(
                                    jsonProperty("name", "TEST"),
                                    jsonProperty("valueFrom", "DUMMY")
                                ))),
                                jsonProperty("environment", jsonArray(jsonObject(
                                    jsonProperty("name", "test"),
                                    jsonProperty("value", "Environment Variable")
                                ))),
                                jsonProperty("essential", true),
                                jsonProperty("logConfiguration", jsonObject(
                                    jsonProperty("logDriver", "awslogs"),
                                    jsonProperty("options", jsonObject(
                                        jsonProperty("awslogs-group", "tf_test_batch_job"),
                                        jsonProperty("awslogs-region", "us-west-2"),
                                        jsonProperty("awslogs-stream-prefix", "ecs")
                                    ))
                                )),
                                jsonProperty("name", "container_a"),
                                jsonProperty("privileged", false),
                                jsonProperty("readonlyRootFilesystem", false),
                                jsonProperty("resourceRequirements", jsonArray(
                                    jsonObject(
                                        jsonProperty("value", "1.0"),
                                        jsonProperty("type", "VCPU")
                                    ),
                                    jsonObject(
                                        jsonProperty("value", "2048"),
                                        jsonProperty("type", "MEMORY")
                                    )
                                ))
                            ),
                            jsonObject(
                                jsonProperty("image", "public.ecr.aws/amazonlinux/amazonlinux:1"),
                                jsonProperty("command", jsonArray(
                                    "sleep",
                                    "360"
                                )),
                                jsonProperty("name", "container_b"),
                                jsonProperty("essential", false),
                                jsonProperty("resourceRequirements", jsonArray(
                                    jsonObject(
                                        jsonProperty("value", "1.0"),
                                        jsonProperty("type", "VCPU")
                                    ),
                                    jsonObject(
                                        jsonProperty("value", "2048"),
                                        jsonProperty("type", "MEMORY")
                                    )
                                ))
                            )
                        ))
                    )))
                )))
            .build());

    }
}
resources:
  test:
    type: aws:batch:JobDefinition
    properties:
      name: my_test_batch_job_definition
      type: container
      platformCapabilities:
        - FARGATE
      ecsProperties:
        fn::toJSON:
          taskProperties:
            - executionRoleArn: ${ecsTaskExecutionRole.arn}
              containers:
                - image: public.ecr.aws/amazonlinux/amazonlinux:1
                  command:
                    - sleep
                    - '60'
                  dependsOn:
                    - containerName: container_b
                      condition: COMPLETE
                  secrets:
                    - name: TEST
                      valueFrom: DUMMY
                  environment:
                    - name: test
                      value: Environment Variable
                  essential: true
                  logConfiguration:
                    logDriver: awslogs
                    options:
                      awslogs-group: tf_test_batch_job
                      awslogs-region: us-west-2
                      awslogs-stream-prefix: ecs
                  name: container_a
                  privileged: false
                  readonlyRootFilesystem: false
                  resourceRequirements:
                    - value: '1.0'
                      type: VCPU
                    - value: '2048'
                      type: MEMORY
                - image: public.ecr.aws/amazonlinux/amazonlinux:1
                  command:
                    - sleep
                    - '360'
                  name: container_b
                  essential: false
                  resourceRequirements:
                    - value: '1.0'
                      type: VCPU
                    - value: '2048'
                      type: MEMORY

Import

Identity Schema

Required

  • arn (String) ARN of the job definition.

Using pulumi import, import Batch Job Definition using the arn. For example:

$ pulumi import aws:batch/jobDefinition:JobDefinition test arn:aws:batch:us-east-1:123456789012:job-definition/sample

Constructors

JobDefinition(String name, {JobDefinitionArgs? args, CustomResourceOptions? options})
Creates a new JobDefinition. name The Pulumi resource name. args Arguments used to configure this JobDefinition. The set of arguments for JobDefinition. options Resource options controlling this resource's behavior.
JobDefinition.reference(String urn)
Creates a typed reference to an existing JobDefinition resource.

Properties

arn ↔ Output<String>
ARN of the job definition, includes revision (:#).
latefinal
arnPrefix ↔ Output<String>
ARN without the revision number.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
containerProperties ↔ Output<String?>
Valid container properties provided as a single valid JSON document. This parameter is only valid if the type parameter is container.
latefinal
deregisterOnNewRevision ↔ Output<bool?>
When updating a job definition a new revision is created. This parameter determines if the previous version is deregistered (INACTIVE) or left ACTIVE. Defaults to true.
latefinal
ecsProperties ↔ Output<String?>
Valid ECS properties provided as a single valid JSON document. This parameter is only valid if the type parameter is container.
latefinal
eksProperties ↔ Output<JobDefinitionEksProperties?>
Valid eks properties. This parameter is only valid if the type parameter is container.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
name ↔ Output<String>
Name of the job definition.
latefinal
nodeProperties ↔ Output<String?>
Valid node properties provided as a single valid JSON document. This parameter is required if the type parameter is multinode.
latefinal
parameters ↔ Output<Map<String, String>?>
Parameter substitution placeholders to set in the job definition.
latefinal
platformCapabilities ↔ Output<List<String>?>
Platform capabilities required by the job definition. If no value is specified, it defaults to EC2. To run the job on Fargate resources, specify FARGATE.
latefinal
propagateTags ↔ Output<bool?>
Whether to propagate the tags from the job definition to the corresponding Amazon ECS task. Default is false.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
retryStrategy ↔ Output<JobDefinitionRetryStrategy?>
Retry strategy to use for failed jobs that are submitted with this job definition. Maximum number of retryStrategy is 1. Defined below.
latefinal
revision ↔ Output<int>
Revision of the job definition.
latefinal
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
schedulingPriority ↔ Output<int?>
Scheduling priority of the job definition. This only affects jobs in job queues with a fair share policy. Jobs with a higher scheduling priority are scheduled before jobs with a lower scheduling priority. Allowed values 0 through 9999.
latefinal
tags ↔ Output<Map<String, String>?>
Key-value map of resource tags. .If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
latefinal
tagsAll ↔ Output<Map<String, String>>
Map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
latefinal
timeout ↔ Output<JobDefinitionTimeout?>
Timeout for jobs so that if a job runs longer, AWS Batch terminates the job. Maximum number of timeout is 1. Defined below.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
type ↔ Output<String>
Type of job definition. Must be container or multinode.
latefinal
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {JobDefinitionState? state, CustomResourceOptions? options}) → JobDefinition
Gets an existing JobDefinition resource's state with the given name and id.