@cfn-modules/lambda-function
Advanced tools
| --- | ||
| AWSTemplateFormatVersion: '2010-09-09' | ||
| Description: 'cfn-modules test' | ||
| Resources: | ||
| Function: | ||
| Type: 'AWS::CloudFormation::Stack' | ||
| Properties: | ||
| Parameters: | ||
| Handler: 'defaults.handler' | ||
| Runtime: 'nodejs8.10' | ||
| FunctionName: 'NamedLambda' | ||
| TemplateURL: './node_modules/@cfn-modules/lambda-function/module.yml' |
+8
-5
@@ -19,4 +19,2 @@ --- | ||
| # TODO integrate with event sources | ||
| # * Amazon DynamoDB (via standalone module using AWS::Lambda::EventSourceMapping, waits for DynamoDB stream support in dynamodb-table module) | ||
| # * Amazon Kinesis Data Streams (via standalone module using AWS::Lambda::EventSourceMapping, waits for Kinesis stream module) | ||
| # * Amazon Simple Notification Service (via standalone module using AWS::SNS::Subscription) | ||
@@ -53,2 +51,6 @@ # * Amazon Simple Email Service (via TODO) | ||
| Default: '' | ||
| FunctionName: | ||
| Description: 'An optional but recommended name for the function and log group.' | ||
| Type: String | ||
| Default: '' | ||
| Description: | ||
@@ -139,2 +141,3 @@ Description: 'Optional description of the function' | ||
| HasVpcModule: !Not [!Equals [!Ref VpcModule, '']] | ||
| HasFunctionName: !Not [!Equals [!Ref FunctionName, '']] | ||
| HasDependencyModule1: !Not [!Equals [!Ref DependencyModule1, '']] | ||
@@ -206,3 +209,3 @@ HasDependencyModule2: !Not [!Equals [!Ref DependencyModule2, '']] | ||
| Properties: | ||
| LogGroupName: !Join ['', ['/aws/lambda/cfn-modules-lambda-', !Select [2, !Split ['/', !Ref 'AWS::StackId']]]] | ||
| LogGroupName: !If [HasFunctionName, !Sub '/aws/lambda/${FunctionName}', !Join ['', ['/aws/lambda/cfn-modules-lambda-', !Select [2, !Split ['/', !Ref 'AWS::StackId']]]]] | ||
| RetentionInDays: !Ref LogGroupRetentionInDays | ||
@@ -224,3 +227,3 @@ Function: | ||
| DEPENDENCY3_ARN: !If [HasDependencyModule3, {'Fn::ImportValue': !Sub '${DependencyModule3}-Arn'}, ''] | ||
| FunctionName: !Join ['', ['cfn-modules-lambda-', !Select [2, !Split ['/', !Ref 'AWS::StackId']]]] # we need to "fix" the name to be able to create the LogGroup in advance | ||
| FunctionName: !If [HasFunctionName, !Ref FunctionName, !Join ['', ['cfn-modules-lambda-', !Select [2, !Split ['/', !Ref 'AWS::StackId']]]]] | ||
| Handler: !Ref Handler | ||
@@ -289,3 +292,3 @@ KmsKeyArn: !If [HasKmsKeyModule, {'Fn::ImportValue': !Sub '${KmsKeyModule}-Arn'}, !Ref 'AWS::NoValue'] | ||
| ModuleVersion: | ||
| Value: '2.3.0' | ||
| Value: '2.4.0' | ||
| StackName: | ||
@@ -292,0 +295,0 @@ Value: !Ref 'AWS::StackName' |
+1
-1
| { | ||
| "name": "@cfn-modules/lambda-function", | ||
| "version": "2.3.0", | ||
| "version": "2.4.0", | ||
| "description": "AWS Lambda function with automated IAM policy generation, encryption, log group and alerting", | ||
@@ -5,0 +5,0 @@ "author": "Michael Wittig <michael@widdix.de>", |
+18
-0
@@ -35,2 +35,3 @@ [](https://travis-ci.org/cfn-modules/lambda-function) | ||
| DeadLetterQueueModule: !GetAtt 'Queue.Outputs.StackName' # optional | ||
| FunctionName: '' #optional | ||
| Description: '' # optional | ||
@@ -58,2 +59,12 @@ Handler: 'example.handler' # required (file must be in the `lambda-src` folder) | ||
| ## Examples | ||
| * [serverless-cron](https://github.com/cfn-modules/docs/tree/master/examples/serverless-cron) | ||
| * [serverless-iam](https://github.com/cfn-modules/docs/tree/master/examples/serverless-iam) | ||
| * [serverless-image-resize](https://github.com/cfn-modules/docs/tree/master/examples/serverless-image-resize) | ||
| * [serverless-sqs-queue](https://github.com/cfn-modules/docs/tree/master/examples/serverless-sqs-queue) | ||
| * [serverless-webhook](https://github.com/cfn-modules/docs/tree/master/examples/serverless-webhook) | ||
| ## Related modules | ||
| ### Event sources | ||
@@ -109,2 +120,9 @@ | ||
| <tr> | ||
| <td>FunctionName</td> | ||
| <td>An optional but recommended name for the function and log group.</td> | ||
| <td></td> | ||
| <td>no</td> | ||
| <td></td> | ||
| </tr> | ||
| <tr> | ||
| <td>Description</td> | ||
@@ -111,0 +129,0 @@ <td>description of the function</td> |
| { | ||
| "private": true, | ||
| "dependencies": { | ||
| "eslint": "5.16.0", | ||
| "ava": "1.4.1", | ||
| "eslint": "6.0.1", | ||
| "ava": "2.2.0", | ||
| "@cfn-modules/test": "0.5.1", | ||
@@ -7,0 +7,0 @@ "@cfn-modules/s3-bucket": "1.4.1", |
+11
-0
@@ -15,2 +15,13 @@ const test = require('ava'); | ||
| test.serial('named', async t => { | ||
| const stackName = cfntest.stackName(); | ||
| try { | ||
| t.log(await cfntest.createStack(`${__dirname}/named.yml`, stackName, {})); | ||
| // what could we test here? | ||
| } finally { | ||
| t.log(await cfntest.deleteStack(stackName)); | ||
| t.pass(); | ||
| } | ||
| }); | ||
| test.serial('lambda-layer', async t => { | ||
@@ -17,0 +28,0 @@ const bucketStackName = cfntest.stackName(); |
38010
3.61%15
7.14%50
25%266
7.26%