Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ Resources:
KmsKeyModule: !GetAtt 'Key.Outputs.StackName' # optional
VpcModule: !GetAtt 'Vpc.Outputs.StackName' # optional
DeadLetterQueueModule: !GetAtt 'Queue.Outputs.StackName' # optional
LayerModule: !GetAtt 'Layer.Outputs.StackName' # optional
Description: '' # optional
Handler: 'example.handler' # required (file must be in the `lambda-src` folder)
MemorySize: '128' # optional
Expand All @@ -48,6 +47,7 @@ Resources:
EnvironmentVariable2: '' # optional
EnvironmentVariable3: '' # optional
ManagedPolicyArns: '' # optional
LayerArns: '' # optional
TemplateURL: './node_modules/@cfn-modules/lambda-function/module.yml'
```

Expand Down Expand Up @@ -100,13 +100,6 @@ Resources:
<td>no</td>
<td></td>
</tr>
<tr>
<td>LayerModule</td>
<td>Stack name of <a href="https://www.npmjs.com/package/@cfn-modules/lambda-layer">lambda-layer module</a></td>
<td></td>
<td>no</td>
<td></td>
</tr>
<tr>
<td>Description</td>
<td>description of the function</td>
Expand Down Expand Up @@ -212,5 +205,19 @@ Resources:
<td>no</td>
<td></td>
</tr>
<tr>
<td>LayerArns</td>
<td>Comma-delimited list of Layer ARNs to attach to the function</td>
<td></td>
<td>no</td>
<td></td>
</tr>
</tbody>
</table>


## Migration Guides

### Migrate to v2

* The `lambda-layer` module is no longer supported. Replace the `LayerModule` parameter with a comma-delimited list of Layer ARNs to attach to the function `LayerArns`. Define the Lambda layer in your own template.
15 changes: 7 additions & 8 deletions module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ Parameters:
Description: 'Optional but recommended for async invocations stack name of sqs-queue module where Lambda sends events to after the maximum number of retries was reached'
Type: String
Default: ''
LayerModule:
Description: 'Optional stack name of lambda-layer module.'
Type: String
Default: ''
Description:
Description: 'Optional description of the function'
Type: String
Expand Down Expand Up @@ -116,17 +112,21 @@ Parameters:
Description: 'Optional comma-delimited list of IAM managed policy ARNs to attach to the task''s IAM role'
Type: String
Default: ''
LayerArns:
Description: 'Optional comma-delimited list of Layer ARNs to attach to the function'
Type: String
Default: ''
Conditions:
HasAlertingModule: !Not [!Equals [!Ref AlertingModule, '']]
HasKmsKeyModule: !Not [!Equals [!Ref KmsKeyModule, '']]
HasDeadLetterQueueModule: !Not [!Equals [!Ref DeadLetterQueueModule, '']]
HasLayerModule: !Not [!Equals [!Ref LayerModule, '']]
HasReservedConcurrentExecutions: !Not [!Equals [!Ref ReservedConcurrentExecutions, -1]]
HasVpcModule: !Not [!Equals [!Ref VpcModule, '']]
HasDependencyModule1: !Not [!Equals [!Ref DependencyModule1, '']]
HasDependencyModule2: !Not [!Equals [!Ref DependencyModule2, '']]
HasDependencyModule3: !Not [!Equals [!Ref DependencyModule3, '']]
HasManagedPolicyArns: !Not [!Equals [!Ref ManagedPolicyArns, '']]
HasLayerArns: !Not [!Equals [!Ref LayerArns, '']]
Resources:
Role:
Type: 'AWS::IAM::Role'
Expand Down Expand Up @@ -208,8 +208,7 @@ Resources:
- SecurityGroupIds: [!Ref SecurityGroup]
SubnetIds: !Split [',', {'Fn::ImportValue': !Sub '${VpcModule}-SubnetIdsPrivate'}]
- !Ref 'AWS::NoValue'
Layers:
- !If [HasLayerModule, {'Fn::ImportValue': !Sub '${LayerModule}-Arn'}, !Ref 'AWS::NoValue']
Layers: !If [HasLayerArns, !Split [',', !Ref LayerArns], !Ref 'AWS::NoValue']
ErrorsTooHighAlarm:
Condition: HasAlertingModule
Type: 'AWS::CloudWatch::Alarm'
Expand Down Expand Up @@ -252,7 +251,7 @@ Outputs:
ModuleId:
Value: 'lambda-function'
ModuleVersion:
Value: '1.3.1'
Value: '2.0.0'
StackName:
Value: !Ref 'AWS::StackName'
Arn:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cfn-modules/lambda-function",
"version": "1.3.1",
"version": "2.0.0",
"description": "AWS Lambda function with automated IAM policy generation, encryption, log group and alerting",
"author": "Michael Wittig <[email protected]>",
"license": "Apache-2.0",
Expand Down
11 changes: 5 additions & 6 deletions test/layer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,16 @@ Parameters:
Type: String
Resources:
Layer:
Type: 'AWS::CloudFormation::Stack'
Type: 'AWS::Lambda::LayerVersion'
Properties:
Parameters:
ContentBucket: !Ref ContentBucket
ContentKey: !Ref ContentKey
TemplateURL: './node_modules/@cfn-modules/lambda-layer/module.yml'
Content:
S3Bucket: !Ref ContentBucket
S3Key: !Ref ContentKey
Function:
Type: 'AWS::CloudFormation::Stack'
Properties:
Parameters:
Handler: 'defaults.handler'
Runtime: 'nodejs8.10'
LayerModule: !GetAtt 'Layer.Outputs.StackName'
LayerArns: !Ref Layer
TemplateURL: './node_modules/@cfn-modules/lambda-function/module.yml'
15 changes: 5 additions & 10 deletions test/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"ava": "0.25.0",
"@cfn-modules/test": "0.4.0",
"@cfn-modules/s3-bucket": "1.2.0",
"@cfn-modules/lambda-layer": "1.0.0",
"@cfn-modules/lambda-function": "file:../"
},
"scripts": {
Expand Down