ApplicationLoadBalancedTaskImageProps

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

Bases: object

Options for configuring a new container.

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

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

  • container_ports (Optional[Sequence[Union[int, float]]]) – A list of port numbers 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 secrets 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:

from aws_cdk.aws_certificatemanager import Certificate
from aws_cdk.aws_ec2 import InstanceType
from aws_cdk.aws_ecs import Cluster, ContainerImage
from aws_cdk.aws_elasticloadbalancingv2 import ApplicationProtocol, SslPolicy
from aws_cdk.aws_route53 import PublicHostedZone

vpc = ec2.Vpc(self, "Vpc", max_azs=1)
load_balanced_fargate_service = ecs_patterns.ApplicationMultipleTargetGroupsFargateService(self, "myService",
    cluster=ecs.Cluster(self, "EcsCluster", vpc=vpc),
    memory_limit_mi_b=256,
    task_image_options=ecsPatterns.ApplicationLoadBalancedTaskImageProps(
        image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample")
    ),
    enable_execute_command=True,
    load_balancers=[ecsPatterns.ApplicationLoadBalancerProps(
        name="lb",
        idle_timeout=Duration.seconds(400),
        domain_name="api.example.com",
        domain_zone=PublicHostedZone(self, "HostedZone", zone_name="example.com"),
        listeners=[ecsPatterns.ApplicationListenerProps(
            name="listener",
            protocol=ApplicationProtocol.HTTPS,
            certificate=Certificate.from_certificate_arn(self, "Cert", "helloworld"),
            ssl_policy=SslPolicy.TLS12_EXT
        )
        ]
    ), ecsPatterns.ApplicationLoadBalancerProps(
        name="lb2",
        idle_timeout=Duration.seconds(120),
        domain_name="frontend.com",
        domain_zone=PublicHostedZone(self, "HostedZone", zone_name="frontend.com"),
        listeners=[ecsPatterns.ApplicationListenerProps(
            name="listener2",
            protocol=ApplicationProtocol.HTTPS,
            certificate=Certificate.from_certificate_arn(self, "Cert2", "helloworld"),
            ssl_policy=SslPolicy.TLS12_EXT
        )
        ]
    )
    ],
    target_groups=[ecsPatterns.ApplicationTargetProps(
        container_port=80,
        listener="listener"
    ), ecsPatterns.ApplicationTargetProps(
        container_port=90,
        path_pattern="a/b/c",
        priority=10,
        listener="listener"
    ), ecsPatterns.ApplicationTargetProps(
        container_port=443,
        listener="listener2"
    ), ecsPatterns.ApplicationTargetProps(
        container_port=80,
        path_pattern="a/b/c",
        priority=10,
        listener="listener2"
    )
    ]
)

Attributes

container_name

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

Default:
  • web

container_ports

A list of port numbers 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, not both.

Default:
  • none

log_driver

The log driver to use.

Default:
  • AwsLogDriver if enableLogging is true

secrets

The secrets 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.