ScheduledEc2TaskImageOptions

class aws_cdk.aws_ecs_patterns.ScheduledEc2TaskImageOptions(*, image, command=None, environment=None, log_driver=None, secrets=None, cpu=None, memory_limit_mib=None, memory_reservation_mib=None)

Bases: ScheduledTaskImageProps

The properties for the ScheduledEc2Task using an image.

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

  • command (Optional[Sequence[str]]) – The command that is passed to the container. If you provide a shell command as a single string, you have to quote command-line arguments. Default: - CMD value built into container image.

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

  • 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.

  • cpu (Union[int, float, None]) – The minimum number of CPU units to reserve for the container. Default: none

  • memory_limit_mib (Union[int, float, None]) – The hard limit (in MiB) of memory to present to the container. If your container attempts to exceed the allocated memory, the container is terminated. At least one of memoryLimitMiB and memoryReservationMiB is required for non-Fargate services. Default: - No memory limit.

  • memory_reservation_mib (Union[int, float, None]) – The soft limit (in MiB) of memory to reserve for the container. When system memory is under contention, Docker attempts to keep the container memory within the limit. If the container requires more memory, it can consume up to the value specified by the Memory property or all of the available memory on the container instance—whichever comes first. At least one of memoryLimitMiB and memoryReservationMiB is required for non-Fargate services. Default: - No memory reserved.

ExampleMetadata:

infused

Example:

# Instantiate an Amazon EC2 Task to run at a scheduled interval
# cluster: ecs.Cluster

ecs_scheduled_task = ecs_patterns.ScheduledEc2Task(self, "ScheduledTask",
    cluster=cluster,
    scheduled_ec2_task_image_options=ecsPatterns.ScheduledEc2TaskImageOptions(
        image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample"),
        memory_limit_mi_b=256,
        environment={"name": "TRIGGER", "value": "CloudWatch Events"}
    ),
    schedule=appscaling.Schedule.expression("rate(1 minute)"),
    enabled=True,
    rule_name="sample-scheduled-task-rule"
)

Attributes

command

The command that is passed to the container.

If you provide a shell command as a single string, you have to quote command-line arguments.

Default:
  • CMD value built into container image.

cpu

The minimum number of CPU units to reserve for the container.

Default:

none

environment

The environment variables to pass to the container.

Default:

none

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

memory_limit_mib

The hard limit (in MiB) of memory to present to the container.

If your container attempts to exceed the allocated memory, the container is terminated.

At least one of memoryLimitMiB and memoryReservationMiB is required for non-Fargate services.

Default:
  • No memory limit.

memory_reservation_mib

The soft limit (in MiB) of memory to reserve for the container.

When system memory is under contention, Docker attempts to keep the container memory within the limit. If the container requires more memory, it can consume up to the value specified by the Memory property or all of the available memory on the container instance—whichever comes first.

At least one of memoryLimitMiB and memoryReservationMiB is required for non-Fargate services.

Default:
  • No memory reserved.

secrets

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

Default:
  • No secret environment variables.