@collaborne/custom-cloudformation-resources
Advanced tools
Comparing version 0.5.3 to 0.5.4
@@ -7,2 +7,5 @@ "use strict"; | ||
const cfn_response_1 = require("./cfn-response"); | ||
const { | ||
/** ARN of the role to use with CloudWatch Events */ | ||
CW_EVENTS_CONTINUATION_RULE_ROLE_ARN, CW_EVENTS_CONTINUATION_TARGET_ROLE_ARN, } = process.env; | ||
function isContinuationRequired(response) { | ||
@@ -115,4 +118,4 @@ return typeof response === 'object' && 'continuationAfter' in response; | ||
const continuationRuleName = this.getContinuationRuleName(request); | ||
// XXX: Magic! Needs to be documented that this can be set to an ARN of the role to use. | ||
const ruleRoleArn = process.env.CW_EVENTS_CONTINUATION_RULE_ROLE_ARN; | ||
const ruleRoleArn = CW_EVENTS_CONTINUATION_RULE_ROLE_ARN; | ||
const targetRoleArn = CW_EVENTS_CONTINUATION_TARGET_ROLE_ARN; | ||
// Ideally we want to put the target for the continuation first so that we don't miss | ||
@@ -142,3 +145,3 @@ // our own goal, but CWE doesn't work this way. | ||
}), | ||
RoleArn: process.env.CW_EVENTS_CONTINUATION_TARGET_ROLE_ARN, | ||
RoleArn: targetRoleArn, | ||
}, | ||
@@ -150,4 +153,7 @@ ], | ||
const when = new Date(now.getTime() + continuationAfter * 1000); | ||
// Round up to the next full minute, as we won't be getting scheduling if the time isn't in the future. | ||
const cronExpression = `${Math.max(now.getMinutes() + 1, when.getMinutes())} ${when.getHours()} ${when.getDate()} ${when.getMonth() + 1} ? ${when.getFullYear()}`; | ||
// 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()}`; | ||
this.logger.log(`Scheduling continuation using CWE rule ${continuationRuleName} after ${continuationAfter}s (at ${cronExpression})`); | ||
@@ -154,0 +160,0 @@ const schedulePutRuleParams = { |
{ | ||
"name": "@collaborne/custom-cloudformation-resources", | ||
"version": "0.5.3", | ||
"version": "0.5.4", | ||
"description": "Custom CloudFormation resources", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -13,2 +13,8 @@ import { CloudWatchEvents } from 'aws-sdk'; | ||
const { | ||
/** ARN of the role to use with CloudWatch Events */ | ||
CW_EVENTS_CONTINUATION_RULE_ROLE_ARN, | ||
CW_EVENTS_CONTINUATION_TARGET_ROLE_ARN, | ||
} = process.env; | ||
export interface Response<ResourceAttributes extends unknown> { | ||
@@ -233,4 +239,4 @@ physicalResourceId?: string; | ||
// XXX: Magic! Needs to be documented that this can be set to an ARN of the role to use. | ||
const ruleRoleArn = process.env.CW_EVENTS_CONTINUATION_RULE_ROLE_ARN; | ||
const ruleRoleArn = CW_EVENTS_CONTINUATION_RULE_ROLE_ARN; | ||
const targetRoleArn = CW_EVENTS_CONTINUATION_TARGET_ROLE_ARN; | ||
@@ -262,3 +268,3 @@ // Ideally we want to put the target for the continuation first so that we don't miss | ||
}), | ||
RoleArn: process.env.CW_EVENTS_CONTINUATION_TARGET_ROLE_ARN, | ||
RoleArn: targetRoleArn, | ||
}, | ||
@@ -271,9 +277,13 @@ ], | ||
const when = new Date(now.getTime() + continuationAfter * 1000); | ||
// Round up to the next full minute, as we won't be getting scheduling if the time isn't in the future. | ||
// 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.getMinutes() + 1, | ||
when.getMinutes(), | ||
)} ${when.getHours()} ${when.getDate()} ${ | ||
when.getMonth() + 1 | ||
} ? ${when.getFullYear()}`; | ||
now.getUTCMinutes() + 1, | ||
when.getUTCMinutes(), | ||
)} ${when.getUTCHours()} ${when.getUTCDate()} ${ | ||
when.getUTCMonth() + 1 | ||
} ? ${when.getUTCFullYear()}`; | ||
@@ -280,0 +290,0 @@ this.logger.log( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
167666
2044
3