Viewing docs for AWS v5.43.0 (Older version)
published on Tuesday, Mar 10, 2026 by Pulumi
published on Tuesday, Mar 10, 2026 by Pulumi
Viewing docs for AWS v5.43.0 (Older version)
published on Tuesday, Mar 10, 2026 by Pulumi
published on Tuesday, Mar 10, 2026 by Pulumi
The ECS task definition data source allows access to details of a specific AWS ECS task definition.
Example Usage
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var mongoTaskDefinition = Aws.Ecs.GetTaskDefinition.Invoke(new()
{
TaskDefinition = mongoEcs / taskDefinitionTaskDefinition.Family,
});
var foo = new Aws.Ecs.Cluster("foo");
var mongoEcs_taskDefinitionTaskDefinition = new Aws.Ecs.TaskDefinition("mongoEcs/taskDefinitionTaskDefinition", new()
{
Family = "mongodb",
ContainerDefinitions = @"[
{
""cpu"": 128,
""environment"": [{
""name"": ""SECRET"",
""value"": ""KEY""
}],
""essential"": true,
""image"": ""mongo:latest"",
""memory"": 128,
""memoryReservation"": 64,
""name"": ""mongodb""
}
]
",
});
var mongoService = new Aws.Ecs.Service("mongoService", new()
{
Cluster = foo.Id,
DesiredCount = 2,
TaskDefinition = mongoTaskDefinition.Apply(getTaskDefinitionResult => getTaskDefinitionResult.Arn),
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ecs"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
mongoTaskDefinition, err := ecs.LookupTaskDefinition(ctx, &ecs.LookupTaskDefinitionArgs{
TaskDefinition: mongoEcs / taskDefinitionTaskDefinition.Family,
}, nil)
if err != nil {
return err
}
foo, err := ecs.NewCluster(ctx, "foo", nil)
if err != nil {
return err
}
_, err = ecs.NewTaskDefinition(ctx, "mongoEcs/taskDefinitionTaskDefinition", &ecs.TaskDefinitionArgs{
Family: pulumi.String("mongodb"),
ContainerDefinitions: pulumi.String(`[
{
"cpu": 128,
"environment": [{
"name": "SECRET",
"value": "KEY"
}],
"essential": true,
"image": "mongo:latest",
"memory": 128,
"memoryReservation": 64,
"name": "mongodb"
}
]
`),
})
if err != nil {
return err
}
_, err = ecs.NewService(ctx, "mongoService", &ecs.ServiceArgs{
Cluster: foo.ID(),
DesiredCount: pulumi.Int(2),
TaskDefinition: *pulumi.String(mongoTaskDefinition.Arn),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ecs.EcsFunctions;
import com.pulumi.aws.ecs.inputs.GetTaskDefinitionArgs;
import com.pulumi.aws.ecs.Cluster;
import com.pulumi.aws.ecs.TaskDefinition;
import com.pulumi.aws.ecs.TaskDefinitionArgs;
import com.pulumi.aws.ecs.Service;
import com.pulumi.aws.ecs.ServiceArgs;
import java.util.List;
import java.util.ArrayList;
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) {
final var mongoTaskDefinition = EcsFunctions.getTaskDefinition(GetTaskDefinitionArgs.builder()
.taskDefinition(mongoEcs / taskDefinitionTaskDefinition.family())
.build());
var foo = new Cluster("foo");
var mongoEcs_taskDefinitionTaskDefinition = new TaskDefinition("mongoEcs/taskDefinitionTaskDefinition", TaskDefinitionArgs.builder()
.family("mongodb")
.containerDefinitions("""
[
{
"cpu": 128,
"environment": [{
"name": "SECRET",
"value": "KEY"
}],
"essential": true,
"image": "mongo:latest",
"memory": 128,
"memoryReservation": 64,
"name": "mongodb"
}
]
""")
.build());
var mongoService = new Service("mongoService", ServiceArgs.builder()
.cluster(foo.id())
.desiredCount(2)
.taskDefinition(mongoTaskDefinition.applyValue(getTaskDefinitionResult -> getTaskDefinitionResult.arn()))
.build());
}
}
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const mongoTaskDefinition = aws.ecs.getTaskDefinition({
taskDefinition: mongoEcs / taskDefinitionTaskDefinition.family,
});
const foo = new aws.ecs.Cluster("foo", {});
const mongoEcs_taskDefinitionTaskDefinition = new aws.ecs.TaskDefinition("mongoEcs/taskDefinitionTaskDefinition", {
family: "mongodb",
containerDefinitions: `[
{
"cpu": 128,
"environment": [{
"name": "SECRET",
"value": "KEY"
}],
"essential": true,
"image": "mongo:latest",
"memory": 128,
"memoryReservation": 64,
"name": "mongodb"
}
]
`,
});
const mongoService = new aws.ecs.Service("mongoService", {
cluster: foo.id,
desiredCount: 2,
taskDefinition: mongoTaskDefinition.then(mongoTaskDefinition => mongoTaskDefinition.arn),
});
import pulumi
import pulumi_aws as aws
mongo_task_definition = aws.ecs.get_task_definition(task_definition=mongo_ecs / task_definition_task_definition["family"])
foo = aws.ecs.Cluster("foo")
mongo_ecs_task_definition_task_definition = aws.ecs.TaskDefinition("mongoEcs/taskDefinitionTaskDefinition",
family="mongodb",
container_definitions="""[
{
"cpu": 128,
"environment": [{
"name": "SECRET",
"value": "KEY"
}],
"essential": true,
"image": "mongo:latest",
"memory": 128,
"memoryReservation": 64,
"name": "mongodb"
}
]
""")
mongo_service = aws.ecs.Service("mongoService",
cluster=foo.id,
desired_count=2,
task_definition=mongo_task_definition.arn)
Example coming soon!
Using getTaskDefinition
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getTaskDefinition(args: GetTaskDefinitionArgs, opts?: InvokeOptions): Promise<GetTaskDefinitionResult>
function getTaskDefinitionOutput(args: GetTaskDefinitionOutputArgs, opts?: InvokeOptions): Output<GetTaskDefinitionResult>def get_task_definition(task_definition: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetTaskDefinitionResult
def get_task_definition_output(task_definition: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetTaskDefinitionResult]func LookupTaskDefinition(ctx *Context, args *LookupTaskDefinitionArgs, opts ...InvokeOption) (*LookupTaskDefinitionResult, error)
func LookupTaskDefinitionOutput(ctx *Context, args *LookupTaskDefinitionOutputArgs, opts ...InvokeOption) LookupTaskDefinitionResultOutput> Note: This function is named LookupTaskDefinition in the Go SDK.
public static class GetTaskDefinition
{
public static Task<GetTaskDefinitionResult> InvokeAsync(GetTaskDefinitionArgs args, InvokeOptions? opts = null)
public static Output<GetTaskDefinitionResult> Invoke(GetTaskDefinitionInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetTaskDefinitionResult> getTaskDefinition(GetTaskDefinitionArgs args, InvokeOptions options)
public static Output<GetTaskDefinitionResult> getTaskDefinition(GetTaskDefinitionArgs args, InvokeOptions options)
fn::invoke:
function: aws:ecs/getTaskDefinition:getTaskDefinition
arguments:
# arguments dictionaryThe following arguments are supported:
- Task
Definition string - Family for the latest ACTIVE revision, family and revision (family:revision) for a specific revision in the family, the ARN of the task definition to access to.
- Task
Definition string - Family for the latest ACTIVE revision, family and revision (family:revision) for a specific revision in the family, the ARN of the task definition to access to.
- task
Definition String - Family for the latest ACTIVE revision, family and revision (family:revision) for a specific revision in the family, the ARN of the task definition to access to.
- task
Definition string - Family for the latest ACTIVE revision, family and revision (family:revision) for a specific revision in the family, the ARN of the task definition to access to.
- task_
definition str - Family for the latest ACTIVE revision, family and revision (family:revision) for a specific revision in the family, the ARN of the task definition to access to.
- task
Definition String - Family for the latest ACTIVE revision, family and revision (family:revision) for a specific revision in the family, the ARN of the task definition to access to.
getTaskDefinition Result
The following output properties are available:
- Arn string
- ARN of the task definition.
- Arn
Without stringRevision - ARN of the Task Definition with the trailing
revisionremoved. This may be useful for situations where the latest task definition is always desired. If a revision isn't specified, the latest ACTIVE revision is used. See the AWS documentation for details. - Execution
Role stringArn - ARN of the task execution role that the Amazon ECS container agent and the Docker.
- Family string
- Family of this task definition.
- Id string
- The provider-assigned unique ID for this managed resource.
- Network
Mode string - Docker networking mode to use for the containers in this task.
- Revision int
- Revision of this task definition.
- Status string
- Status of this task definition.
- Task
Definition string - Task
Role stringArn - ARN of the IAM role that containers in this task can assume.
- Arn string
- ARN of the task definition.
- Arn
Without stringRevision - ARN of the Task Definition with the trailing
revisionremoved. This may be useful for situations where the latest task definition is always desired. If a revision isn't specified, the latest ACTIVE revision is used. See the AWS documentation for details. - Execution
Role stringArn - ARN of the task execution role that the Amazon ECS container agent and the Docker.
- Family string
- Family of this task definition.
- Id string
- The provider-assigned unique ID for this managed resource.
- Network
Mode string - Docker networking mode to use for the containers in this task.
- Revision int
- Revision of this task definition.
- Status string
- Status of this task definition.
- Task
Definition string - Task
Role stringArn - ARN of the IAM role that containers in this task can assume.
- arn String
- ARN of the task definition.
- arn
Without StringRevision - ARN of the Task Definition with the trailing
revisionremoved. This may be useful for situations where the latest task definition is always desired. If a revision isn't specified, the latest ACTIVE revision is used. See the AWS documentation for details. - execution
Role StringArn - ARN of the task execution role that the Amazon ECS container agent and the Docker.
- family String
- Family of this task definition.
- id String
- The provider-assigned unique ID for this managed resource.
- network
Mode String - Docker networking mode to use for the containers in this task.
- revision Integer
- Revision of this task definition.
- status String
- Status of this task definition.
- task
Definition String - task
Role StringArn - ARN of the IAM role that containers in this task can assume.
- arn string
- ARN of the task definition.
- arn
Without stringRevision - ARN of the Task Definition with the trailing
revisionremoved. This may be useful for situations where the latest task definition is always desired. If a revision isn't specified, the latest ACTIVE revision is used. See the AWS documentation for details. - execution
Role stringArn - ARN of the task execution role that the Amazon ECS container agent and the Docker.
- family string
- Family of this task definition.
- id string
- The provider-assigned unique ID for this managed resource.
- network
Mode string - Docker networking mode to use for the containers in this task.
- revision number
- Revision of this task definition.
- status string
- Status of this task definition.
- task
Definition string - task
Role stringArn - ARN of the IAM role that containers in this task can assume.
- arn str
- ARN of the task definition.
- arn_
without_ strrevision - ARN of the Task Definition with the trailing
revisionremoved. This may be useful for situations where the latest task definition is always desired. If a revision isn't specified, the latest ACTIVE revision is used. See the AWS documentation for details. - execution_
role_ strarn - ARN of the task execution role that the Amazon ECS container agent and the Docker.
- family str
- Family of this task definition.
- id str
- The provider-assigned unique ID for this managed resource.
- network_
mode str - Docker networking mode to use for the containers in this task.
- revision int
- Revision of this task definition.
- status str
- Status of this task definition.
- task_
definition str - task_
role_ strarn - ARN of the IAM role that containers in this task can assume.
- arn String
- ARN of the task definition.
- arn
Without StringRevision - ARN of the Task Definition with the trailing
revisionremoved. This may be useful for situations where the latest task definition is always desired. If a revision isn't specified, the latest ACTIVE revision is used. See the AWS documentation for details. - execution
Role StringArn - ARN of the task execution role that the Amazon ECS container agent and the Docker.
- family String
- Family of this task definition.
- id String
- The provider-assigned unique ID for this managed resource.
- network
Mode String - Docker networking mode to use for the containers in this task.
- revision Number
- Revision of this task definition.
- status String
- Status of this task definition.
- task
Definition String - task
Role StringArn - ARN of the IAM role that containers in this task can assume.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.
Viewing docs for AWS v5.43.0 (Older version)
published on Tuesday, Mar 10, 2026 by Pulumi
published on Tuesday, Mar 10, 2026 by Pulumi
