@mapbox/cloudfriend 5.0.1 → 5.1.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.
Files changed (30) hide show
  1. package/.travis.yml +3 -5
  2. package/CODEOWNERS +2 -0
  3. package/changelog.md +10 -0
  4. package/lib/shortcuts/hookshot.js +4 -4
  5. package/lib/shortcuts/lambda.js +6 -0
  6. package/package.json +2 -2
  7. package/test/fixtures/shortcuts/cross-account-role-no-defaults.json +2 -2
  8. package/test/fixtures/shortcuts/glue-json-table-no-defaults.json +1 -1
  9. package/test/fixtures/shortcuts/glue-orc-table-no-defaults.json +1 -1
  10. package/test/fixtures/shortcuts/glue-parquet-table-no-defaults.json +1 -1
  11. package/test/fixtures/shortcuts/glue-table-no-defaults.json +1 -1
  12. package/test/fixtures/shortcuts/glue-view-no-defaults.json +1 -1
  13. package/test/fixtures/shortcuts/hookshot-github-secret-ref.json +5 -5
  14. package/test/fixtures/shortcuts/hookshot-github-secret-string.json +5 -5
  15. package/test/fixtures/shortcuts/hookshot-github.json +5 -5
  16. package/test/fixtures/shortcuts/hookshot-passthrough-access-log-format.json +13 -13
  17. package/test/fixtures/shortcuts/hookshot-passthrough-alarms.json +2 -2
  18. package/test/fixtures/shortcuts/hookshot-passthrough-enhanced-logging.json +2 -2
  19. package/test/fixtures/shortcuts/hookshot-passthrough-full-blown-logging.json +2 -2
  20. package/test/fixtures/shortcuts/hookshot-passthrough-logging.json +2 -2
  21. package/test/fixtures/shortcuts/hookshot-passthrough.json +2 -2
  22. package/test/fixtures/shortcuts/lambda-docker.json +131 -0
  23. package/test/fixtures/shortcuts/lambda-provided-role.json +3 -1
  24. package/test/fixtures/shortcuts/role-no-defaults.json +2 -2
  25. package/test/fixtures/shortcuts/service-role-no-defaults.json +2 -2
  26. package/test/fixtures/shortcuts/stream-lambda-defaults.json +3 -3
  27. package/test/fixtures/shortcuts/stream-lambda-no-defaults.json +3 -3
  28. package/test/index.test.js +0 -13
  29. package/test/shortcuts.test.js +46 -16
  30. package/cloudformation/ci.template.js +0 -5
package/.travis.yml CHANGED
@@ -1,8 +1,6 @@
1
1
  language: node_js
2
2
  node_js:
3
- - 10
4
3
  - 12
5
- env:
6
- global:
7
- - secure: ucYs7Z82X7hsIq70GF3dgxmXI+VzBzM22B+jwGcJRQvp1R12fRv/P8/Eb/ScvDCeU9cJvP/FJ8GeGC6kPFHDjCZLyCxFG/SY/O550lE+hkTkQjHG933p3F2a0jCmhlMC2kTI7Dw4yk9dK0tgpnzBmswbgtT/QyvcImcxzBC0hcr9KJ3JCvSpQmi+TFdaDRmqs6H5Qy2owfiD6Ei0y6s3JEygYDHqWTbsrovhUwRvlFh/NgWOZ1lDu0FV71iPE+3LGrkSp+xyEAVQN/1ar/hqTufhSvcxD9Uf2kGUwqg4U2n+k46jd6h1rTDXyh31J62k2AJN0T6p6N5EGBKS/zzvuuhQN/yZdieMdxQpAho8i5TZyXdVp+RHPQxoTNnHL+O6obad13Q+o2iCr/1zaYefjG+23/wGCxdBtkjukGrD+6CwZ8gSwUxqhBUh9Q8oDI92jxd+jWp2VEcs7sXravaHhBWG2oNrb8tksOOElP2iD2iRkUdnvrAORzKWsxi7d3FhQE2TtvvD+icwpMQ6oHZS0PFKC0YzlUp3mfhtOl56UJsYYgEuamloUwsblO+kr5P60ZMevuyx5jNEE05bKi2kJ2kj02P0MD9cXjrWqNvcTBX6CYs/X3XSruBJPQNxbrp+rrsZWw2lFRXGg9+m1kS691TPhgRbMyOWL89zV0PqrGY=
8
- - secure: ELtMfU71GlyGC/T1/nDkLubWDovykXSBCbal0EtDKpl/fd3uaWT5M/elW0s7pFlcvgsp+Vw+aPHFEOf3HvjSG4d8tnoB4P3nAFINyw0a6ewJl8v2u+zXLrZr98S9aQI+mFm9xjpHe5G37/MjkfzbwT3Dl3guqqMBiffAecQXge/Gynn59PZypN+9Q/Ih5MgAXMaR3IJMIHQ61A+vL0A6fjeFmgM4uFpXXmoIYqD5Cah742Uv3YdZkbjC+e36jak/4l396+AAvWa21QjtHpy2hJ10NM0FCbxr669aP2Y+J+PLr+rPjqUqqG5xkJijMyDV8lqiZu0NI4Yd5dFjT538GDSXa5RMg+UhhwoK+zcOs6TbUyER7JgF0JFqCRY8A36yX6/aYFABGQhqqlgmcUuxEOLPxp5bVhIKyqehWckcFaS3KbUyMuFJ5ngXcHpI/j0uL20RBRz8W546dXoFh2kQl1bytXAnK9b2ZWfKjt6GAg/c12jg5daNFLXcbSWsyFn0yBXqMZN1XuJvoc8vZ+zDprG8U4ywrHKku3OqbGukwNIrXD2k1zl9hk+KrBj06TwLrsBkB5K8EyKKjPMX5v7fiox5rLt3kVqbcATUqxcF1Qjf3lqCxvi5CgjU4Nc2SWSUzBVRBFbLprWk0GbVoJNJXLSlo748SS35wDT4Fu9B6k8=
4
+ - 14
5
+ before_install:
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,15 @@
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
+
10
+ ## v5.0.2
11
+ - Fixes handling custom access log formats in hookshot shortcuts.
12
+
3
13
  ## v5.0.1
4
14
  - Improves data type mappings between Glue and Presto when using the `GluePrestoView` shortcut.
5
15
 
@@ -199,7 +199,7 @@ class Passthrough {
199
199
  }
200
200
  };
201
201
 
202
- Resources[`${Prefix}Stage`].Properties.MethodSettings[0].AccessLogSetting = {
202
+ Resources[`${Prefix}Stage`].Properties.AccessLogSetting = {
203
203
  DestinationArn: { 'Fn::GetAtt': [`${Prefix}AccessLogs`, 'Arn'] },
204
204
  Format: AccessLogFormat
205
205
  };
@@ -373,14 +373,14 @@ class Github extends Passthrough {
373
373
  IntegrationHttpMethod: 'POST',
374
374
  IntegrationResponses: [
375
375
  {
376
- StatusCode: 200
376
+ StatusCode: '200'
377
377
  },
378
378
  {
379
- StatusCode: 500,
379
+ StatusCode: '500',
380
380
  SelectionPattern: '^error.*'
381
381
  },
382
382
  {
383
- StatusCode: 403,
383
+ StatusCode: '403',
384
384
  SelectionPattern: '^invalid.*'
385
385
  }
386
386
  ],
@@ -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.1",
3
+ "version": "5.1.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": {
@@ -24,8 +24,8 @@
24
24
  "ManagedPolicyArns": [
25
25
  "arn:aws:iam::123456789012:policy/fake"
26
26
  ],
27
- "MaxSessionDuration": 60,
28
- "Path": "/fake",
27
+ "MaxSessionDuration": 3600,
28
+ "Path": "/fake/",
29
29
  "RoleName": "my-role",
30
30
  "AssumeRolePolicyDocument": {
31
31
  "Statement": [
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "PartitionKeys": [],
34
34
  "Retention": 12,
35
- "TableType": "TABLE_TYPE",
35
+ "TableType": "EXTERNAL_TABLE",
36
36
  "ViewExpandedText": "/* Presto View */",
37
37
  "ViewOriginalText": "/* Presto View: abc123= */",
38
38
  "StorageDescriptor": {
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "PartitionKeys": [],
34
34
  "Retention": 12,
35
- "TableType": "TABLE_TYPE",
35
+ "TableType": "EXTERNAL_TABLE",
36
36
  "ViewExpandedText": "/* Presto View */",
37
37
  "ViewOriginalText": "/* Presto View: abc123= */",
38
38
  "StorageDescriptor": {
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "PartitionKeys": [],
34
34
  "Retention": 12,
35
- "TableType": "TABLE_TYPE",
35
+ "TableType": "EXTERNAL_TABLE",
36
36
  "ViewExpandedText": "/* Presto View */",
37
37
  "ViewOriginalText": "/* Presto View: abc123= */",
38
38
  "StorageDescriptor": {
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "PartitionKeys": [],
34
34
  "Retention": 12,
35
- "TableType": "TABLE_TYPE",
35
+ "TableType": "EXTERNAL_TABLE",
36
36
  "ViewExpandedText": "/* Presto View */",
37
37
  "ViewOriginalText": "/* Presto View: abc123= */",
38
38
  "StorageDescriptor": {
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "PartitionKeys": [],
34
34
  "Retention": 12,
35
- "TableType": "TABLE_TYPE",
35
+ "TableType": "EXTERNAL_TABLE",
36
36
  "ViewExpandedText": "/* Presto View */",
37
37
  "ViewOriginalText": {
38
38
  "Fn::Sub": [
@@ -28,7 +28,7 @@
28
28
  "Type": "AWS::ApiGateway::Stage",
29
29
  "Properties": {
30
30
  "DeploymentId": {
31
- "Ref": "PassDeployment6237c388"
31
+ "Ref": "PassDeployment0209686b"
32
32
  },
33
33
  "StageName": "hookshot",
34
34
  "RestApiId": {
@@ -47,7 +47,7 @@
47
47
  ]
48
48
  }
49
49
  },
50
- "PassDeployment6237c388": {
50
+ "PassDeployment0209686b": {
51
51
  "Type": "AWS::ApiGateway::Deployment",
52
52
  "DependsOn": "PassMethod",
53
53
  "Properties": {
@@ -89,14 +89,14 @@
89
89
  "IntegrationHttpMethod": "POST",
90
90
  "IntegrationResponses": [
91
91
  {
92
- "StatusCode": 200
92
+ "StatusCode": "200"
93
93
  },
94
94
  {
95
- "StatusCode": 500,
95
+ "StatusCode": "500",
96
96
  "SelectionPattern": "^error.*"
97
97
  },
98
98
  {
99
- "StatusCode": 403,
99
+ "StatusCode": "403",
100
100
  "SelectionPattern": "^invalid.*"
101
101
  }
102
102
  ],
@@ -24,7 +24,7 @@
24
24
  "Type": "AWS::ApiGateway::Stage",
25
25
  "Properties": {
26
26
  "DeploymentId": {
27
- "Ref": "PassDeployment6237c388"
27
+ "Ref": "PassDeployment0209686b"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  }
45
45
  },
46
- "PassDeployment6237c388": {
46
+ "PassDeployment0209686b": {
47
47
  "Type": "AWS::ApiGateway::Deployment",
48
48
  "DependsOn": "PassMethod",
49
49
  "Properties": {
@@ -85,14 +85,14 @@
85
85
  "IntegrationHttpMethod": "POST",
86
86
  "IntegrationResponses": [
87
87
  {
88
- "StatusCode": 200
88
+ "StatusCode": "200"
89
89
  },
90
90
  {
91
- "StatusCode": 500,
91
+ "StatusCode": "500",
92
92
  "SelectionPattern": "^error.*"
93
93
  },
94
94
  {
95
- "StatusCode": 403,
95
+ "StatusCode": "403",
96
96
  "SelectionPattern": "^invalid.*"
97
97
  }
98
98
  ],
@@ -24,7 +24,7 @@
24
24
  "Type": "AWS::ApiGateway::Stage",
25
25
  "Properties": {
26
26
  "DeploymentId": {
27
- "Ref": "PassDeployment6237c388"
27
+ "Ref": "PassDeployment0209686b"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  }
45
45
  },
46
- "PassDeployment6237c388": {
46
+ "PassDeployment0209686b": {
47
47
  "Type": "AWS::ApiGateway::Deployment",
48
48
  "DependsOn": "PassMethod",
49
49
  "Properties": {
@@ -85,14 +85,14 @@
85
85
  "IntegrationHttpMethod": "POST",
86
86
  "IntegrationResponses": [
87
87
  {
88
- "StatusCode": 200
88
+ "StatusCode": "200"
89
89
  },
90
90
  {
91
- "StatusCode": 500,
91
+ "StatusCode": "500",
92
92
  "SelectionPattern": "^error.*"
93
93
  },
94
94
  {
95
- "StatusCode": 403,
95
+ "StatusCode": "403",
96
96
  "SelectionPattern": "^invalid.*"
97
97
  }
98
98
  ],
@@ -24,7 +24,7 @@
24
24
  "Type": "AWS::ApiGateway::Stage",
25
25
  "Properties": {
26
26
  "DeploymentId": {
27
- "Ref": "PassDeployment6237c388"
27
+ "Ref": "PassDeployment0209686b"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -38,21 +38,21 @@
38
38
  "ThrottlingRateLimit": 5,
39
39
  "LoggingLevel": "OFF",
40
40
  "DataTraceEnabled": false,
41
- "MetricsEnabled": false,
42
- "AccessLogSetting": {
43
- "DestinationArn": {
44
- "Fn::GetAtt": [
45
- "PassAccessLogs",
46
- "Arn"
47
- ]
48
- },
49
- "Format": "{ \"requestId\":\"$context.requestId\" }"
50
- }
41
+ "MetricsEnabled": false
51
42
  }
52
- ]
43
+ ],
44
+ "AccessLogSetting": {
45
+ "DestinationArn": {
46
+ "Fn::GetAtt": [
47
+ "PassAccessLogs",
48
+ "Arn"
49
+ ]
50
+ },
51
+ "Format": "{ \"requestId\":\"$context.requestId\" }"
52
+ }
53
53
  }
54
54
  },
55
- "PassDeployment6237c388": {
55
+ "PassDeployment0209686b": {
56
56
  "Type": "AWS::ApiGateway::Deployment",
57
57
  "DependsOn": "PassMethod",
58
58
  "Properties": {
@@ -24,7 +24,7 @@
24
24
  "Type": "AWS::ApiGateway::Stage",
25
25
  "Properties": {
26
26
  "DeploymentId": {
27
- "Ref": "PassDeployment6237c388"
27
+ "Ref": "PassDeployment0209686b"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  }
45
45
  },
46
- "PassDeployment6237c388": {
46
+ "PassDeployment0209686b": {
47
47
  "Type": "AWS::ApiGateway::Deployment",
48
48
  "DependsOn": "PassMethod",
49
49
  "Properties": {
@@ -24,7 +24,7 @@
24
24
  "Type": "AWS::ApiGateway::Stage",
25
25
  "Properties": {
26
26
  "DeploymentId": {
27
- "Ref": "PassDeployment6237c388"
27
+ "Ref": "PassDeployment0209686b"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  }
45
45
  },
46
- "PassDeployment6237c388": {
46
+ "PassDeployment0209686b": {
47
47
  "Type": "AWS::ApiGateway::Deployment",
48
48
  "DependsOn": "PassMethod",
49
49
  "Properties": {
@@ -24,7 +24,7 @@
24
24
  "Type": "AWS::ApiGateway::Stage",
25
25
  "Properties": {
26
26
  "DeploymentId": {
27
- "Ref": "PassDeployment6237c388"
27
+ "Ref": "PassDeployment0209686b"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  }
45
45
  },
46
- "PassDeployment6237c388": {
46
+ "PassDeployment0209686b": {
47
47
  "Type": "AWS::ApiGateway::Deployment",
48
48
  "DependsOn": "PassMethod",
49
49
  "Properties": {
@@ -24,7 +24,7 @@
24
24
  "Type": "AWS::ApiGateway::Stage",
25
25
  "Properties": {
26
26
  "DeploymentId": {
27
- "Ref": "PassDeployment6237c388"
27
+ "Ref": "PassDeployment0209686b"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  }
45
45
  },
46
- "PassDeployment6237c388": {
46
+ "PassDeployment0209686b": {
47
47
  "Type": "AWS::ApiGateway::Deployment",
48
48
  "DependsOn": "PassMethod",
49
49
  "Properties": {
@@ -24,7 +24,7 @@
24
24
  "Type": "AWS::ApiGateway::Stage",
25
25
  "Properties": {
26
26
  "DeploymentId": {
27
- "Ref": "PassDeployment6237c388"
27
+ "Ref": "PassDeployment0209686b"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  }
45
45
  },
46
- "PassDeployment6237c388": {
46
+ "PassDeployment0209686b": {
47
47
  "Type": "AWS::ApiGateway::Deployment",
48
48
  "DependsOn": "PassMethod",
49
49
  "Properties": {
@@ -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
+ }
@@ -124,7 +124,9 @@
124
124
  },
125
125
  "CustomLambdaRole": {
126
126
  "Type": "AWS::IAM::Role",
127
- "Properties": {}
127
+ "Properties": {
128
+ "AssumeRolePolicyDocument": {}
129
+ }
128
130
  }
129
131
  },
130
132
  "Outputs": {}
@@ -24,8 +24,8 @@
24
24
  "ManagedPolicyArns": [
25
25
  "arn:aws:iam::123456789012:policy/fake"
26
26
  ],
27
- "MaxSessionDuration": 60,
28
- "Path": "/fake",
27
+ "MaxSessionDuration": 3600,
28
+ "Path": "/fake/",
29
29
  "RoleName": "my-role",
30
30
  "Tags": [
31
31
  {
@@ -24,8 +24,8 @@
24
24
  "ManagedPolicyArns": [
25
25
  "arn:aws:iam::123456789012:policy/fake"
26
26
  ],
27
- "MaxSessionDuration": 60,
28
- "Path": "/fake",
27
+ "MaxSessionDuration": 3600,
28
+ "Path": "/fake/",
29
29
  "RoleName": "my-role",
30
30
  "AssumeRolePolicyDocument": {
31
31
  "Statement": [
@@ -145,12 +145,12 @@
145
145
  "kinesis:ListStreams"
146
146
  ],
147
147
  "Resource": [
148
- "arn:aws:sqs:us-east-1:123456789012:queue/fake",
148
+ "arn:aws:kinesis:us-east-1:123456789012:stream/fake",
149
149
  {
150
150
  "Fn::Sub": [
151
151
  "${arn}/*",
152
152
  {
153
- "arn": "arn:aws:sqs:us-east-1:123456789012:queue/fake"
153
+ "arn": "arn:aws:kinesis:us-east-1:123456789012:stream/fake"
154
154
  }
155
155
  ]
156
156
  }
@@ -167,7 +167,7 @@
167
167
  "Properties": {
168
168
  "BatchSize": 1,
169
169
  "Enabled": true,
170
- "EventSourceArn": "arn:aws:sqs:us-east-1:123456789012:queue/fake",
170
+ "EventSourceArn": "arn:aws:kinesis:us-east-1:123456789012:stream/fake",
171
171
  "FunctionName": {
172
172
  "Ref": "MyLambda"
173
173
  },
@@ -145,12 +145,12 @@
145
145
  "kinesis:ListStreams"
146
146
  ],
147
147
  "Resource": [
148
- "arn:aws:sqs:us-east-1:123456789012:queue/fake",
148
+ "arn:aws:kinesis:us-east-1:123456789012:stream/fake",
149
149
  {
150
150
  "Fn::Sub": [
151
151
  "${arn}/*",
152
152
  {
153
- "arn": "arn:aws:sqs:us-east-1:123456789012:queue/fake"
153
+ "arn": "arn:aws:kinesis:us-east-1:123456789012:stream/fake"
154
154
  }
155
155
  ]
156
156
  }
@@ -168,7 +168,7 @@
168
168
  "BatchSize": 10000,
169
169
  "MaximumBatchingWindowInSeconds": 300,
170
170
  "Enabled": false,
171
- "EventSourceArn": "arn:aws:sqs:us-east-1:123456789012:queue/fake",
171
+ "EventSourceArn": "arn:aws:kinesis:us-east-1:123456789012:stream/fake",
172
172
  "FunctionName": {
173
173
  "Ref": "MyLambda"
174
174
  },
@@ -102,19 +102,6 @@ test('build', (assert) => {
102
102
  });
103
103
  });
104
104
 
105
- test('validate', (assert) => {
106
- assert.plan(2);
107
-
108
- cloudfriend.validate(path.join(fixtures, 'static.json'))
109
- .then(() => {
110
- assert.ok(true, 'valid');
111
- return cloudfriend.validate(path.join(fixtures, 'invalid.json'));
112
- })
113
- .catch((err) => {
114
- assert.ok(/Template format error: Unrecognized resource type/.test(err.message), 'invalid');
115
- });
116
- });
117
-
118
105
  test('merge', (assert) => {
119
106
  const a = {
120
107
  Metadata: { Instances: { Description: 'Information about the instances' } },
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ const cp = require('child_process');
3
4
  const path = require('path');
4
5
  const fs = require('fs');
5
6
  const test = require('tape');
@@ -13,6 +14,15 @@ const update = !!process.env.UPDATE;
13
14
  const noUndefined = (template) => JSON.parse(JSON.stringify(template));
14
15
 
15
16
  test('[shortcuts] fixture validation', async (assert) => {
17
+ // Runs cfn-lint, ignoring "warnings". Install via pip or Homebrew to run these
18
+ // tests locally.
19
+ const cfnLint = (filepath) => new Promise((resolve, reject) => {
20
+ cp.exec(`cfn-lint ${filepath} --ignore-checks W`, (err, stdout) => {
21
+ if (err) return reject(new Error(stdout));
22
+ return resolve();
23
+ });
24
+ });
25
+
16
26
  const toValidate = fs
17
27
  .readdirSync(path.join(__dirname, 'fixtures', 'shortcuts'))
18
28
  .filter((filename) => path.extname(filename) === '.json');
@@ -20,9 +30,12 @@ test('[shortcuts] fixture validation', async (assert) => {
20
30
  while (toValidate.length) {
21
31
  const filename = toValidate.shift();
22
32
  await Promise.all([
23
- cf.validate(path.join(__dirname, 'fixtures', 'shortcuts', filename))
33
+ cfnLint(path.join(__dirname, 'fixtures', 'shortcuts', filename))
24
34
  .then(() => assert.pass(`${filename} fixture passed validation`))
25
- .catch((err) => assert.fail(`${filename} fixture fails validation: ${err.message}`)),
35
+ .catch((err) => {
36
+ assert.fail(`${filename} fixture fails validation`);
37
+ console.log(err.message);
38
+ }),
26
39
  sleep(1000)
27
40
  ]);
28
41
  }
@@ -76,6 +89,21 @@ test('[shortcuts] lambda', (assert) => {
76
89
  'expected resources generated using all default values'
77
90
  );
78
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
+
79
107
  lambda = new cf.shortcuts.Lambda({
80
108
  LogicalName: 'MyLambda',
81
109
  Code: {
@@ -104,7 +132,9 @@ test('[shortcuts] lambda', (assert) => {
104
132
  Resources: {
105
133
  'CustomLambdaRole': {
106
134
  Type: 'AWS::IAM::Role',
107
- Properties: {}
135
+ Properties: {
136
+ AssumeRolePolicyDocument: {}
137
+ }
108
138
  }
109
139
  }
110
140
  });
@@ -425,7 +455,7 @@ test('[shortcuts] stream-lambda', (assert) => {
425
455
  S3Bucket: 'my-code-bucket',
426
456
  S3Key: 'path/to/code.zip'
427
457
  },
428
- EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake'
458
+ EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake'
429
459
  });
430
460
 
431
461
  let template = cf.merge(lambda);
@@ -442,7 +472,7 @@ test('[shortcuts] stream-lambda', (assert) => {
442
472
  S3Bucket: 'my-code-bucket',
443
473
  S3Key: 'path/to/code.zip'
444
474
  },
445
- EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
475
+ EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
446
476
  BatchSize: 10000,
447
477
  MaximumBatchingWindowInSeconds: 300,
448
478
  Enabled: false,
@@ -734,8 +764,8 @@ test('[shortcuts] role', (assert) => {
734
764
  }
735
765
  ],
736
766
  ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
737
- MaxSessionDuration: 60,
738
- Path: '/fake',
767
+ MaxSessionDuration: 3600,
768
+ Path: '/fake/',
739
769
  RoleName: 'my-role',
740
770
  Tags: [{ Key: 'pipeline-name', Value: 'test' }],
741
771
  Condition: 'Always',
@@ -801,8 +831,8 @@ test('[shortcuts] cross-account role', (assert) => {
801
831
  }
802
832
  ],
803
833
  ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
804
- MaxSessionDuration: 60,
805
- Path: '/fake',
834
+ MaxSessionDuration: 3600,
835
+ Path: '/fake/',
806
836
  RoleName: 'my-role',
807
837
  Condition: 'Always',
808
838
  DependsOn: 'AnotherThing'
@@ -899,8 +929,8 @@ test('[shortcuts] service role', (assert) => {
899
929
  }
900
930
  ],
901
931
  ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
902
- MaxSessionDuration: 60,
903
- Path: '/fake',
932
+ MaxSessionDuration: 3600,
933
+ Path: '/fake/',
904
934
  RoleName: 'my-role',
905
935
  Condition: 'Always',
906
936
  DependsOn: 'AnotherThing'
@@ -1013,7 +1043,7 @@ test('[shortcuts] glue table', (assert) => {
1013
1043
  Parameters: { table: 'params' },
1014
1044
  Description: 'my_table description',
1015
1045
  Retention: 12,
1016
- TableType: 'TABLE_TYPE',
1046
+ TableType: 'EXTERNAL_TABLE',
1017
1047
  ViewExpandedText: '/* Presto View */',
1018
1048
  ViewOriginalText: '/* Presto View: abc123= */',
1019
1049
  BucketColumns: ['column'],
@@ -1095,7 +1125,7 @@ test('[shortcuts] glue json table', (assert) => {
1095
1125
  Parameters: { table: 'params' },
1096
1126
  Description: 'my_table description',
1097
1127
  Retention: 12,
1098
- TableType: 'TABLE_TYPE',
1128
+ TableType: 'EXTERNAL_TABLE',
1099
1129
  ViewExpandedText: '/* Presto View */',
1100
1130
  ViewOriginalText: '/* Presto View: abc123= */',
1101
1131
  BucketColumns: ['column'],
@@ -1177,7 +1207,7 @@ test('[shortcuts] glue orc table', (assert) => {
1177
1207
  Parameters: { table: 'params' },
1178
1208
  Description: 'my_table description',
1179
1209
  Retention: 12,
1180
- TableType: 'TABLE_TYPE',
1210
+ TableType: 'EXTERNAL_TABLE',
1181
1211
  ViewExpandedText: '/* Presto View */',
1182
1212
  ViewOriginalText: '/* Presto View: abc123= */',
1183
1213
  BucketColumns: ['column'],
@@ -1259,7 +1289,7 @@ test('[shortcuts] glue parquet table', (assert) => {
1259
1289
  Parameters: { table: 'params' },
1260
1290
  Description: 'my_table description',
1261
1291
  Retention: 12,
1262
- TableType: 'TABLE_TYPE',
1292
+ TableType: 'EXTERNAL_TABLE',
1263
1293
  ViewExpandedText: '/* Presto View */',
1264
1294
  ViewOriginalText: '/* Presto View: abc123= */',
1265
1295
  BucketColumns: ['column'],
@@ -1342,7 +1372,7 @@ test('[shortcuts] glue view', (assert) => {
1342
1372
  Parameters: { table: 'params' },
1343
1373
  Description: 'my_view description',
1344
1374
  Retention: 12,
1345
- TableType: 'TABLE_TYPE',
1375
+ TableType: 'EXTERNAL_TABLE',
1346
1376
  BucketColumns: ['column'],
1347
1377
  Compressed: true,
1348
1378
  Location: 's3://fake/location',
@@ -1,5 +0,0 @@
1
- 'use strict';
2
-
3
- const cloudfriend = require('..');
4
-
5
- module.exports = cloudfriend.permissions;