Ec2TaskDefinitionAttributes Struct
Attributes used to import an existing EC2 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 ec2TaskDefinitionAttributes: ecs.Ec2TaskDefinitionAttributes = {
taskDefinitionArn: 'taskDefinitionArn',
// the properties below are optional
executionRole: role,
networkMode: ecs.NetworkMode.NONE,
taskRole: role,
};
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
ec2_task_definition_attributes = ecs.Ec2TaskDefinitionAttributes(
task_definition_arn="taskDefinitionArn",
# the properties below are optional
execution_role=role,
network_mode=ecs.NetworkMode.NONE,
task_role=role
)
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;
Ec2TaskDefinitionAttributes ec2TaskDefinitionAttributes = Ec2TaskDefinitionAttributes.builder()
.taskDefinitionArn("taskDefinitionArn")
// the properties below are optional
.executionRole(role)
.networkMode(NetworkMode.NONE)
.taskRole(role)
.build();
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 ec2TaskDefinitionAttributes = new Ec2TaskDefinitionAttributes {
TaskDefinitionArn = "taskDefinitionArn",
// the properties below are optional
ExecutionRole = role,
NetworkMode = NetworkMode.NONE,
TaskRole = role
};
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
ec2TaskDefinitionAttributes := &Ec2TaskDefinitionAttributes{
TaskDefinitionArn: jsii.String("taskDefinitionArn"),
// the properties below are optional
ExecutionRole: role,
NetworkMode: awscdk.Aws_ecs.NetworkMode_NONE,
TaskRole: role,
}
Properties
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.