# CommonTaskDefinitionAttributes

The common task definition attributes used across all types of task definitions.

- Source: [`aws-ecs/lib/base/task-definition.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-ecs/lib/base/task-definition.ts#L265)
- Type last changed: v2.76.0 · 20 Apr 2023

## Example

TypeScript:

```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 commonTaskDefinitionAttributes: ecs.CommonTaskDefinitionAttributes = {
  taskDefinitionArn: 'taskDefinitionArn',

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

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ecs as ecs
from aws_cdk import aws_iam as iam

# role: iam.Role

common_task_definition_attributes = ecs.CommonTaskDefinitionAttributes(
    task_definition_arn="taskDefinitionArn",

    # the properties below are optional
    execution_role=role,
    network_mode=ecs.NetworkMode.NONE,
    task_role=role
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ecs.*;
import software.amazon.awscdk.services.iam.*;

Role role;

CommonTaskDefinitionAttributes commonTaskDefinitionAttributes = CommonTaskDefinitionAttributes.builder()
        .taskDefinitionArn("taskDefinitionArn")

        // the properties below are optional
        .executionRole(role)
        .networkMode(NetworkMode.NONE)
        .taskRole(role)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.ECS;
using Amazon.CDK.AWS.IAM;

Role role;

var commonTaskDefinitionAttributes = new CommonTaskDefinitionAttributes {
    TaskDefinitionArn = "taskDefinitionArn",

    // the properties below are optional
    ExecutionRole = role,
    NetworkMode = NetworkMode.NONE,
    TaskRole = role
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var role Role

commonTaskDefinitionAttributes := &CommonTaskDefinitionAttributes{
	TaskDefinitionArn: jsii.String("taskDefinitionArn"),

	// the properties below are optional
	ExecutionRole: role,
	NetworkMode: awscdk.Aws_ecs.NetworkMode_NONE,
	TaskRole: role,
}
```

## Properties

- `executionRole`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) = 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.

- `networkMode`: [NetworkMode](/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.NetworkMode.html) — The networking mode to use for the containers in the task.

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

- `taskDefinitionArn`: string (required) — The arn of the task definition.

- `taskRole`: [IRole](/cdk/api/v2/docs/aws-cdk-lib.aws_iam.IRole.html) — 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.
