UNPKG

@pulumi/aws

Version:

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

333 lines • 12.8 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, Object.assign(Object.assign({}, 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 ? state.arn : undefined; resourceInputs["arnWithoutRevision"] = state ? state.arnWithoutRevision : undefined; resourceInputs["containerDefinitions"] = state ? state.containerDefinitions : undefined; resourceInputs["cpu"] = state ? state.cpu : undefined; resourceInputs["enableFaultInjection"] = state ? state.enableFaultInjection : undefined; resourceInputs["ephemeralStorage"] = state ? state.ephemeralStorage : undefined; resourceInputs["executionRoleArn"] = state ? state.executionRoleArn : undefined; resourceInputs["family"] = state ? state.family : undefined; resourceInputs["ipcMode"] = state ? state.ipcMode : undefined; resourceInputs["memory"] = state ? state.memory : undefined; resourceInputs["networkMode"] = state ? state.networkMode : undefined; resourceInputs["pidMode"] = state ? state.pidMode : undefined; resourceInputs["placementConstraints"] = state ? state.placementConstraints : undefined; resourceInputs["proxyConfiguration"] = state ? state.proxyConfiguration : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["requiresCompatibilities"] = state ? state.requiresCompatibilities : undefined; resourceInputs["revision"] = state ? state.revision : undefined; resourceInputs["runtimePlatform"] = state ? state.runtimePlatform : undefined; resourceInputs["skipDestroy"] = state ? state.skipDestroy : undefined; resourceInputs["tags"] = state ? state.tags : undefined; resourceInputs["tagsAll"] = state ? state.tagsAll : undefined; resourceInputs["taskRoleArn"] = state ? state.taskRoleArn : undefined; resourceInputs["trackLatest"] = state ? state.trackLatest : undefined; resourceInputs["volumes"] = state ? state.volumes : undefined; } else { const args = argsOrState; if ((!args || args.containerDefinitions === undefined) && !opts.urn) { throw new Error("Missing required property 'containerDefinitions'"); } if ((!args || args.family === undefined) && !opts.urn) { throw new Error("Missing required property 'family'"); } resourceInputs["containerDefinitions"] = args ? args.containerDefinitions : undefined; resourceInputs["cpu"] = args ? args.cpu : undefined; resourceInputs["enableFaultInjection"] = args ? args.enableFaultInjection : undefined; resourceInputs["ephemeralStorage"] = args ? args.ephemeralStorage : undefined; resourceInputs["executionRoleArn"] = args ? args.executionRoleArn : undefined; resourceInputs["family"] = args ? args.family : undefined; resourceInputs["ipcMode"] = args ? args.ipcMode : undefined; resourceInputs["memory"] = args ? args.memory : undefined; resourceInputs["networkMode"] = args ? args.networkMode : undefined; resourceInputs["pidMode"] = args ? args.pidMode : undefined; resourceInputs["placementConstraints"] = args ? args.placementConstraints : undefined; resourceInputs["proxyConfiguration"] = args ? args.proxyConfiguration : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["requiresCompatibilities"] = args ? args.requiresCompatibilities : undefined; resourceInputs["runtimePlatform"] = args ? args.runtimePlatform : undefined; resourceInputs["skipDestroy"] = args ? args.skipDestroy : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["taskRoleArn"] = args ? args.taskRoleArn : undefined; resourceInputs["trackLatest"] = args ? args.trackLatest : undefined; resourceInputs["volumes"] = args ? args.volumes : undefined; 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