@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
237 lines • 12.1 kB
JavaScript
;
// *** 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",
* },
* });
* ```
*
* ### 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, Object.assign(Object.assign({}, 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 ? state.alarms : undefined;
resourceInputs["arn"] = state ? state.arn : undefined;
resourceInputs["availabilityZoneRebalancing"] = state ? state.availabilityZoneRebalancing : undefined;
resourceInputs["capacityProviderStrategies"] = state ? state.capacityProviderStrategies : undefined;
resourceInputs["cluster"] = state ? state.cluster : undefined;
resourceInputs["deploymentCircuitBreaker"] = state ? state.deploymentCircuitBreaker : undefined;
resourceInputs["deploymentConfiguration"] = state ? state.deploymentConfiguration : undefined;
resourceInputs["deploymentController"] = state ? state.deploymentController : undefined;
resourceInputs["deploymentMaximumPercent"] = state ? state.deploymentMaximumPercent : undefined;
resourceInputs["deploymentMinimumHealthyPercent"] = state ? state.deploymentMinimumHealthyPercent : undefined;
resourceInputs["desiredCount"] = state ? state.desiredCount : undefined;
resourceInputs["enableEcsManagedTags"] = state ? state.enableEcsManagedTags : undefined;
resourceInputs["enableExecuteCommand"] = state ? state.enableExecuteCommand : undefined;
resourceInputs["forceDelete"] = state ? state.forceDelete : undefined;
resourceInputs["forceNewDeployment"] = state ? state.forceNewDeployment : undefined;
resourceInputs["healthCheckGracePeriodSeconds"] = state ? state.healthCheckGracePeriodSeconds : undefined;
resourceInputs["iamRole"] = state ? state.iamRole : undefined;
resourceInputs["launchType"] = state ? state.launchType : undefined;
resourceInputs["loadBalancers"] = state ? state.loadBalancers : undefined;
resourceInputs["name"] = state ? state.name : undefined;
resourceInputs["networkConfiguration"] = state ? state.networkConfiguration : undefined;
resourceInputs["orderedPlacementStrategies"] = state ? state.orderedPlacementStrategies : undefined;
resourceInputs["placementConstraints"] = state ? state.placementConstraints : undefined;
resourceInputs["platformVersion"] = state ? state.platformVersion : undefined;
resourceInputs["propagateTags"] = state ? state.propagateTags : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["schedulingStrategy"] = state ? state.schedulingStrategy : undefined;
resourceInputs["serviceConnectConfiguration"] = state ? state.serviceConnectConfiguration : undefined;
resourceInputs["serviceRegistries"] = state ? state.serviceRegistries : undefined;
resourceInputs["tags"] = state ? state.tags : undefined;
resourceInputs["tagsAll"] = state ? state.tagsAll : undefined;
resourceInputs["taskDefinition"] = state ? state.taskDefinition : undefined;
resourceInputs["triggers"] = state ? state.triggers : undefined;
resourceInputs["volumeConfiguration"] = state ? state.volumeConfiguration : undefined;
resourceInputs["vpcLatticeConfigurations"] = state ? state.vpcLatticeConfigurations : undefined;
resourceInputs["waitForSteadyState"] = state ? state.waitForSteadyState : undefined;
}
else {
const args = argsOrState;
resourceInputs["alarms"] = args ? args.alarms : undefined;
resourceInputs["availabilityZoneRebalancing"] = args ? args.availabilityZoneRebalancing : undefined;
resourceInputs["capacityProviderStrategies"] = args ? args.capacityProviderStrategies : undefined;
resourceInputs["cluster"] = args ? args.cluster : undefined;
resourceInputs["deploymentCircuitBreaker"] = args ? args.deploymentCircuitBreaker : undefined;
resourceInputs["deploymentConfiguration"] = args ? args.deploymentConfiguration : undefined;
resourceInputs["deploymentController"] = args ? args.deploymentController : undefined;
resourceInputs["deploymentMaximumPercent"] = args ? args.deploymentMaximumPercent : undefined;
resourceInputs["deploymentMinimumHealthyPercent"] = args ? args.deploymentMinimumHealthyPercent : undefined;
resourceInputs["desiredCount"] = args ? args.desiredCount : undefined;
resourceInputs["enableEcsManagedTags"] = args ? args.enableEcsManagedTags : undefined;
resourceInputs["enableExecuteCommand"] = args ? args.enableExecuteCommand : undefined;
resourceInputs["forceDelete"] = args ? args.forceDelete : undefined;
resourceInputs["forceNewDeployment"] = args ? args.forceNewDeployment : undefined;
resourceInputs["healthCheckGracePeriodSeconds"] = args ? args.healthCheckGracePeriodSeconds : undefined;
resourceInputs["iamRole"] = args ? args.iamRole : undefined;
resourceInputs["launchType"] = args ? args.launchType : undefined;
resourceInputs["loadBalancers"] = args ? args.loadBalancers : undefined;
resourceInputs["name"] = args ? args.name : undefined;
resourceInputs["networkConfiguration"] = args ? args.networkConfiguration : undefined;
resourceInputs["orderedPlacementStrategies"] = args ? args.orderedPlacementStrategies : undefined;
resourceInputs["placementConstraints"] = args ? args.placementConstraints : undefined;
resourceInputs["platformVersion"] = args ? args.platformVersion : undefined;
resourceInputs["propagateTags"] = args ? args.propagateTags : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["schedulingStrategy"] = args ? args.schedulingStrategy : undefined;
resourceInputs["serviceConnectConfiguration"] = args ? args.serviceConnectConfiguration : undefined;
resourceInputs["serviceRegistries"] = args ? args.serviceRegistries : undefined;
resourceInputs["tags"] = args ? args.tags : undefined;
resourceInputs["taskDefinition"] = args ? args.taskDefinition : undefined;
resourceInputs["triggers"] = args ? args.triggers : undefined;
resourceInputs["volumeConfiguration"] = args ? args.volumeConfiguration : undefined;
resourceInputs["vpcLatticeConfigurations"] = args ? args.vpcLatticeConfigurations : undefined;
resourceInputs["waitForSteadyState"] = args ? args.waitForSteadyState : undefined;
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