ScheduledEc2TaskImageOptions Struct
The properties for the ScheduledEc2Task using an image.
| Source | aws-ecs-patterns/lib/ecs/scheduled-ecs-task.ts |
|---|
Example
// Instantiate an Amazon EC2 Task to run at a scheduled interval
declare const cluster: ecs.Cluster;
const ecsScheduledTask = new ecsPatterns.ScheduledEc2Task(this, 'ScheduledTask', {
cluster,
scheduledEc2TaskImageOptions: {
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
memoryLimitMiB: 256,
environment: { name: 'TRIGGER', value: 'CloudWatch Events' },
},
schedule: appscaling.Schedule.expression('rate(1 minute)'),
enabled: true,
ruleName: 'sample-scheduled-task-rule',
});
# 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"
)
// Instantiate an Amazon EC2 Task to run at a scheduled interval
Cluster cluster;
ScheduledEc2Task ecsScheduledTask = ScheduledEc2Task.Builder.create(this, "ScheduledTask")
.cluster(cluster)
.scheduledEc2TaskImageOptions(ScheduledEc2TaskImageOptions.builder()
.image(ContainerImage.fromRegistry("amazon/amazon-ecs-sample"))
.memoryLimitMiB(256)
.environment(Map.of("name", "TRIGGER", "value", "CloudWatch Events"))
.build())
.schedule(Schedule.expression("rate(1 minute)"))
.enabled(true)
.ruleName("sample-scheduled-task-rule")
.build();
// Install: dotnet add package Amazon.CDK.Lib
// Instantiate an Amazon EC2 Task to run at a scheduled interval
Cluster cluster;
var ecsScheduledTask = new ScheduledEc2Task(this, "ScheduledTask", new ScheduledEc2TaskProps {
Cluster = cluster,
ScheduledEc2TaskImageOptions = new ScheduledEc2TaskImageOptions {
Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
MemoryLimitMiB = 256,
Environment = new Dictionary<string, string> { { "name", "TRIGGER" }, { "value", "CloudWatch Events" } }
},
Schedule = Schedule.Expression("rate(1 minute)"),
Enabled = true,
RuleName = "sample-scheduled-task-rule"
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Instantiate an Amazon EC2 Task to run at a scheduled interval
var cluster Cluster
ecsScheduledTask := ecsPatterns.NewScheduledEc2Task(this, jsii.String("ScheduledTask"), &ScheduledEc2TaskProps{
Cluster: Cluster,
ScheduledEc2TaskImageOptions: &ScheduledEc2TaskImageOptions{
Image: ecs.ContainerImage_FromRegistry(jsii.String("amazon/amazon-ecs-sample")),
MemoryLimitMiB: jsii.Number(256),
Environment: map[string]*string{
"name": jsii.String("TRIGGER"),
"value": jsii.String("CloudWatch Events"),
},
},
Schedule: appscaling.Schedule_Expression(jsii.String("rate(1 minute)")),
Enabled: jsii.Boolean(true),
RuleName: jsii.String("sample-scheduled-task-rule"),
})
Properties
commandoptionalstring[]commandoptionaltyping.List[str]commandoptionalList<String>Commandoptionalstring[]Commandoptional*[]*string #Default: CMD value built into container image.
If you provide a shell command as a single string, you have to quote command-line arguments.
containerNameoptionalstringcontainer_nameoptionalstrcontainerNameoptionalStringContainerNameoptionalstringContainerNameoptional*string = ScheduledContainer #cpuoptionalnumbercpuoptionalint | floatcpuoptionalNumberCpuoptionaldoubleCpuoptional*float64 = none #environmentoptional{ [key: string]: string }environmentoptionaltyping.Mapping[str, str]environmentoptionalMap<String, String>EnvironmentoptionalIDictionary<string, string>Environmentoptional*map[string]*string = none #imageContainerImageimageContainerImageimageContainerImageImageContainerImageImageContainerImage = none required #Image or taskDefinition must be specified, but not both.
logDriveroptionalLogDriverlog_driveroptionalLogDriverlogDriveroptionalLogDriverLogDriveroptionalLogDriverLogDriveroptionalLogDriver #Default: AwsLogDriver if enableLogging is true
memoryLimitMiBoptionalnumbermemory_limit_mi_boptionalint | floatmemoryLimitMiBoptionalNumberMemoryLimitMiBoptionaldoubleMemoryLimitMiBoptional*float64 #Default: No memory limit.
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.
memoryReservationMiBoptionalnumbermemory_reservation_mi_boptionalint | floatmemoryReservationMiBoptionalNumberMemoryReservationMiBoptionaldoubleMemoryReservationMiBoptional*float64 #Default: No memory reserved.
notes
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.