unescape quotes when necessary to compatible with old filter patterns

This commit is contained in:
Will Yang 2018-01-03 14:15:54 +11:00
parent b444155a27
commit ced088c4fa

View File

@ -78,6 +78,13 @@ class AwsCompileCloudWatchLogEvents {
.getLambdaCloudWatchLogPermissionLogicalId(functionName,
cloudWatchLogNumberInFunction);
// unescape quotes once when the first quote is detected escaped
const idxFirstSlash = FilterPattern.indexOf('\\');
const idxFirstQuote = FilterPattern.indexOf('"');
if (idxFirstSlash >= 0 && idxFirstQuote >= 0 && idxFirstQuote > idxFirstSlash) {
FilterPattern = FilterPattern.replace(/\\("|\\|')/g, (match, g) => g);
}
const cloudWatchLogRuleTemplate = `
{
"Type": "AWS::Logs::SubscriptionFilter",