UNPKG

@pulumi/aws

Version:

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

333 lines • 11.9 kB
"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.TaskDefinition = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Manages a revision of an ECS task definition to be used in `aws.ecs.Service`. * * ## Example Usage * * ### Basic Example * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const service = new aws.ecs.TaskDefinition("service", { * family: "service", * containerDefinitions: JSON.stringify([ * { * name: "first", * image: "service-first", * cpu: 10, * memory: 512, * essential: true, * portMappings: [{ * containerPort: 80, * hostPort: 80, * }], * }, * { * name: "second", * image: "service-second", * cpu: 10, * memory: 256, * essential: true, * portMappings: [{ * containerPort: 443, * hostPort: 443, * }], * }, * ]), * volumes: [{ * name: "service-storage", * hostPath: "/ecs/service-storage", * }], * placementConstraints: [{ * type: "memberOf", * expression: "attribute:ecs.availability-zone in [us-west-2a, us-west-2b]", * }], * }); * ``` * * ### With AppMesh Proxy * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * import * as std from "@pulumi/std"; * * const service = new aws.ecs.TaskDefinition("service", { * family: "service", * containerDefinitions: std.file({ * input: "task-definitions/service.json", * }).then(invoke => invoke.result), * proxyConfiguration: { * type: "APPMESH", * containerName: "applicationContainerName", * properties: { * AppPorts: "8080", * EgressIgnoredIPs: "169.254.170.2,169.254.169.254", * IgnoredUID: "1337", * ProxyEgressPort: "15001", * ProxyIngressPort: "15000", * }, * }, * }); * ``` * * ### Example Using `dockerVolumeConfiguration` * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * import * as std from "@pulumi/std"; * * const service = new aws.ecs.TaskDefinition("service", { * family: "service", * containerDefinitions: std.file({ * input: "task-definitions/service.json", * }).then(invoke => invoke.result), * volumes: [{ * name: "service-storage", * dockerVolumeConfiguration: { * scope: "shared", * autoprovision: true, * driver: "local", * driverOpts: { * type: "nfs", * device: `${fs.dnsName}:/`, * o: `addr=${fs.dnsName},rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport`, * }, * }, * }], * }); * ``` * * ### Example Using `efsVolumeConfiguration` * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * import * as std from "@pulumi/std"; * * const service = new aws.ecs.TaskDefinition("service", { * family: "service", * containerDefinitions: std.file({ * input: "task-definitions/service.json", * }).then(invoke => invoke.result), * volumes: [{ * name: "service-storage", * efsVolumeConfiguration: { * fileSystemId: fs.id, * rootDirectory: "/opt/data", * transitEncryption: "ENABLED", * transitEncryptionPort: 2999, * authorizationConfig: { * accessPointId: test.id, * iam: "ENABLED", * }, * }, * }], * }); * ``` * * ### Example Using `fsxWindowsFileServerVolumeConfiguration` * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * import * as std from "@pulumi/std"; * * const test = new aws.secretsmanager.SecretVersion("test", { * secretId: testAwsSecretsmanagerSecret.id, * secretString: JSON.stringify({ * username: "admin", * password: testAwsDirectoryServiceDirectory.password, * }), * }); * const service = new aws.ecs.TaskDefinition("service", { * family: "service", * containerDefinitions: std.file({ * input: "task-definitions/service.json", * }).then(invoke => invoke.result), * volumes: [{ * name: "service-storage", * fsxWindowsFileServerVolumeConfiguration: { * fileSystemId: testAwsFsxWindowsFileSystem.id, * rootDirectory: "\\data", * authorizationConfig: { * credentialsParameter: test.arn, * domain: testAwsDirectoryServiceDirectory.name, * }, * }, * }], * }); * ``` * * ### Example Using `containerDefinitions` * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const test = new aws.ecs.TaskDefinition("test", { * family: "test", * containerDefinitions: `[ * { * "cpu": 10, * "command": ["sleep", "10"], * "entryPoint": ["/"], * "environment": [ * {"name": "VARNAME", "value": "VARVAL"} * ], * "essential": true, * "image": "jenkins", * "memory": 128, * "name": "jenkins", * "portMappings": [ * { * "containerPort": 80, * "hostPort": 8080 * } * ] * } * ] * `, * }); * ``` * * ### Example Using `runtimePlatform` and `fargate` * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const test = new aws.ecs.TaskDefinition("test", { * family: "test", * requiresCompatibilities: ["FARGATE"], * networkMode: "awsvpc", * cpu: "1024", * memory: "2048", * containerDefinitions: `[ * { * "name": "iis", * "image": "mcr.microsoft.com/windows/servercore/iis", * "cpu": 1024, * "memory": 2048, * "essential": true * } * ] * `, * runtimePlatform: { * operatingSystemFamily: "WINDOWS_SERVER_2019_CORE", * cpuArchitecture: "X86_64", * }, * }); * ``` * * ## Import * * Using `pulumi import`, import ECS Task Definitions using their ARNs. For example: * * ```sh * $ pulumi import aws:ecs/taskDefinition:TaskDefinition example arn:aws:ecs:us-east-1:012345678910:task-definition/mytaskfamily:123 * ``` */ class TaskDefinition extends pulumi.CustomResource { /** * Get an existing TaskDefinition 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 TaskDefinition(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of TaskDefinition. 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'] === TaskDefinition.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["arn"] = state?.arn; resourceInputs["arnWithoutRevision"] = state?.arnWithoutRevision; resourceInputs["containerDefinitions"] = state?.containerDefinitions; resourceInputs["cpu"] = state?.cpu; resourceInputs["enableFaultInjection"] = state?.enableFaultInjection; resourceInputs["ephemeralStorage"] = state?.ephemeralStorage; resourceInputs["executionRoleArn"] = state?.executionRoleArn; resourceInputs["family"] = state?.family; resourceInputs["ipcMode"] = state?.ipcMode; resourceInputs["memory"] = state?.memory; resourceInputs["networkMode"] = state?.networkMode; resourceInputs["pidMode"] = state?.pidMode; resourceInputs["placementConstraints"] = state?.placementConstraints; resourceInputs["proxyConfiguration"] = state?.proxyConfiguration; resourceInputs["region"] = state?.region; resourceInputs["requiresCompatibilities"] = state?.requiresCompatibilities; resourceInputs["revision"] = state?.revision; resourceInputs["runtimePlatform"] = state?.runtimePlatform; resourceInputs["skipDestroy"] = state?.skipDestroy; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; resourceInputs["taskRoleArn"] = state?.taskRoleArn; resourceInputs["trackLatest"] = state?.trackLatest; resourceInputs["volumes"] = state?.volumes; } else { const args = argsOrState; if (args?.containerDefinitions === undefined && !opts.urn) { throw new Error("Missing required property 'containerDefinitions'"); } if (args?.family === undefined && !opts.urn) { throw new Error("Missing required property 'family'"); } resourceInputs["containerDefinitions"] = args?.containerDefinitions; resourceInputs["cpu"] = args?.cpu; resourceInputs["enableFaultInjection"] = args?.enableFaultInjection; resourceInputs["ephemeralStorage"] = args?.ephemeralStorage; resourceInputs["executionRoleArn"] = args?.executionRoleArn; resourceInputs["family"] = args?.family; resourceInputs["ipcMode"] = args?.ipcMode; resourceInputs["memory"] = args?.memory; resourceInputs["networkMode"] = args?.networkMode; resourceInputs["pidMode"] = args?.pidMode; resourceInputs["placementConstraints"] = args?.placementConstraints; resourceInputs["proxyConfiguration"] = args?.proxyConfiguration; resourceInputs["region"] = args?.region; resourceInputs["requiresCompatibilities"] = args?.requiresCompatibilities; resourceInputs["runtimePlatform"] = args?.runtimePlatform; resourceInputs["skipDestroy"] = args?.skipDestroy; resourceInputs["tags"] = args?.tags; resourceInputs["taskRoleArn"] = args?.taskRoleArn; resourceInputs["trackLatest"] = args?.trackLatest; resourceInputs["volumes"] = args?.volumes; resourceInputs["arn"] = undefined /*out*/; resourceInputs["arnWithoutRevision"] = undefined /*out*/; resourceInputs["revision"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(TaskDefinition.__pulumiType, name, resourceInputs, opts); } } exports.TaskDefinition = TaskDefinition; /** @internal */ TaskDefinition.__pulumiType = 'aws:ecs/taskDefinition:TaskDefinition'; //# sourceMappingURL=taskDefinition.js.map