Package com.pulumi.aws.batch
Class JobDefinition
- java.lang.Object
-
- com.pulumi.resources.Resource
-
- com.pulumi.resources.CustomResource
-
- com.pulumi.aws.batch.JobDefinition
-
public class JobDefinition extends com.pulumi.resources.CustomResource
Provides a Batch Job Definition resource. ## Example Usage ### Job definition of type container <!--Start PulumiCodeChooser -->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.List; import java.util.ArrayList; 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()); } }
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.List; import java.util.ArrayList; 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()); } }
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.JobDefinitionEksPropertiesPodPropertiesContainersArgs; import com.pulumi.aws.batch.inputs.JobDefinitionEksPropertiesPodPropertiesContainersResourcesArgs; import com.pulumi.aws.batch.inputs.JobDefinitionEksPropertiesPodPropertiesMetadataArgs; import java.util.List; import java.util.ArrayList; 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_eks") .type("container") .eksProperties(JobDefinitionEksPropertiesArgs.builder() .podProperties(JobDefinitionEksPropertiesPodPropertiesArgs.builder() .hostNetwork(true) .containers(JobDefinitionEksPropertiesPodPropertiesContainersArgs.builder() .image("public.ecr.aws/amazonlinux/amazonlinux:1") .commands( "sleep", "60") .resources(JobDefinitionEksPropertiesPodPropertiesContainersResourcesArgs.builder() .limits(Map.ofEntries( Map.entry("cpu", "1"), Map.entry("memory", "1024Mi") )) .build()) .build()) .metadata(JobDefinitionEksPropertiesPodPropertiesMetadataArgs.builder() .labels(Map.of("environment", "test")) .build()) .build()) .build()) .build()); } }
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.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.List; import java.util.ArrayList; 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() .actions("sts:AssumeRole") .principals(GetPolicyDocumentStatementPrincipalArgs.builder() .type("Service") .identifiers("ecs-tasks.amazonaws.com") .build()) .build()) .build()); var ecsTaskExecutionRole = new Role("ecsTaskExecutionRole", RoleArgs.builder() .name("my_test_batch_exec_role") .assumeRolePolicy(assumeRolePolicy.applyValue(getPolicyDocumentResult -> getPolicyDocumentResult.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()); } }
-
-
Constructor Summary
Constructors Constructor Description JobDefinition(java.lang.String name)
JobDefinition(java.lang.String name, JobDefinitionArgs args)
JobDefinition(java.lang.String name, JobDefinitionArgs args, com.pulumi.resources.CustomResourceOptions options)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description com.pulumi.core.Output<java.lang.String>
arn()
com.pulumi.core.Output<java.lang.String>
arnPrefix()
com.pulumi.core.Output<java.util.Optional<java.lang.String>>
containerProperties()
com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>>
deregisterOnNewRevision()
com.pulumi.core.Output<java.util.Optional<JobDefinitionEksProperties>>
eksProperties()
static JobDefinition
get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, JobDefinitionState state, com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.com.pulumi.core.Output<java.lang.String>
name()
com.pulumi.core.Output<java.util.Optional<java.lang.String>>
nodeProperties()
com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>>
parameters()
com.pulumi.core.Output<java.util.Optional<java.util.List<java.lang.String>>>
platformCapabilities()
com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>>
propagateTags()
com.pulumi.core.Output<java.util.Optional<JobDefinitionRetryStrategy>>
retryStrategy()
com.pulumi.core.Output<java.lang.Integer>
revision()
com.pulumi.core.Output<java.util.Optional<java.lang.Integer>>
schedulingPriority()
com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>>
tags()
com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>>
tagsAll()
com.pulumi.core.Output<java.util.Optional<JobDefinitionTimeout>>
timeout()
com.pulumi.core.Output<java.lang.String>
type()
-
-
-
Constructor Detail
-
JobDefinition
public JobDefinition(java.lang.String name)
- Parameters:
name
- The _unique_ name of the resulting resource.
-
JobDefinition
public JobDefinition(java.lang.String name, JobDefinitionArgs args)
- Parameters:
name
- The _unique_ name of the resulting resource.args
- The arguments to use to populate this resource's properties.
-
JobDefinition
public JobDefinition(java.lang.String name, JobDefinitionArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options)
- Parameters:
name
- The _unique_ name of the resulting resource.args
- The arguments to use to populate this resource's properties.options
- A bag of options that control this resource's behavior.
-
-
Method Detail
-
arn
public com.pulumi.core.Output<java.lang.String> arn()
- Returns:
- The Amazon Resource Name of the job definition, includes revision (`:#`).
-
arnPrefix
public com.pulumi.core.Output<java.lang.String> arnPrefix()
- Returns:
- The ARN without the revision number.
-
containerProperties
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> containerProperties()
- Returns:
- A valid [container properties](http://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html) provided as a single valid JSON document. This parameter is only valid if the `type` parameter is `container`.
-
deregisterOnNewRevision
public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> deregisterOnNewRevision()
- Returns:
- 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`.
-
eksProperties
public com.pulumi.core.Output<java.util.Optional<JobDefinitionEksProperties>> eksProperties()
- Returns:
- A valid eks properties. This parameter is only valid if the `type` parameter is `container`.
-
name
public com.pulumi.core.Output<java.lang.String> name()
- Returns:
- Specifies the name of the job definition.
-
nodeProperties
public com.pulumi.core.Output<java.util.Optional<java.lang.String>> nodeProperties()
- Returns:
- A valid [node properties](http://docs.aws.amazon.com/batch/latest/APIReference/API_RegisterJobDefinition.html) provided as a single valid JSON document. This parameter is required if the `type` parameter is `multinode`.
-
parameters
public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>> parameters()
- Returns:
- Specifies the parameter substitution placeholders to set in the job definition.
-
platformCapabilities
public com.pulumi.core.Output<java.util.Optional<java.util.List<java.lang.String>>> platformCapabilities()
- Returns:
- The 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`.
-
propagateTags
public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> propagateTags()
- Returns:
- Specifies whether to propagate the tags from the job definition to the corresponding Amazon ECS task. Default is `false`.
-
retryStrategy
public com.pulumi.core.Output<java.util.Optional<JobDefinitionRetryStrategy>> retryStrategy()
- Returns:
- Specifies the retry strategy to use for failed jobs that are submitted with this job definition. Maximum number of `retry_strategy` is `1`. Defined below.
-
revision
public com.pulumi.core.Output<java.lang.Integer> revision()
- Returns:
- The revision of the job definition.
-
schedulingPriority
public com.pulumi.core.Output<java.util.Optional<java.lang.Integer>> schedulingPriority()
- Returns:
- The 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`.
-
tags
public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,java.lang.String>>> tags()
- Returns:
- Key-value map of resource tags. .If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
-
tagsAll
public com.pulumi.core.Output<java.util.Map<java.lang.String,java.lang.String>> tagsAll()
- Returns:
- A map of tags assigned to the resource, including those inherited from the provider `default_tags` configuration block.
-
timeout
public com.pulumi.core.Output<java.util.Optional<JobDefinitionTimeout>> timeout()
- Returns:
- Specifies the timeout for jobs so that if a job runs longer, AWS Batch terminates the job. Maximum number of `timeout` is `1`. Defined below.
-
type
public com.pulumi.core.Output<java.lang.String> type()
- Returns:
- The type of job definition. Must be `container` or `multinode`. The following arguments are optional:
-
get
public static JobDefinition get(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, @Nullable JobDefinitionState state, @Nullable com.pulumi.resources.CustomResourceOptions options)
Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.- Parameters:
name
- The _unique_ name of the resulting resource.id
- The _unique_ provider ID of the resource to lookup.state
-options
- Optional settings to control the behavior of the CustomResource.
-
-