UNPKG

@pulumi/aws-native

Version:

The Pulumi AWS Cloud Control Provider enables you to build, deploy, and manage [any AWS resource that's supported by the AWS Cloud Control API](https://github.com/pulumi/pulumi-aws-native/blob/master/provider/cmd/pulumi-gen-aws-native/supported-types.txt)

276 lines • 13.4 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"); /** * Registers a new task definition from the supplied ``family`` and ``containerDefinitions``. Optionally, you can add data volumes to your containers with the ``volumes`` parameter. For more information about task definition parameters and defaults, see [Amazon ECS Task Definitions](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_defintions.html) in the *Amazon Elastic Container Service Developer Guide*. * You can specify a role for your task with the ``taskRoleArn`` parameter. When you specify a role for a task, its containers can then use the latest versions of the CLI or SDKs to make API requests to the AWS services that are specified in the policy that's associated with the role. For more information, see [IAM Roles for Tasks](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html) in the *Amazon Elastic Container Service Developer Guide*. * You can specify a Docker networking mode for the containers in your task definition with the ``networkMode`` parameter. If you specify the ``awsvpc`` network mode, the task is allocated an elastic network interface, and you must specify a [NetworkConfiguration](https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_NetworkConfiguration.html) when you create a service or run a task with the task definition. For more information, see [Task Networking](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-networking.html) in the *Amazon Elastic Container Service Developer Guide*. * In the following example or examples, the Authorization header contents (``AUTHPARAMS``) must be replaced with an AWS Signature Version 4 signature. For more information, see [Signature Version 4 Signing Process](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html) in the *General Reference*. * You only need to learn how to sign HTTP requests if you intend to create them manually. When you use the [](https://docs.aws.amazon.com/cli/) or one of the [SDKs](https://docs.aws.amazon.com/tools/) to make requests to AWS, these tools automatically sign the requests for you, with the access key that you specify when you configure the tools. When you use these tools, you don't have to sign requests yourself. * * ## Example Usage * ### Example * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws_native from "@pulumi/aws-native"; * * const taskdefinition = new aws_native.ecs.TaskDefinition("taskdefinition", { * requiresCompatibilities: ["EC2"], * containerDefinitions: [ * { * name: "my-app", * mountPoints: [{ * sourceVolume: "my-vol", * containerPath: "/var/www/my-vol", * }], * image: "amazon/amazon-ecs-sample", * cpu: 256, * entryPoint: [ * "/usr/sbin/apache2", * "-D", * "FOREGROUND", * ], * memory: 512, * essential: true, * }, * { * name: "busybox", * image: "busybox", * cpu: 256, * entryPoint: [ * "sh", * "-c", * ], * memory: 512, * command: ["/bin/sh -c \"while true; do /bin/date > /var/www/my-vol/date; sleep 1; done\""], * essential: false, * dependsOn: [{ * containerName: "my-app", * condition: "START", * }], * volumesFrom: [{ * sourceContainer: "my-app", * }], * }, * ], * volumes: [{ * host: { * sourcePath: "/var/lib/docker/vfs/dir/", * }, * name: "my-vol", * }], * }); * * ``` * ### Example * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws_native from "@pulumi/aws-native"; * * const taskdefinition = new aws_native.ecs.TaskDefinition("taskdefinition", { * requiresCompatibilities: ["EC2"], * containerDefinitions: [ * { * name: "my-app", * mountPoints: [{ * sourceVolume: "my-vol", * containerPath: "/var/www/my-vol", * }], * image: "amazon/amazon-ecs-sample", * cpu: 256, * entryPoint: [ * "/usr/sbin/apache2", * "-D", * "FOREGROUND", * ], * memory: 512, * essential: true, * }, * { * name: "busybox", * image: "busybox", * cpu: 256, * entryPoint: [ * "sh", * "-c", * ], * memory: 512, * command: ["/bin/sh -c \"while true; do /bin/date > /var/www/my-vol/date; sleep 1; done\""], * essential: false, * dependsOn: [{ * containerName: "my-app", * condition: "START", * }], * volumesFrom: [{ * sourceContainer: "my-app", * }], * }, * ], * volumes: [{ * host: { * sourcePath: "/var/lib/docker/vfs/dir/", * }, * name: "my-vol", * }], * }); * * ``` * ### Example * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws_native from "@pulumi/aws-native"; * * const ecsTaskDefinitionResource = new aws_native.ecs.TaskDefinition("ecsTaskDefinitionResource", { * containerDefinitions: [{ * name: "first-run-task", * image: "httpd:2.4", * essential: true, * portMappings: [{ * containerPort: 80, * protocol: "tcp", * }], * environment: [ * { * name: "entryPoint", * value: "sh, -c", * }, * { * name: "command", * value: "/bin/sh -c \\\"echo '<html> <head> <title>Amazon ECS Sample App</title> <style>body {margin-top: 40px; background-color: #333;} </style> </head><body> <div style=color:white;text-align:center> <h1>Amazon ECS Sample App</h1> <h2>Congratulations!</h2> <p>Your application is now running on a container in Amazon ECS.</p> </div></body></html>' > /usr/local/apache2/htdocs/index.html && httpd-foreground\\\"", * }, * ], * environmentFiles: [], * }], * family: "first-run-task", * cpu: "1 vCPU", * memory: "3 GB", * }); * export const ecsTaskDefinition = ecsTaskDefinitionResource.id; * * ``` * ### Example * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws_native from "@pulumi/aws-native"; * * const ecsTaskDefinitionResource = new aws_native.ecs.TaskDefinition("ecsTaskDefinitionResource", { * containerDefinitions: [{ * name: "first-run-task", * image: "httpd:2.4", * essential: true, * portMappings: [{ * containerPort: 80, * protocol: "tcp", * }], * environment: [ * { * name: "entryPoint", * value: "sh, -c", * }, * { * name: "command", * value: "/bin/sh -c \\\"echo '<html> <head> <title>Amazon ECS Sample App</title> <style>body {margin-top: 40px; background-color: #333;} </style> </head><body> <div style=color:white;text-align:center> <h1>Amazon ECS Sample App</h1> <h2>Congratulations!</h2> <p>Your application is now running on a container in Amazon ECS.</p> </div></body></html>' > /usr/local/apache2/htdocs/index.html && httpd-foreground\\\"", * }, * ], * environmentFiles: [], * }], * family: "first-run-task", * cpu: "1 vCPU", * memory: "3 GB", * }); * export const ecsTaskDefinition = ecsTaskDefinitionResource.id; * * ``` */ 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 opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, opts) { return new TaskDefinition(name, undefined, 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; } /** * Create a TaskDefinition 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, args, opts) { let resourceInputs = {}; opts = opts || {}; if (!opts.id) { 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["inferenceAccelerators"] = args ? args.inferenceAccelerators : 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["requiresCompatibilities"] = args ? args.requiresCompatibilities : undefined; resourceInputs["runtimePlatform"] = args ? args.runtimePlatform : undefined; resourceInputs["tags"] = args ? args.tags : undefined; resourceInputs["taskRoleArn"] = args ? args.taskRoleArn : undefined; resourceInputs["volumes"] = args ? args.volumes : undefined; resourceInputs["taskDefinitionArn"] = undefined /*out*/; } else { resourceInputs["containerDefinitions"] = undefined /*out*/; resourceInputs["cpu"] = undefined /*out*/; resourceInputs["enableFaultInjection"] = undefined /*out*/; resourceInputs["ephemeralStorage"] = undefined /*out*/; resourceInputs["executionRoleArn"] = undefined /*out*/; resourceInputs["family"] = undefined /*out*/; resourceInputs["inferenceAccelerators"] = undefined /*out*/; resourceInputs["ipcMode"] = undefined /*out*/; resourceInputs["memory"] = undefined /*out*/; resourceInputs["networkMode"] = undefined /*out*/; resourceInputs["pidMode"] = undefined /*out*/; resourceInputs["placementConstraints"] = undefined /*out*/; resourceInputs["proxyConfiguration"] = undefined /*out*/; resourceInputs["requiresCompatibilities"] = undefined /*out*/; resourceInputs["runtimePlatform"] = undefined /*out*/; resourceInputs["tags"] = undefined /*out*/; resourceInputs["taskDefinitionArn"] = undefined /*out*/; resourceInputs["taskRoleArn"] = undefined /*out*/; resourceInputs["volumes"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); const replaceOnChanges = { replaceOnChanges: ["containerDefinitions[*]", "cpu", "enableFaultInjection", "ephemeralStorage", "executionRoleArn", "family", "inferenceAccelerators[*]", "ipcMode", "memory", "networkMode", "pidMode", "placementConstraints[*]", "proxyConfiguration", "requiresCompatibilities[*]", "runtimePlatform", "taskRoleArn", "volumes[*]"] }; opts = pulumi.mergeOptions(opts, replaceOnChanges); super(TaskDefinition.__pulumiType, name, resourceInputs, opts); } } exports.TaskDefinition = TaskDefinition; /** @internal */ TaskDefinition.__pulumiType = 'aws-native:ecs:TaskDefinition'; //# sourceMappingURL=taskDefinition.js.map