NetworkLoadBalancedTaskImageOptions

class aws_cdk.aws_ecs_patterns.NetworkLoadBalancedTaskImageOptions(*, image, container_name=None, container_port=None, docker_labels=None, enable_logging=None, environment=None, execution_role=None, family=None, log_driver=None, secrets=None, task_role=None)

Bases: object

Parameters:
  • image (ContainerImage) – The image used to start a container. Image or taskDefinition must be specified, but not both. Default: - none

  • container_name (Optional[str]) – The container name value to be specified in the task definition. Default: - none

  • container_port (Union[int, float, None]) – The port number on the container that is bound to the user-specified or automatically assigned host port. If you are using containers in a task with the awsvpc or host network mode, exposed ports should be specified using containerPort. If you are using containers in a task with the bridge network mode and you specify a container port and not a host port, your container automatically receives a host port in the ephemeral port range. Port mappings that are automatically assigned in this way do not count toward the 100 reserved ports limit of a container instance. For more information, see hostPort. Default: 80

  • docker_labels (Optional[Mapping[str, str]]) – A key/value map of labels to add to the container. Default: - No labels.

  • enable_logging (Optional[bool]) – Flag to indicate whether to enable logging. Default: true

  • environment (Optional[Mapping[str, str]]) – The environment variables to pass to the container. Default: - No environment variables.

  • execution_role (Optional[IRole]) – The name of the task execution IAM role that grants the Amazon ECS container agent permission to call AWS APIs on your behalf. Default: - No value

  • family (Optional[str]) – The name of a family that this task definition is registered to. A family groups multiple versions of a task definition. Default: - Automatically generated name.

  • log_driver (Optional[LogDriver]) – The log driver to use. Default: - AwsLogDriver if enableLogging is true

  • secrets (Optional[Mapping[str, Secret]]) – The secret to expose to the container as an environment variable. Default: - No secret environment variables.

  • task_role (Optional[IRole]) – The name of the task IAM role that grants containers in the task permission to call AWS APIs on your behalf. Default: - A task role is automatically created for you.

ExampleMetadata:

infused

Example:

# cluster: ecs.Cluster

load_balanced_ecs_service = ecs_patterns.NetworkLoadBalancedEc2Service(self, "Service",
    cluster=cluster,
    memory_limit_mi_b=1024,
    task_image_options=ecsPatterns.NetworkLoadBalancedTaskImageOptions(
        image=ecs.ContainerImage.from_registry("test"),
        environment={
            "TEST_ENVIRONMENT_VARIABLE1": "test environment variable 1 value",
            "TEST_ENVIRONMENT_VARIABLE2": "test environment variable 2 value"
        }
    ),
    desired_count=2
)

Attributes

container_name

The container name value to be specified in the task definition.

Default:
  • none

container_port

The port number on the container that is bound to the user-specified or automatically assigned host port.

If you are using containers in a task with the awsvpc or host network mode, exposed ports should be specified using containerPort. If you are using containers in a task with the bridge network mode and you specify a container port and not a host port, your container automatically receives a host port in the ephemeral port range.

Port mappings that are automatically assigned in this way do not count toward the 100 reserved ports limit of a container instance.

For more information, see hostPort.

Default:

80

docker_labels

A key/value map of labels to add to the container.

Default:
  • No labels.

enable_logging

Flag to indicate whether to enable logging.

Default:

true

environment

The environment variables to pass to the container.

Default:
  • No environment variables.

execution_role

The name of the task execution IAM role that grants the Amazon ECS container agent permission to call AWS APIs on your behalf.

Default:
  • No value

family

The name of a family that this task definition is registered to.

A family groups multiple versions of a task definition.

Default:
  • Automatically generated name.

image

The image used to start a container.

Image or taskDefinition must be specified, but not both.

Default:
  • none

log_driver

The log driver to use.

Default:
  • AwsLogDriver if enableLogging is true

secrets

The secret to expose to the container as an environment variable.

Default:
  • No secret environment variables.

task_role

The name of the task IAM role that grants containers in the task permission to call AWS APIs on your behalf.

Default:
  • A task role is automatically created for you.