UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 3.51 kB
"use strict";var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__setModuleDefault=exports&&exports.__setModuleDefault||(Object.create?(function(o,v){Object.defineProperty(o,"default",{enumerable:!0,value:v})}):function(o,v){o.default=v}),__importStar=exports&&exports.__importStar||(function(){var ownKeys=function(o){return ownKeys=Object.getOwnPropertyNames||function(o2){var ar=[];for(var k in o2)Object.prototype.hasOwnProperty.call(o2,k)&&(ar[ar.length]=k);return ar},ownKeys(o)};return function(mod){if(mod&&mod.__esModule)return mod;var result={};if(mod!=null)for(var k=ownKeys(mod),i=0;i<k.length;i++)k[i]!=="default"&&__createBinding(result,mod,k[i]);return __setModuleDefault(result,mod),result}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.NotificationsResourceHandler=exports.NotificationsResourceHandlerProps=void 0;var fs=()=>{var tmp=__importStar(require("fs"));return fs=()=>tmp,tmp},path=()=>{var tmp=__importStar(require("path"));return path=()=>tmp,tmp},constructs_1=()=>{var tmp=require("constructs");return constructs_1=()=>tmp,tmp},iam=()=>{var tmp=__importStar(require("../../../aws-iam"));return iam=()=>tmp,tmp},runtime_1=()=>{var tmp=require("../../../aws-lambda/lib/runtime");return runtime_1=()=>tmp,tmp},cdk=()=>{var tmp=__importStar(require("../../../core"));return cdk=()=>tmp,tmp};class NotificationsResourceHandlerProps{role}exports.NotificationsResourceHandlerProps=NotificationsResourceHandlerProps;class NotificationsResourceHandler extends constructs_1().Construct{static singleton(context,props={}){const root=cdk().Stack.of(context),logicalId="BucketNotificationsHandler050a0587b7544547bf325f094a3db834";let lambda=root.node.tryFindChild(logicalId);return lambda||(lambda=new NotificationsResourceHandler(root,logicalId,props)),lambda}functionArn;role;constructor(scope,id,props={}){super(scope,id),this.role=props.role??new(iam()).Role(this,"Role",{assumedBy:new(iam()).ServicePrincipal("lambda.amazonaws.com")}),this.role.addManagedPolicy(iam().ManagedPolicy.fromAwsManagedPolicyName("service-role/AWSLambdaBasicExecutionRole"));const resourceType="AWS::Lambda::Function";class InLineLambda extends cdk().CfnResource{tags=new(cdk()).TagManager(cdk().TagType.STANDARD,resourceType);renderProperties(properties){return properties.Tags=cdk().listMapper(cdk().cfnTagToCloudFormation)(this.tags.renderTags()),delete properties.tags,properties}}const handlerSourceWithoutComments=fs().readFileSync(path().join(__dirname,"..","..","..","custom-resource-handlers","dist","aws-s3","notifications-resource-handler","index.py"),"utf8").replace(/^ *#.*\n?/gm,""),resource=new InLineLambda(this,"Resource",{type:resourceType,properties:{Description:'AWS CloudFormation handler for "Custom::S3BucketNotifications" resources (@aws-cdk/aws-s3)',Code:{ZipFile:handlerSourceWithoutComments},Handler:"index.handler",Role:this.role.roleArn,Runtime:runtime_1().Runtime.determineLatestPythonRuntime(this).name,Timeout:300}});resource.node.addDependency(this.role),this.functionArn=resource.getAtt("Arn").toString()}addToRolePolicy(statement){this.role.addToPrincipalPolicy(statement)}}exports.NotificationsResourceHandler=NotificationsResourceHandler;