@mapbox/cloudfriend 5.0.2 → 5.1.2-SNAPSHOT-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.travis.yml CHANGED
@@ -3,4 +3,4 @@ node_js:
3
3
  - 12
4
4
  - 14
5
5
  before_install:
6
- - pip install cfn-lint
6
+ - pip install cfn-lint==0.51.0
package/CODEOWNERS ADDED
@@ -0,0 +1,2 @@
1
+ # global owners
2
+ * @mapbox/orchestration
package/changelog.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## v5.1.1
4
+
5
+ - Dependency updates to avoid security vulnerabilities (minimist).
6
+
7
+ ## v5.1.0
8
+ - Lambda shortcuts now support custom Docker images.
9
+
3
10
  ## v5.0.2
4
11
  - Fixes handling custom access log formats in hookshot shortcuts.
5
12
 
@@ -228,6 +228,12 @@ class Lambda {
228
228
  this.Resources[`${LogicalName}`].Properties.Role = { 'Fn::GetAtt': [`${LogicalName}Role`, 'Arn'] };
229
229
  this.Resources = merge(this, serviceRole).Resources;
230
230
  }
231
+
232
+ if (Code.ImageUri) {
233
+ this.Resources[`${LogicalName}`].Properties.PackageType = 'Image';
234
+ delete this.Resources[`${LogicalName}`].Properties.Runtime;
235
+ delete this.Resources[`${LogicalName}`].Properties.Handler;
236
+ }
231
237
  }
232
238
  }
233
239
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapbox/cloudfriend",
3
- "version": "5.0.2",
3
+ "version": "5.1.2-SNAPSHOT-1",
4
4
  "description": "Helper functions for assembling CloudFormation templates in JavaScript",
5
5
  "main": "index.js",
6
6
  "engines": {
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "aws-sdk": "^2.829.0",
49
- "minimist": "^1.2.5",
49
+ "minimist": "^1.2.6",
50
50
  "redent": "^2.0.0"
51
51
  },
52
52
  "eslintConfig": {
@@ -0,0 +1,131 @@
1
+ {
2
+ "AWSTemplateFormatVersion": "2010-09-09",
3
+ "Metadata": {},
4
+ "Parameters": {},
5
+ "Rules": {},
6
+ "Mappings": {},
7
+ "Conditions": {},
8
+ "Resources": {
9
+ "MyLambdaLogs": {
10
+ "Type": "AWS::Logs::LogGroup",
11
+ "Properties": {
12
+ "LogGroupName": {
13
+ "Fn::Sub": [
14
+ "/aws/lambda/${name}",
15
+ {
16
+ "name": {
17
+ "Fn::Sub": "${AWS::StackName}-MyLambda"
18
+ }
19
+ }
20
+ ]
21
+ },
22
+ "RetentionInDays": 14
23
+ }
24
+ },
25
+ "MyLambda": {
26
+ "Type": "AWS::Lambda::Function",
27
+ "Properties": {
28
+ "PackageType": "Image",
29
+ "Code": {
30
+ "ImageUri": "MyImage"
31
+ },
32
+ "Description": {
33
+ "Fn::Sub": "MyLambda in the ${AWS::StackName} stack"
34
+ },
35
+ "FunctionName": {
36
+ "Fn::Sub": "${AWS::StackName}-MyLambda"
37
+ },
38
+ "MemorySize": 128,
39
+ "Timeout": 300,
40
+ "Role": {
41
+ "Fn::GetAtt": [
42
+ "MyLambdaRole",
43
+ "Arn"
44
+ ]
45
+ }
46
+ }
47
+ },
48
+ "MyLambdaErrorAlarm": {
49
+ "Type": "AWS::CloudWatch::Alarm",
50
+ "Properties": {
51
+ "AlarmName": {
52
+ "Fn::Sub": "${AWS::StackName}-MyLambda-Errors-${AWS::Region}"
53
+ },
54
+ "AlarmDescription": {
55
+ "Fn::Sub": [
56
+ "Error alarm for ${name} lambda function in ${AWS::StackName} stack",
57
+ {
58
+ "name": {
59
+ "Fn::Sub": "${AWS::StackName}-MyLambda"
60
+ }
61
+ }
62
+ ]
63
+ },
64
+ "AlarmActions": [],
65
+ "Period": 60,
66
+ "EvaluationPeriods": 5,
67
+ "DatapointsToAlarm": 1,
68
+ "Statistic": "Sum",
69
+ "Threshold": 0,
70
+ "ComparisonOperator": "GreaterThanThreshold",
71
+ "TreatMissingData": "notBreaching",
72
+ "Namespace": "AWS/Lambda",
73
+ "Dimensions": [
74
+ {
75
+ "Name": "FunctionName",
76
+ "Value": {
77
+ "Ref": "MyLambda"
78
+ }
79
+ }
80
+ ],
81
+ "MetricName": "Errors"
82
+ }
83
+ },
84
+ "MyLambdaLogPolicy": {
85
+ "Type": "AWS::IAM::Policy",
86
+ "DependsOn": "MyLambdaRole",
87
+ "Properties": {
88
+ "PolicyName": "lambda-log-access",
89
+ "Roles": [
90
+ {
91
+ "Ref": "MyLambdaRole"
92
+ }
93
+ ],
94
+ "PolicyDocument": {
95
+ "Version": "2012-10-17",
96
+ "Statement": [
97
+ {
98
+ "Effect": "Allow",
99
+ "Action": "logs:*",
100
+ "Resource": {
101
+ "Fn::GetAtt": [
102
+ "MyLambdaLogs",
103
+ "Arn"
104
+ ]
105
+ }
106
+ }
107
+ ]
108
+ }
109
+ }
110
+ },
111
+ "MyLambdaRole": {
112
+ "Type": "AWS::IAM::Role",
113
+ "Properties": {
114
+ "AssumeRolePolicyDocument": {
115
+ "Statement": [
116
+ {
117
+ "Effect": "Allow",
118
+ "Action": "sts:AssumeRole",
119
+ "Principal": {
120
+ "Service": {
121
+ "Fn::Sub": "lambda.amazonaws.com"
122
+ }
123
+ }
124
+ }
125
+ ]
126
+ }
127
+ }
128
+ }
129
+ },
130
+ "Outputs": {}
131
+ }
@@ -89,6 +89,21 @@ test('[shortcuts] lambda', (assert) => {
89
89
  'expected resources generated using all default values'
90
90
  );
91
91
 
92
+ lambda = new cf.shortcuts.Lambda({
93
+ LogicalName: 'MyLambda',
94
+ Code: {
95
+ ImageUri: 'MyImage'
96
+ }
97
+ });
98
+
99
+ template = cf.merge(lambda);
100
+ if (update) fixtures.update('lambda-docker', template);
101
+ assert.deepEqual(
102
+ noUndefined(template),
103
+ fixtures.get('lambda-docker'),
104
+ 'expected resources generated using all default values and a docker image'
105
+ );
106
+
92
107
  lambda = new cf.shortcuts.Lambda({
93
108
  LogicalName: 'MyLambda',
94
109
  Code: {
@@ -1,17 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "pwa-node",
9
- "request": "launch",
10
- "name": "Launch Program",
11
- "skipFiles": [
12
- "<node_internals>/**"
13
- ],
14
- "program": "${workspaceFolder}/test/some.test.js"
15
- }
16
- ]
17
- }