@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
359 lines • 12.8 kB
JavaScript
"use strict";
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.JobDefinition = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* 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
* ```
*/
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, id, state, opts) {
return new JobDefinition(name, state, { ...opts, id: id });
}
/**
* 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) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === JobDefinition.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["arn"] = state?.arn;
resourceInputs["arnPrefix"] = state?.arnPrefix;
resourceInputs["containerProperties"] = state?.containerProperties;
resourceInputs["deregisterOnNewRevision"] = state?.deregisterOnNewRevision;
resourceInputs["ecsProperties"] = state?.ecsProperties;
resourceInputs["eksProperties"] = state?.eksProperties;
resourceInputs["name"] = state?.name;
resourceInputs["nodeProperties"] = state?.nodeProperties;
resourceInputs["parameters"] = state?.parameters;
resourceInputs["platformCapabilities"] = state?.platformCapabilities;
resourceInputs["propagateTags"] = state?.propagateTags;
resourceInputs["region"] = state?.region;
resourceInputs["retryStrategy"] = state?.retryStrategy;
resourceInputs["revision"] = state?.revision;
resourceInputs["schedulingPriority"] = state?.schedulingPriority;
resourceInputs["tags"] = state?.tags;
resourceInputs["tagsAll"] = state?.tagsAll;
resourceInputs["timeout"] = state?.timeout;
resourceInputs["type"] = state?.type;
}
else {
const args = argsOrState;
if (args?.type === undefined && !opts.urn) {
throw new Error("Missing required property 'type'");
}
resourceInputs["containerProperties"] = args?.containerProperties;
resourceInputs["deregisterOnNewRevision"] = args?.deregisterOnNewRevision;
resourceInputs["ecsProperties"] = args?.ecsProperties;
resourceInputs["eksProperties"] = args?.eksProperties;
resourceInputs["name"] = args?.name;
resourceInputs["nodeProperties"] = args?.nodeProperties;
resourceInputs["parameters"] = args?.parameters;
resourceInputs["platformCapabilities"] = args?.platformCapabilities;
resourceInputs["propagateTags"] = args?.propagateTags;
resourceInputs["region"] = args?.region;
resourceInputs["retryStrategy"] = args?.retryStrategy;
resourceInputs["schedulingPriority"] = args?.schedulingPriority;
resourceInputs["tags"] = args?.tags;
resourceInputs["timeout"] = args?.timeout;
resourceInputs["type"] = args?.type;
resourceInputs["arn"] = undefined /*out*/;
resourceInputs["arnPrefix"] = undefined /*out*/;
resourceInputs["revision"] = undefined /*out*/;
resourceInputs["tagsAll"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(JobDefinition.__pulumiType, name, resourceInputs, opts);
}
}
exports.JobDefinition = JobDefinition;
/** @internal */
JobDefinition.__pulumiType = 'aws:batch/jobDefinition:JobDefinition';
//# sourceMappingURL=jobDefinition.js.map