UNPKG

@pulumi/aws

Version:

A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.

544 lines (543 loc) • 21.7 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Provides a Batch Job Definition resource. * * ## Example Usage * * ### Job definition of type container * * ```typescript * 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, * }], * }), * }); * ``` * * ### Job definition of type multinode * * ```typescript * 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, * }), * }); * ``` * * ### Job Definition of type EKS * * ```typescript * 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_eks", * type: "container", * eksProperties: { * podProperties: { * hostNetwork: true, * containers: [{ * image: "public.ecr.aws/amazonlinux/amazonlinux:1", * commands: [ * "sleep", * "60", * ], * resources: { * limits: { * cpu: "1", * memory: "1024Mi", * }, * }, * }], * metadata: { * labels: { * environment: "test", * }, * }, * }, * }, * }); * ``` * * ### Fargate Platform Capability * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const assumeRolePolicy = aws.iam.getPolicyDocument({ * statements: [{ * actions: ["sts:AssumeRole"], * principals: [{ * type: "Service", * identifiers: ["ecs-tasks.amazonaws.com"], * }], * }], * }); * 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, * }), * }); * ``` * * ### Job definition of type container using `ecsProperties` * * ```typescript * 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 * * Using `pulumi import`, import Batch Job Definition using the `arn`. For example: * * ```sh * $ pulumi import aws:batch/jobDefinition:JobDefinition test arn:aws:batch:us-east-1:123456789012:job-definition/sample * ``` */ export declare class JobDefinition extends pulumi.CustomResource { /** * Get an existing JobDefinition resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input<pulumi.ID>, state?: JobDefinitionState, opts?: pulumi.CustomResourceOptions): JobDefinition; /** * Returns true if the given object is an instance of JobDefinition. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is JobDefinition; /** * ARN of the job definition, includes revision (`:#`). */ readonly arn: pulumi.Output<string>; /** * ARN without the revision number. */ readonly arnPrefix: pulumi.Output<string>; /** * 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`. */ readonly containerProperties: pulumi.Output<string | undefined>; /** * 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`. */ readonly deregisterOnNewRevision: pulumi.Output<boolean | undefined>; /** * Valid [ECS 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`. */ readonly ecsProperties: pulumi.Output<string | undefined>; /** * Valid eks properties. This parameter is only valid if the `type` parameter is `container`. */ readonly eksProperties: pulumi.Output<outputs.batch.JobDefinitionEksProperties | undefined>; /** * Name of the job definition. */ readonly name: pulumi.Output<string>; /** * 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`. */ readonly nodeProperties: pulumi.Output<string | undefined>; /** * Parameter substitution placeholders to set in the job definition. */ readonly parameters: pulumi.Output<{ [key: string]: string; } | undefined>; /** * 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`. */ readonly platformCapabilities: pulumi.Output<string[] | undefined>; /** * Whether to propagate the tags from the job definition to the corresponding Amazon ECS task. Default is `false`. */ readonly propagateTags: pulumi.Output<boolean | undefined>; /** * Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration. */ readonly region: pulumi.Output<string>; /** * Retry strategy to use for failed jobs that are submitted with this job definition. Maximum number of `retryStrategy` is `1`. Defined below. */ readonly retryStrategy: pulumi.Output<outputs.batch.JobDefinitionRetryStrategy | undefined>; /** * Revision of the job definition. */ readonly revision: pulumi.Output<number>; /** * 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`. */ readonly schedulingPriority: pulumi.Output<number | undefined>; /** * 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. */ readonly tags: pulumi.Output<{ [key: string]: string; } | undefined>; /** * Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. */ readonly tagsAll: pulumi.Output<{ [key: string]: string; }>; /** * Timeout for jobs so that if a job runs longer, AWS Batch terminates the job. Maximum number of `timeout` is `1`. Defined below. */ readonly timeout: pulumi.Output<outputs.batch.JobDefinitionTimeout | undefined>; /** * Type of job definition. Must be `container` or `multinode`. * * The following arguments are optional: */ readonly type: pulumi.Output<string>; /** * Create a JobDefinition resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: JobDefinitionArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering JobDefinition resources. */ export interface JobDefinitionState { /** * ARN of the job definition, includes revision (`:#`). */ arn?: pulumi.Input<string>; /** * ARN without the revision number. */ arnPrefix?: pulumi.Input<string>; /** * 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`. */ containerProperties?: pulumi.Input<string>; /** * 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`. */ deregisterOnNewRevision?: pulumi.Input<boolean>; /** * Valid [ECS 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`. */ ecsProperties?: pulumi.Input<string>; /** * Valid eks properties. This parameter is only valid if the `type` parameter is `container`. */ eksProperties?: pulumi.Input<inputs.batch.JobDefinitionEksProperties>; /** * Name of the job definition. */ name?: pulumi.Input<string>; /** * 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`. */ nodeProperties?: pulumi.Input<string>; /** * Parameter substitution placeholders to set in the job definition. */ parameters?: pulumi.Input<{ [key: string]: pulumi.Input<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`. */ platformCapabilities?: pulumi.Input<pulumi.Input<string>[]>; /** * Whether to propagate the tags from the job definition to the corresponding Amazon ECS task. Default is `false`. */ propagateTags?: pulumi.Input<boolean>; /** * Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration. */ region?: pulumi.Input<string>; /** * Retry strategy to use for failed jobs that are submitted with this job definition. Maximum number of `retryStrategy` is `1`. Defined below. */ retryStrategy?: pulumi.Input<inputs.batch.JobDefinitionRetryStrategy>; /** * Revision of the job definition. */ revision?: pulumi.Input<number>; /** * 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`. */ schedulingPriority?: pulumi.Input<number>; /** * 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. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block. */ tagsAll?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * Timeout for jobs so that if a job runs longer, AWS Batch terminates the job. Maximum number of `timeout` is `1`. Defined below. */ timeout?: pulumi.Input<inputs.batch.JobDefinitionTimeout>; /** * Type of job definition. Must be `container` or `multinode`. * * The following arguments are optional: */ type?: pulumi.Input<string>; } /** * The set of arguments for constructing a JobDefinition resource. */ export interface JobDefinitionArgs { /** * 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`. */ containerProperties?: pulumi.Input<string>; /** * 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`. */ deregisterOnNewRevision?: pulumi.Input<boolean>; /** * Valid [ECS 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`. */ ecsProperties?: pulumi.Input<string>; /** * Valid eks properties. This parameter is only valid if the `type` parameter is `container`. */ eksProperties?: pulumi.Input<inputs.batch.JobDefinitionEksProperties>; /** * Name of the job definition. */ name?: pulumi.Input<string>; /** * 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`. */ nodeProperties?: pulumi.Input<string>; /** * Parameter substitution placeholders to set in the job definition. */ parameters?: pulumi.Input<{ [key: string]: pulumi.Input<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`. */ platformCapabilities?: pulumi.Input<pulumi.Input<string>[]>; /** * Whether to propagate the tags from the job definition to the corresponding Amazon ECS task. Default is `false`. */ propagateTags?: pulumi.Input<boolean>; /** * Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration. */ region?: pulumi.Input<string>; /** * Retry strategy to use for failed jobs that are submitted with this job definition. Maximum number of `retryStrategy` is `1`. Defined below. */ retryStrategy?: pulumi.Input<inputs.batch.JobDefinitionRetryStrategy>; /** * 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`. */ schedulingPriority?: pulumi.Input<number>; /** * 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. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input<string>; }>; /** * Timeout for jobs so that if a job runs longer, AWS Batch terminates the job. Maximum number of `timeout` is `1`. Defined below. */ timeout?: pulumi.Input<inputs.batch.JobDefinitionTimeout>; /** * Type of job definition. Must be `container` or `multinode`. * * The following arguments are optional: */ type: pulumi.Input<string>; }