Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
logRetention: logs.RetentionDays.TWO_WEEKS,
timeout: cdk.Duration.seconds(30),
memorySize: 128,
environment: {
"ALARM_SNS": config['alarm_sns_arn']
},
});
// Add priv to publish the events so the alarms can be forwarded
alarm_forwarder.addToRolePolicy(new iam.PolicyStatement({
resources: [config['alarm_sns_arn']],
actions: ['sns:Publish']
}));
// Connect the SNS to the Lambda
sns_topic.addSubscription(new sns_subscription.LambdaSubscription(alarm_forwarder));
}
}
logRetention: logs.RetentionDays.TWO_WEEKS,
timeout: cdk.Duration.seconds(30),
memorySize: 128,
environment: {
"ALARM_SNS": config['alarm_sns_arn']
},
});
// Add priv to publish the events so the alarms can be forwarded
alarm_forwarder.addToRolePolicy(new iam.PolicyStatement({
resources: [config['alarm_sns_arn']],
actions: ['sns:Publish']
}));
// Connect the SNS to the Lambda
sns_topic.addSubscription(new sns_subscription.LambdaSubscription(alarm_forwarder));
}
}
const approvalRequester = new Function(
scope,
'SlackApprovalRequesterFunction',
{
runtime: Runtime.NODEJS_10_X,
handler: 'lib/approval-requester.handler',
code: Code.asset(
path.join(__dirname, '..', 'lambda', 'bundle.zip'),
),
environment,
},
);
const topic = new Topic(scope, 'SlackApprovalTopic');
topic.grantPublish(options.role);
topic.addSubscription(new LambdaSubscription(approvalRequester));
const approvalHandler = new Function(
scope,
'SlackApprovalHandlerFunction',
{
runtime: Runtime.NODEJS_10_X,
handler: 'lib/approval-handler.handler',
code: Code.fromAsset(
path.join(__dirname, '..', 'lambda', 'bundle.zip'),
),
environment,
},
);
const api = new RestApi(scope, 'SlackApprovalApi');
api.root.addProxy({
public bind(scope: Construct, lifecycleHook: autoscaling.ILifecycleHook): autoscaling.LifecycleHookTargetConfig {
const topic = new sns.Topic(scope, 'Topic');
topic.addSubscription(new subs.LambdaSubscription(this.fn));
return new TopicHook(topic).bind(scope, lifecycleHook);
}
}
public bind(target: lambda.IFunction) {
this.topic.addSubscription(new subs.LambdaSubscription(target));
}
}