@collaborne/custom-cloudformation-resources
Advanced tools
Comparing version 0.5.4 to 0.5.5
@@ -149,8 +149,12 @@ "use strict"; | ||
const now = new Date(); | ||
const when = new Date(now.getTime() + continuationAfter * 1000); | ||
const whenTs = Math.ceil((now.getTime() / 1000 + continuationAfter) / 60) * 60 * 1000; | ||
// Bump up to the next full minute, as we won't be getting scheduling if the time isn't "far enough" | ||
// in the future. | ||
const when = new Date(whenTs); | ||
if (when.getMinutes() === now.getMinutes()) { | ||
when.setMinutes(when.getMinutes() + 1); | ||
} | ||
// Build a cron expression for CWE | ||
// - We must use GMT | ||
// - We must round up to the next full minute, as we won't be getting scheduling if the time isn't in the future. | ||
// See also https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html | ||
const cronExpression = `${Math.max(now.getUTCMinutes() + 1, when.getUTCMinutes())} ${when.getUTCHours()} ${when.getUTCDate()} ${when.getUTCMonth() + 1} ? ${when.getUTCFullYear()}`; | ||
const cronExpression = `${when.getUTCMinutes()} ${when.getUTCHours()} ${when.getUTCDate()} ${when.getUTCMonth() + 1} ? ${when.getUTCFullYear()}`; | ||
this.logger.log(`Scheduling continuation using CWE rule ${continuationRuleName} after ${continuationAfter}s (at ${cronExpression})`); | ||
@@ -157,0 +161,0 @@ const schedulePutRuleParams = { |
{ | ||
"name": "@collaborne/custom-cloudformation-resources", | ||
"version": "0.5.4", | ||
"version": "0.5.5", | ||
"description": "Custom CloudFormation resources", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -273,12 +273,14 @@ import { CloudWatchEvents } from 'aws-sdk'; | ||
const now = new Date(); | ||
const when = new Date(now.getTime() + continuationAfter * 1000); | ||
const whenTs = | ||
Math.ceil((now.getTime() / 1000 + continuationAfter) / 60) * 60 * 1000; | ||
// Bump up to the next full minute, as we won't be getting scheduling if the time isn't "far enough" | ||
// in the future. | ||
const when = new Date(whenTs); | ||
if (when.getMinutes() === now.getMinutes()) { | ||
when.setMinutes(when.getMinutes() + 1); | ||
} | ||
// Build a cron expression for CWE | ||
// - We must use GMT | ||
// - We must round up to the next full minute, as we won't be getting scheduling if the time isn't in the future. | ||
// See also https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html | ||
const cronExpression = `${Math.max( | ||
now.getUTCMinutes() + 1, | ||
when.getUTCMinutes(), | ||
)} ${when.getUTCHours()} ${when.getUTCDate()} ${ | ||
const cronExpression = `${when.getUTCMinutes()} ${when.getUTCHours()} ${when.getUTCDate()} ${ | ||
when.getUTCMonth() + 1 | ||
@@ -285,0 +287,0 @@ } ? ${when.getUTCFullYear()}`; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
168067
2050