Skip to content

Commit 03ff724

Browse files
authored
Merge pull request #226 from gammarers/feature/add-state-machine-timeout
feat: add state machine timeout
2 parents 569af03 + 87a0327 commit 03ff724

File tree

9 files changed

+80
-27
lines changed

9 files changed

+80
-27
lines changed

.projen/deps.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.projenrc.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const project = new awscdk.AwsCdkConstructLibrary({
44
authorAddress: '[email protected]',
55
authorOrganization: true,
66
cdkVersion: '2.120.0',
7-
typescriptVersion: '5.7.x',
8-
jsiiVersion: '5.7.x',
7+
typescriptVersion: '5.8.x',
8+
jsiiVersion: '5.8.x',
99
defaultReleaseBranch: 'main',
1010
name: '@gammarers/aws-ec2-instance-running-schedule-stack',
1111
description: 'AWS EC2 Instance Running Scheduler',

API.md

Lines changed: 39 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Stack } from 'aws-cdk-lib';
1+
import { Duration, Stack } from 'aws-cdk-lib';
22
import * as iam from 'aws-cdk-lib/aws-iam';
33
import * as logs from 'aws-cdk-lib/aws-logs';
44
import * as scheduler from 'aws-cdk-lib/aws-scheduler';
@@ -32,12 +32,17 @@ export interface LogOption {
3232
readonly machineLogLevel?: EC2InstanceRunningScheduleStackMachineLogLevel;
3333
}
3434

35+
export interface Timeout {
36+
readonly stateMachineTimeout?: Duration;
37+
}
38+
3539
export interface EC2InstanceRunningScheduleStackProps {
3640
readonly targetResource: TargetResource;
3741
readonly stopSchedule?: Schedule;
3842
readonly startSchedule?: Schedule;
3943
readonly notifications?: Notifications;
4044
readonly logOption?: LogOption;
45+
readonly timeout?: Timeout;
4146
}
4247

4348
export class EC2InstanceRunningScheduleStack extends Stack {
@@ -62,6 +67,12 @@ export class EC2InstanceRunningScheduleStack extends Stack {
6267
const machine = new RunningControlStateMachine(this, 'StateMachine', {
6368
stateMachineName: undefined,
6469
notificationTopic: topic,
70+
timeout: (() => {
71+
if (props.timeout?.stateMachineTimeout) {
72+
return props.timeout?.stateMachineTimeout;
73+
}
74+
return Duration.hours(1);
75+
})(),
6576
logs: (() => {
6677
if (props.logOption?.machineLogLevel) {
6778
return {

test/__snapshots__/stack.default.test.ts.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/__snapshots__/stack.specific.test.ts.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/stack.specific.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { App } from 'aws-cdk-lib';
1+
import { App, Duration } from 'aws-cdk-lib';
22
import { Template } from 'aws-cdk-lib/assertions';
33
import { EC2InstanceRunningScheduleStack, EC2InstanceRunningScheduleStackMachineLogLevel } from '../src';
44

@@ -29,6 +29,9 @@ describe('Ec2InstanceRunningScheduleStack specific Testing', () => {
2929
3030
],
3131
},
32+
timeout: {
33+
stateMachineTimeout: Duration.minutes(30),
34+
},
3235
logOption: {
3336
machineLogLevel: EC2InstanceRunningScheduleStackMachineLogLevel.ALL,
3437
},

yarn.lock

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)