UNPKG

@pulumi/aws

Version:

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

256 lines • 11.3 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.Service = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * > **Note:** To prevent a race condition during service deletion, make sure to set `dependsOn` to the related `aws.iam.RolePolicy`; otherwise, the policy may be destroyed too soon and the ECS service will then get stuck in the `DRAINING` state. * * Provides an ECS service - effectively a task that is expected to run until an error occurs or a user terminates it (typically a webserver or a database). * * See [ECS Services section in AWS developer guide](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs_services.html). * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const mongo = new aws.ecs.Service("mongo", { * name: "mongodb", * cluster: fooAwsEcsCluster.id, * taskDefinition: mongoAwsEcsTaskDefinition.arn, * desiredCount: 3, * iamRole: fooAwsIamRole.arn, * orderedPlacementStrategies: [{ * type: "binpack", * field: "cpu", * }], * loadBalancers: [{ * targetGroupArn: fooAwsLbTargetGroup.arn, * containerName: "mongo", * containerPort: 8080, * }], * placementConstraints: [{ * type: "memberOf", * expression: "attribute:ecs.availability-zone in [us-west-2a, us-west-2b]", * }], * }, { * dependsOn: [foo], * }); * ``` * * ### Ignoring Changes to Desired Count * * You can use [`ignoreChanges`](https://www.pulumi.com/docs/intro/concepts/programming-model/#ignorechanges) to create an ECS service with an initial count of running instances, then ignore any changes to that count caused externally (e.g. Application Autoscaling). * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.ecs.Service("example", {desiredCount: 2}); * ``` * * ### Daemon Scheduling Strategy * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const bar = new aws.ecs.Service("bar", { * name: "bar", * cluster: foo.id, * taskDefinition: barAwsEcsTaskDefinition.arn, * schedulingStrategy: "DAEMON", * }); * ``` * * ### CloudWatch Deployment Alarms * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.ecs.Service("example", { * name: "example", * cluster: exampleAwsEcsCluster.id, * alarms: { * enable: true, * rollback: true, * alarmNames: [exampleAwsCloudwatchMetricAlarm.alarmName], * }, * }); * ``` * * ### External Deployment Controller * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.ecs.Service("example", { * name: "example", * cluster: exampleAwsEcsCluster.id, * deploymentController: { * type: "EXTERNAL", * }, * }); * ``` * * ### Blue/Green Deployment with SIGINT Rollback * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.ecs.Service("example", { * name: "example", * cluster: exampleAwsEcsCluster.id, * deploymentConfiguration: { * strategy: "BLUE_GREEN", * }, * sigintRollback: true, * waitForSteadyState: true, * }); * ``` * * ### Redeploy Service On Every Apply * * The key used with `triggers` is arbitrary. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as aws from "@pulumi/aws"; * * const example = new aws.ecs.Service("example", { * forceNewDeployment: true, * triggers: { * redeployment: "plantimestamp()", * }, * }); * ``` * * ## Import * * Using `pulumi import`, import ECS services using the `name` together with ecs cluster `name`. For example: * * ```sh * $ pulumi import aws:ecs/service:Service imported cluster-name/service-name * ``` */ class Service extends pulumi.CustomResource { /** * Get an existing Service 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 Service(name, state, { ...opts, id: id }); } /** * Returns true if the given object is an instance of Service. 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'] === Service.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["alarms"] = state?.alarms; resourceInputs["arn"] = state?.arn; resourceInputs["availabilityZoneRebalancing"] = state?.availabilityZoneRebalancing; resourceInputs["capacityProviderStrategies"] = state?.capacityProviderStrategies; resourceInputs["cluster"] = state?.cluster; resourceInputs["deploymentCircuitBreaker"] = state?.deploymentCircuitBreaker; resourceInputs["deploymentConfiguration"] = state?.deploymentConfiguration; resourceInputs["deploymentController"] = state?.deploymentController; resourceInputs["deploymentMaximumPercent"] = state?.deploymentMaximumPercent; resourceInputs["deploymentMinimumHealthyPercent"] = state?.deploymentMinimumHealthyPercent; resourceInputs["desiredCount"] = state?.desiredCount; resourceInputs["enableEcsManagedTags"] = state?.enableEcsManagedTags; resourceInputs["enableExecuteCommand"] = state?.enableExecuteCommand; resourceInputs["forceDelete"] = state?.forceDelete; resourceInputs["forceNewDeployment"] = state?.forceNewDeployment; resourceInputs["healthCheckGracePeriodSeconds"] = state?.healthCheckGracePeriodSeconds; resourceInputs["iamRole"] = state?.iamRole; resourceInputs["launchType"] = state?.launchType; resourceInputs["loadBalancers"] = state?.loadBalancers; resourceInputs["name"] = state?.name; resourceInputs["networkConfiguration"] = state?.networkConfiguration; resourceInputs["orderedPlacementStrategies"] = state?.orderedPlacementStrategies; resourceInputs["placementConstraints"] = state?.placementConstraints; resourceInputs["platformVersion"] = state?.platformVersion; resourceInputs["propagateTags"] = state?.propagateTags; resourceInputs["region"] = state?.region; resourceInputs["schedulingStrategy"] = state?.schedulingStrategy; resourceInputs["serviceConnectConfiguration"] = state?.serviceConnectConfiguration; resourceInputs["serviceRegistries"] = state?.serviceRegistries; resourceInputs["sigintRollback"] = state?.sigintRollback; resourceInputs["tags"] = state?.tags; resourceInputs["tagsAll"] = state?.tagsAll; resourceInputs["taskDefinition"] = state?.taskDefinition; resourceInputs["triggers"] = state?.triggers; resourceInputs["volumeConfiguration"] = state?.volumeConfiguration; resourceInputs["vpcLatticeConfigurations"] = state?.vpcLatticeConfigurations; resourceInputs["waitForSteadyState"] = state?.waitForSteadyState; } else { const args = argsOrState; resourceInputs["alarms"] = args?.alarms; resourceInputs["availabilityZoneRebalancing"] = args?.availabilityZoneRebalancing; resourceInputs["capacityProviderStrategies"] = args?.capacityProviderStrategies; resourceInputs["cluster"] = args?.cluster; resourceInputs["deploymentCircuitBreaker"] = args?.deploymentCircuitBreaker; resourceInputs["deploymentConfiguration"] = args?.deploymentConfiguration; resourceInputs["deploymentController"] = args?.deploymentController; resourceInputs["deploymentMaximumPercent"] = args?.deploymentMaximumPercent; resourceInputs["deploymentMinimumHealthyPercent"] = args?.deploymentMinimumHealthyPercent; resourceInputs["desiredCount"] = args?.desiredCount; resourceInputs["enableEcsManagedTags"] = args?.enableEcsManagedTags; resourceInputs["enableExecuteCommand"] = args?.enableExecuteCommand; resourceInputs["forceDelete"] = args?.forceDelete; resourceInputs["forceNewDeployment"] = args?.forceNewDeployment; resourceInputs["healthCheckGracePeriodSeconds"] = args?.healthCheckGracePeriodSeconds; resourceInputs["iamRole"] = args?.iamRole; resourceInputs["launchType"] = args?.launchType; resourceInputs["loadBalancers"] = args?.loadBalancers; resourceInputs["name"] = args?.name; resourceInputs["networkConfiguration"] = args?.networkConfiguration; resourceInputs["orderedPlacementStrategies"] = args?.orderedPlacementStrategies; resourceInputs["placementConstraints"] = args?.placementConstraints; resourceInputs["platformVersion"] = args?.platformVersion; resourceInputs["propagateTags"] = args?.propagateTags; resourceInputs["region"] = args?.region; resourceInputs["schedulingStrategy"] = args?.schedulingStrategy; resourceInputs["serviceConnectConfiguration"] = args?.serviceConnectConfiguration; resourceInputs["serviceRegistries"] = args?.serviceRegistries; resourceInputs["sigintRollback"] = args?.sigintRollback; resourceInputs["tags"] = args?.tags; resourceInputs["taskDefinition"] = args?.taskDefinition; resourceInputs["triggers"] = args?.triggers; resourceInputs["volumeConfiguration"] = args?.volumeConfiguration; resourceInputs["vpcLatticeConfigurations"] = args?.vpcLatticeConfigurations; resourceInputs["waitForSteadyState"] = args?.waitForSteadyState; resourceInputs["arn"] = undefined /*out*/; resourceInputs["tagsAll"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(Service.__pulumiType, name, resourceInputs, opts); } } exports.Service = Service; /** @internal */ Service.__pulumiType = 'aws:ecs/service:Service'; //# sourceMappingURL=service.js.map