Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(aws-ecs-patterns): allow ScheduledTaskBase be created in a DISABLED state #12837

Merged
merged 5 commits into from
Feb 15, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-ecs-patterns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ const ecsScheduledTask = new ScheduledEc2Task(stack, 'ScheduledTask', {
environment: { name: 'TRIGGER', value: 'CloudWatch Events' },
},
schedule: events.Schedule.expression('rate(1 minute)'),
enabled: true,
ruleName: 'sample-scheduled-task-rule'
});
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ export interface ScheduledTaskBaseProps {
*/
readonly schedule: Schedule;

/**
* Indicates whether the rule is enabled.
*
* @default true
*/
readonly enabled?: boolean;

/**
* A name for the rule.
*
Expand Down Expand Up @@ -148,6 +155,7 @@ export abstract class ScheduledTaskBase extends CoreConstruct {
this.eventRule = new Rule(this, 'ScheduledEventRule', {
schedule: props.schedule,
ruleName: props.ruleName,
enabled: props.enabled,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export = {

// THEN
expect(stack).to(haveResource('AWS::Events::Rule', {
State: 'ENABLED',
Targets: [
{
Arn: { 'Fn::GetAtt': ['EcsCluster97242B84', 'Arn'] },
Expand Down Expand Up @@ -78,6 +79,7 @@ export = {

new ScheduledEc2Task(stack, 'ScheduledEc2Task', {
cluster,
enabled: false,
scheduledEc2TaskImageOptions: {
image: ecs.ContainerImage.fromRegistry('henk'),
memoryLimitMiB: 512,
Expand All @@ -92,6 +94,7 @@ export = {
// THEN
expect(stack).to(haveResource('AWS::Events::Rule', {
Name: 'sample-scheduled-task-rule',
State: 'DISABLED',
Targets: [
{
Arn: { 'Fn::GetAtt': ['EcsCluster97242B84', 'Arn'] },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export = {

// THEN
expect(stack).to(haveResource('AWS::Events::Rule', {
State: 'ENABLED',
Targets: [
{
Arn: { 'Fn::GetAtt': ['EcsCluster97242B84', 'Arn'] },
Expand Down Expand Up @@ -90,6 +91,7 @@ export = {

new ScheduledFargateTask(stack, 'ScheduledFargateTask', {
cluster,
enabled: false,
scheduledFargateTaskImageOptions: {
image: ecs.ContainerImage.fromRegistry('henk'),
memoryLimitMiB: 512,
Expand All @@ -104,6 +106,7 @@ export = {
// THEN
expect(stack).to(haveResource('AWS::Events::Rule', {
Name: 'sample-scheduled-task-rule',
State: 'DISABLED',
Targets: [
{
Arn: { 'Fn::GetAtt': ['EcsCluster97242B84', 'Arn'] },
Expand Down