Resource: awsBatchJobDefinition
Provides a Batch Job Definition resource.
Example Usage
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.batchJobDefinition.BatchJobDefinition(this, "test", {
containerProperties:
'${jsonencode({\n command = ["ls", "-la"],\n image = "busybox"\n\n resourceRequirements = [\n {\n type = "VCPU"\n value = "0.25"\n },\n {\n type = "MEMORY"\n value = "512"\n }\n ]\n\n volumes = [\n {\n host = {\n sourcePath = "/tmp"\n }\n name = "tmp"\n }\n ]\n\n environment = [\n {\n name = "VARNAME"\n value = "VARVAL"\n }\n ]\n\n mountPoints = [\n {\n sourceVolume = "tmp"\n containerPath = "/tmp"\n readOnly = false\n }\n ]\n\n ulimits = [\n {\n hardLimit = 1024\n name = "nofile"\n softLimit = 1024\n }\n ]\n })}',
name: "tf_test_batch_job_definition",
type: "container",
});
Fargate Platform Capability
/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
new aws.batchJobDefinition.BatchJobDefinition(this, "test", {
containerProperties:
'${jsonencode({\n command = ["echo", "test"]\n image = "busybox"\n jobRoleArn = "arn:aws:iam::123456789012:role/AWSBatchS3ReadOnly"\n\n fargatePlatformConfiguration = {\n platformVersion = "LATEST"\n }\n\n resourceRequirements = [\n {\n type = "VCPU"\n value = "0.25"\n },\n {\n type = "MEMORY"\n value = "512"\n }\n ]\n\n executionRoleArn = aws_iam_role.ecs_task_execution_role.arn\n })}',
name: "tf_test_batch_job_definition",
platformCapabilities: ["FARGATE"],
type: "container",
});
const dataAwsIamPolicyDocumentAssumeRolePolicy =
new aws.dataAwsIamPolicyDocument.DataAwsIamPolicyDocument(
this,
"assume_role_policy",
{
statement: [
{
actions: ["sts:AssumeRole"],
principals: [
{
identifiers: ["ecs-tasks.amazonaws.com"],
type: "Service",
},
],
},
],
}
);
const awsIamRoleEcsTaskExecutionRole = new aws.iamRole.IamRole(
this,
"ecs_task_execution_role",
{
assumeRolePolicy: dataAwsIamPolicyDocumentAssumeRolePolicy.json,
name: "tf_test_batch_exec_role",
}
);
new aws.iamRolePolicyAttachment.IamRolePolicyAttachment(
this,
"ecs_task_execution_role_policy",
{
policyArn:
"arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy",
role: awsIamRoleEcsTaskExecutionRole.name,
}
);
Argument Reference
The following arguments are required:
name
- (Required) Specifies the name of the job definition.type
- (Required) The type of job definition. Must becontainer
.
The following arguments are optional:
containerProperties
- (Optional) A valid container properties provided as a single valid JSON document. This parameter is required if thetype
parameter iscontainer
.parameters
- (Optional) Specifies the parameter substitution placeholders to set in the job definition.platformCapabilities
- (Optional) The platform capabilities required by the job definition. If no value is specified, it defaults toec2
. To run the job on Fargate resources, specifyfargate
.propagateTags
- (Optional) Specifies whether to propagate the tags from the job definition to the corresponding Amazon ECS task. Default isfalse
.retryStrategy
- (Optional) Specifies the retry strategy to use for failed jobs that are submitted with this job definition. Maximum number ofretryStrategy
is1
. Defined below.tags
- (Optional) Key-value map of resource tags. If configured with a providerdefaultTags
configuration block present, tags with matching keys will overwrite those defined at the provider-level.timeout
- (Optional) Specifies the timeout for jobs so that if a job runs longer, AWS Batch terminates the job. Maximum number oftimeout
is1
. Defined below.
retryStrategy
attempts
- (Optional) The number of times to move a job to therunnable
status. You may specify between1
and10
attempts.evaluateOnExit
- (Optional) The evaluate on exit conditions under which the job should be retried or failed. If this parameter is specified, then theattempts
parameter must also be specified. You may specify up to 5 configuration blocks.
evaluateOnExit
action
- (Required) Specifies the action to take if all of the specified conditions are met. The values are not case sensitive. Valid values:retry
,exit
.onExitCode
- (Optional) A glob pattern to match against the decimal representation of the exit code returned for a job.onReason
- (Optional) A glob pattern to match against the reason returned for a job.onStatusReason
- (Optional) A glob pattern to match against the status reason returned for a job.
timeout
attemptDurationSeconds
- (Optional) The time duration in seconds after which AWS Batch terminates your jobs if they have not finished. The minimum value for the timeout is60
seconds.
Attributes Reference
In addition to all arguments above, the following attributes are exported:
arn
- The Amazon Resource Name of the job definition.revision
- The revision of the job definition.tagsAll
- A map of tags assigned to the resource, including those inherited from the providerdefaultTags
configuration block.
Import
Batch Job Definition can be imported using the arn
, e.g.,