in lib/emailHandler-stack.ts [33:65]
constructor(scope: cdk.Construct, id: string, props: EmailHandlerStackProps) {
super(scope, id, props);
// Provision Lambda
const emailHandler = new lambda.Function(this, 'emailHandler', {
code: lambda.Code.asset('./lambda-helpers/email-handler'),
functionName: `${props.prefix}-cicd-emailHandler`,
handler: 'lambda.send_codebuild_events_to_sns',
runtime: lambda.Runtime.PYTHON_3_8,
logRetention: logs.RetentionDays.TWO_WEEKS,
environment: {
"SSM_ROOT": props.ssmRoot,
"PREFIX": props.prefix
}
});
emailHandler.addPermission('cloudWatchPermission', {
principal: new ServicePrincipal('events.amazonaws.com')
})
emailHandler.addToRolePolicy(new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: [ 'ssm:GetParameter', 'sns:Publish' ],
resources: [ '*' ]
}));
new ssm.StringParameter(this, 'EmailHandlerArn', {
description: 'Email Handler Lambda Function Arn',
parameterName: `${props.ssmRoot}/lambda/cicd-email-handler`,
stringValue: emailHandler.functionArn
});
}