Skip to content
v2.274.0

TaskDefinitionAttributes Struct ​

A reference to an existing task definition.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ecs as ecs } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';

declare const role: iam.Role;
const taskDefinitionAttributes: ecs.TaskDefinitionAttributes = {
  taskDefinitionArn: 'taskDefinitionArn',

  // the properties below are optional
  compatibility: ecs.Compatibility.EC2,
  executionRole: role,
  networkMode: ecs.NetworkMode.NONE,
  taskRole: role,
};

Properties ​

compatibilityoptionalCompatibilitycompatibilityoptionalCompatibilitycompatibilityoptionalCompatibilityCompatibilityoptionalCompatibilityCompatibilityoptionalCompatibility= Compatibility.EC2_AND_FARGATE#
What launch types this task definition should be compatible with.
executionRoleoptionalIRoleexecution_roleoptionalIRoleexecutionRoleoptionalIRoleExecutionRoleoptionalIRoleExecutionRoleoptionalIRole= undefined#
The IAM role that grants containers and Fargate agents permission to make AWS API calls on your behalf.

Some tasks do not have an execution role.

networkModeoptionalNetworkModenetwork_modeoptionalNetworkModenetworkModeoptionalNetworkModeNetworkModeoptionalNetworkModeNetworkModeoptionalNetworkMode#
The networking mode to use for the containers in the task.

Default: Network mode cannot be provided to the imported task.

taskDefinitionArnstringtask_definition_arnstrtaskDefinitionArnStringTaskDefinitionArnstringTaskDefinitionArn*stringrequired#
The arn of the task definition.
taskRoleoptionalIRoletask_roleoptionalIRoletaskRoleoptionalIRoleTaskRoleoptionalIRoleTaskRoleoptionalIRole#
The name of the IAM role that grants containers in the task permission to call AWS APIs on your behalf.

Default: Permissions cannot be granted to the imported task.