@kumologica/builder
Version:
Kumologica build and deploy module
95 lines (83 loc) • 1.87 kB
JavaScript
function trigger(functionName, params){
let templateResources = {};
/*templateResources.LambdaUtils = {
CustomResourceLambdaFunction: {
Type: "AWS::Lambda::Function",
Properties: {
Handler: "index.lambda_handler",
Role: {
Ref: LambdaUtilsRole
},
Code: {
ZipFile: code
}
}
}
};
templateResources.LambdaUtilsRole = {
Type: 'AWS::IAM::Role',
Properties: {
AssumeRolePolicyDocument: {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Principal: {
Service: ["lambda.amazonaws.com"]
},
Action:['sts:AssumeRole']
}
],
Path: "/",
Policies: [
{
PolicyName: "root",
PolicyDocument: {
Version: "2012-10-17",
Statement: [
{
Effect: "Allow",
Actions: ['s3:GetBucketNotification','s3:PutBucketNotification'],
Resource: 'arn:aws:s3:::' + params.s3.bucket
},
{
Effect: "Allow",
Actions: ['logs:CreateLogGroup', 'logs:CreateLogStream','logs:PutLogEvents'],
Resource: "arn:aws:logs:*:*:*"
}
]
}
}
]
}
}
};*/
templateResources.LambdaS3InvokePermission = {
Type: 'AWS::Lambda::Permission',
DependsOn: 'Lambda',
Properties: {
FunctionName: functionName,
Action: 'lambda:InvokeFunction',
Principal: 's3.amazonaws.com',
SourceAccount: params.s3.sourceAccount || {'Ref': 'AWS::AccountId'},
SourceArn: 'arn:aws:s3:::' + params.s3.bucket
}
}
/* templateResources.S3Bucket = {
Type: 'AWS::S3::Bucket',
DeletionPolicy: 'Retain',
Properties: {
BucketName: params.s3.bucket,
NotificationConfiguration: {
LambdaConfigurations: [{
Event: params.s3.eventType,
Function: functionName
}]
}
}
}*/
return templateResources;
}
module.exports = {
trigger
}