TaskSet class
Provides an ECS task set - 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 Task Set section in AWS developer guide.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.ecs.TaskSet("example", {
loadBalancers: [{
targetGroupArn: exampleAwsLbTargetGroup.arn,
containerName: "mongo",
containerPort: 8080,
}],
service: exampleAwsEcsService.id,
cluster: exampleAwsEcsCluster.id,
taskDefinition: exampleAwsEcsTaskDefinition.arn,
});
import pulumi
import pulumi_aws as aws
example = aws.ecs.TaskSet("example",
load_balancers=[{
"target_group_arn": example_aws_lb_target_group["arn"],
"container_name": "mongo",
"container_port": 8080,
}],
service=example_aws_ecs_service["id"],
cluster=example_aws_ecs_cluster["id"],
task_definition=example_aws_ecs_task_definition["arn"])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.Ecs.TaskSet("example", new()
{
LoadBalancers = new[]
{
new Aws.Ecs.Inputs.TaskSetLoadBalancerArgs
{
TargetGroupArn = exampleAwsLbTargetGroup.Arn,
ContainerName = "mongo",
ContainerPort = 8080,
},
},
Service = exampleAwsEcsService.Id,
Cluster = exampleAwsEcsCluster.Id,
TaskDefinition = exampleAwsEcsTaskDefinition.Arn,
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ecs"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := ecs.NewTaskSet(ctx, "example", &ecs.TaskSetArgs{
LoadBalancers: ecs.TaskSetLoadBalancerArray{
&ecs.TaskSetLoadBalancerArgs{
TargetGroupArn: pulumi.Any(exampleAwsLbTargetGroup.Arn),
ContainerName: pulumi.String("mongo"),
ContainerPort: pulumi.Int(8080),
},
},
Service: pulumi.Any(exampleAwsEcsService.Id),
Cluster: pulumi.Any(exampleAwsEcsCluster.Id),
TaskDefinition: pulumi.Any(exampleAwsEcsTaskDefinition.Arn),
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_ecs_taskset" "example" {
load_balancers {
target_group_arn = exampleAwsLbTargetGroup.arn
container_name = "mongo"
container_port = 8080
}
service = exampleAwsEcsService.id
cluster = exampleAwsEcsCluster.id
task_definition = exampleAwsEcsTaskDefinition.arn
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ecs.TaskSet;
import com.pulumi.aws.ecs.TaskSetArgs;
import com.pulumi.aws.ecs.inputs.TaskSetLoadBalancerArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new TaskSet("example", TaskSetArgs.builder()
.loadBalancers(TaskSetLoadBalancerArgs.builder()
.targetGroupArn(exampleAwsLbTargetGroup.arn())
.containerName("mongo")
.containerPort(8080)
.build())
.service(exampleAwsEcsService.id())
.cluster(exampleAwsEcsCluster.id())
.taskDefinition(exampleAwsEcsTaskDefinition.arn())
.build());
}
}
resources:
example:
type: aws:ecs:TaskSet
properties:
loadBalancers:
- targetGroupArn: ${exampleAwsLbTargetGroup.arn}
containerName: mongo
containerPort: 8080
service: ${exampleAwsEcsService.id}
cluster: ${exampleAwsEcsCluster.id}
taskDefinition: ${exampleAwsEcsTaskDefinition.arn}
Ignoring Changes to Scale
You can utilize the generic resource lifecycle configuration block with 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).
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = new aws.ecs.TaskSet("example", {scale: {
value: 50,
}}, {
ignoreChanges: ["scale"],
});
import pulumi
import pulumi_aws as aws
example = aws.ecs.TaskSet("example", scale={
"value": float(50),
},
opts = pulumi.ResourceOptions(ignore_changes=["scale"]))
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = new Aws.Ecs.TaskSet("example", new()
{
Scale = new Aws.Ecs.Inputs.TaskSetScaleArgs
{
Value = 50,
},
}, new CustomResourceOptions
{
IgnoreChanges =
{
"scale",
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ecs"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := ecs.NewTaskSet(ctx, "example", &ecs.TaskSetArgs{
Scale: &ecs.TaskSetScaleArgs{
Value: pulumi.Float64(50),
},
}, pulumi.IgnoreChanges([]string{
"scale",
}))
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
resource "aws_ecs_taskset" "example" {
lifecycle {
ignore_changes = [scale]
}
scale = {
value = 50
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ecs.TaskSet;
import com.pulumi.aws.ecs.TaskSetArgs;
import com.pulumi.aws.ecs.inputs.TaskSetScaleArgs;
import com.pulumi.resources.CustomResourceOptions;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var example = new TaskSet("example", TaskSetArgs.builder()
.scale(TaskSetScaleArgs.builder()
.value(50.0)
.build())
.build(), CustomResourceOptions.builder()
.ignoreChanges("scale")
.build());
}
}
resources:
example:
type: aws:ecs:TaskSet
properties:
scale:
value: 50
options:
ignoreChanges:
- scale
Import
Using pulumi import, import ECS Task Sets using the taskSetId, service, and cluster separated by commas (,). For example:
$ pulumi import aws:ecs/taskSet:TaskSet example ecs-svc/7177320696926227436,arn:aws:ecs:us-west-2:123456789101:service/example/example-1234567890,arn:aws:ecs:us-west-2:123456789101:cluster/example
Constructors
- TaskSet(String name, {TaskSetArgs? args, CustomResourceOptions? options})
-
Creates a new TaskSet.
nameThe Pulumi resource name.argsArguments used to configure this TaskSet. The set of arguments for TaskSet.optionsResource options controlling this resource's behavior. - TaskSet.reference(String urn)
- Creates a typed reference to an existing TaskSet resource.
Properties
-
arn
↔ Output<
String> -
ARN that identifies the task set.
latefinal
-
capacityProviderStrategies
↔ Output<
List< TaskSetCapacityProviderStrategy> ?> -
Capacity provider strategy to use for the service. Can be one or more. Defined below.
latefinal
-
childResources
→ Set<
Resource> -
finalinherited
-
cluster
↔ Output<
String> -
Short name or ARN of the cluster that hosts the service to create the task set in.
latefinal
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
externalId
↔ Output<
String> -
External ID associated with the task set.
latefinal
-
forceDelete
↔ Output<
bool?> -
Whether to allow deleting the task set without waiting for scaling down to 0. You can force a task set to delete even if it's in the process of scaling a resource. Normally, the provider drains all the tasks before deleting the task set. This bypasses that behavior and potentially leaves resources dangling.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
- isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
launchType
↔ Output<
String> -
Launch type on which to run your service. Valid values are
EC2,FARGATE, andEXTERNAL. Defaults toEC2.latefinal -
loadBalancers
↔ Output<
List< TaskSetLoadBalancer> ?> -
Details on load balancers that are used with a task set. Detailed below.
latefinal
-
networkConfiguration
↔ Output<
TaskSetNetworkConfiguration?> -
Network configuration for the service. Required for task definitions that use the
awsvpcnetwork mode to receive their own Elastic Network Interface, and not supported for other network modes. Detailed below.latefinal -
platformVersion
↔ Output<
String> -
Platform version on which to run your service. Only applicable for
launchTypeset toFARGATE. Defaults toLATEST. More information about Fargate platform versions can be found in the AWS ECS User Guide.latefinal -
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
scale
↔ Output<
TaskSetScale> -
Floating-point percentage of the desired number of tasks to place and keep running in the task set. Detailed below.
latefinal
-
service
↔ Output<
String> -
Short name or ARN of the ECS service.
latefinal
-
serviceRegistries
↔ Output<
TaskSetServiceRegistries?> -
Service discovery registries for the service. The maximum number of
serviceRegistriesblocks is1. Detailed below.latefinal -
stabilityStatus
↔ Output<
String> -
Stability status. This indicates whether the task set has reached a steady state.
latefinal
-
status
↔ Output<
String> -
Status of the task set.
latefinal
-
Map of tags to assign to the file system. If configured with a provider
defaultTagsconfiguration block present, tags with matching keys will overwrite those defined at the provider-level. If you have setcopyTagsToBackupsto true, and you specify one or more tags, no existing file system tags are copied from the file system to the backup.latefinal -
Map of tags assigned to the resource, including those inherited from the provider
defaultTagsconfiguration block.latefinal -
taskDefinition
↔ Output<
String> -
Family and revision (
family:revision) or full ARN of the task definition to run in your service.latefinal -
taskSetId
↔ Output<
String> -
ID of the task set.
latefinal
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
-
waitUntilStable
↔ Output<
bool?> -
Whether the provider should wait until the task set has reached
STEADY_STATE.latefinal -
waitUntilStableTimeout
↔ Output<
String?> -
Wait timeout for task set to reach
STEADY_STATE. Valid time units includens,us(orµs),ms,s,m, andh. Default10m.latefinal
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited