registerTaskDefinition

Registers a new task definition from the supplied family and containerDefinitions. Optionally, you can add data volumes to your containers with the volumes parameter. For more information about task definition parameters and defaults, see Amazon ECS Task Definitions in the Amazon Elastic Container Service Developer Guide.

You can specify a role for your task with the taskRoleArn parameter. When you specify a role for a task, its containers can then use the latest versions of the CLI or SDKs to make API requests to the Amazon Web Services services that are specified in the policy that's associated with the role. For more information, see IAM Roles for Tasks in the Amazon Elastic Container Service Developer Guide.

You can specify a Docker networking mode for the containers in your task definition with the networkMode parameter. If you specify the awsvpc network mode, the task is allocated an elastic network interface, and you must specify a NetworkConfiguration when you create a service or run a task with the task definition. For more information, see Task Networking in the Amazon Elastic Container Service Developer Guide.

Samples

import aws.sdk.kotlin.services.ecs.model.ContainerDefinition
import aws.sdk.kotlin.services.ecs.model.Volume

fun main() { 
   //sampleStart 
   // This example registers a task definition to the specified family.
val resp = ecsClient.registerTaskDefinition {
    family = "sleep360"
    taskRoleArn = ""
    containerDefinitions = listOf<ContainerDefinition>(
        ContainerDefinition {
            name = "sleep"
            image = "public.ecr.aws/docker/library/busybox:latest"
            cpu = 10
            command = listOf<String>(
                "sleep",
                "360"
            )
            memory = 10
            essential = true
        }            
    )
    volumes = listOf<Volume>(
    )
} 
   //sampleEnd
}