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

fix(autoscaling): add timezone property to Scheduled Action #17330

Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions packages/@aws-cdk/aws-autoscaling/lib/scheduled-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ import { Schedule } from './schedule';
* Properties for a scheduled scaling action
*/
export interface BasicScheduledActionProps {
/**
* Specifies the time zone for a cron expression. If a time zone is not provided, UTC is used by default.
*
* Valid values are the canonical names of the IANA time zones, derived from the IANA Time Zone Database (such as Etc/GMT+9 or Pacific/Tahiti).
*
* For more information, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones.
*
* @default - UTC
*
*/
readonly timeZone?: string;
/**
* When to perform this action.
*
Expand Down Expand Up @@ -94,6 +105,7 @@ export class ScheduledAction extends Resource {
maxSize: props.maxCapacity,
desiredCapacity: props.desiredCapacity,
recurrence: props.schedule.expressionString,
timeZone: props.timeZone,
});
}
}
Expand Down
21 changes: 21 additions & 0 deletions packages/@aws-cdk/aws-autoscaling/test/scheduled-action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,27 @@ describe('scheduled action', () => {

});

test('have timezone property', () => {
// GIVEN
const stack = new cdk.Stack();
const asg = makeAutoScalingGroup(stack);

// WHEN
asg.scaleOnSchedule('ScaleOutAtMiddaySeoul', {
schedule: autoscaling.Schedule.cron({ hour: '12', minute: '0' }),
minCapacity: 12,
timeZone: 'Asia/Seoul',
});

// THEN
expect(stack).to(haveResource('AWS::AutoScaling::ScheduledAction', {
MinSize: 12,
Recurrence: '0 12 * * *',
TimeZone: 'Asia/Seoul',
}));

});

test('autoscaling group has recommended updatepolicy for scheduled actions', () => {
// GIVEN
const stack = new cdk.Stack();
Expand Down