Interface GuScheduledEcsTaskProps

Configuration options for the [[GuEcsTask]] pattern.

See [[ContainerConfiguration]] for details of how to configure the container used to run the task.

taskTimeoutInMinutes does what is says on the tin. The default timeout is 15 minutes.

The taskCommand prop allows you to specify a command to run when the task starts (this can also be done via a CMD statement in your Dockerfile). For example:

const props = { //other props taskCommand: `aws s3 cp s3://${distbucket}/${stack}/${stage}/${app}/ . && ./ }

It is advisable to configure alarms for when the job fails/times out. To do this specify the alarmSnsTopicArn prop.

customTaskPolicies allows your task to interact with other AWS services. By default a task will have read access to the distribution bucket for your account.

You can specify security groups to apply to task using the securityGroups prop.

You can also set the memory and cpu units for your task. See for further details.

If you want to pass input from the step function into your EcsTask you can do so via the environmentOverrides prop, which allows you to wire up step function input JSON to environment variables set on the container. For example, const props = { ...otherProps environmentOverrides: [ { name: "VERSION", value: JsonPath.stringAt("$.version"), }, } With the above override, your task will attempt to find a version property in the JSON input passed to the step function, and apply it to the VERSION environment variable. Alternatively, you could hard code a value for the variable in CDK. See for further detail and other override options - this construct currently only supports environment variables.

interface GuScheduledEcsTaskProps {
    app: string;
    containerConfiguration: ContainerConfiguration;
    containerInsights?: boolean;
    cpu?: number;
    customTaskPolicies?: PolicyStatement[];
    enableDistributablePolicy?: boolean;
    environmentOverrides?: TaskEnvironmentVariable[];
    memory?: number;
    monitoringConfiguration: NoMonitoring | GuEcsTaskMonitoringProps;
    readonlyRootFilesystem?: boolean;
    schedule: Schedule;
    securityGroups?: ISecurityGroup[];
    storage?: number;
    taskCommand?: string;
    taskTimeoutInMinutes?: number;
    vpc: IVpc;

Hierarchy (view full)


app: string
containerConfiguration: ContainerConfiguration
containerInsights?: boolean

If true, CloudWatch Container Insights will be enabled for the cluster


cpu?: number
customTaskPolicies?: PolicyStatement[]
enableDistributablePolicy?: boolean

Whether to give the task IAM role access to the account's dist bucket. This is enabled by default to avoid breaking changes, but consumers of this pattern that pull a container image that doesn't need extra dependencies from S3 shoud set this value to false.

environmentOverrides?: TaskEnvironmentVariable[]
memory?: number
monitoringConfiguration: NoMonitoring | GuEcsTaskMonitoringProps
readonlyRootFilesystem?: boolean

When this parameter is true, the container is given read-only access to its root file system.


schedule: Schedule

Schedule for the task.


  • Schedule.expression("cron(0 8 ? * MON-FRI *)")
  • Schedule.rate(Duration.minutes(5))
securityGroups?: ISecurityGroup[]
storage?: number
taskCommand?: string
taskTimeoutInMinutes?: number
vpc: IVpc