@mapbox/cloudfriend 8.2.0 → 8.3.0
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/.nyc_output/3129d911-ae18-4550-9ed8-077e4d8442fb.json +1 -0
- package/.nyc_output/713d29d9-ffc7-41fd-b87a-23479319de91.json +1 -0
- package/.nyc_output/processinfo/3129d911-ae18-4550-9ed8-077e4d8442fb.json +1 -0
- package/.nyc_output/processinfo/713d29d9-ffc7-41fd-b87a-23479319de91.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/changelog.md +4 -0
- package/lib/intrinsic.js +8 -2
- package/package.json +2 -1
- package/test/fixtures/shortcuts/hookshot-github-secret-ref.json +2 -2
- package/test/fixtures/shortcuts/hookshot-github-secret-string.json +2 -2
- package/test/fixtures/shortcuts/hookshot-github.json +2 -2
- package/test/fixtures/shortcuts/hookshot-passthrough-access-log-format.json +2 -2
- package/test/fixtures/shortcuts/hookshot-passthrough-alarms.json +2 -2
- package/test/fixtures/shortcuts/hookshot-passthrough-enhanced-logging.json +2 -2
- package/test/fixtures/shortcuts/hookshot-passthrough-full-blown-logging.json +2 -2
- package/test/fixtures/shortcuts/hookshot-passthrough-logging.json +2 -2
- package/test/fixtures/shortcuts/hookshot-passthrough.json +2 -2
- package/test/fixtures/shortcuts/lambda-full.json +28 -9
- package/test/fixtures/shortcuts/stream-lambda-no-defaults.json +8 -8
- package/test/index.test.js +1 -0
- package/.nyc_output/3d263a21-c592-478a-a9b6-71ff681d5523.json +0 -1
- package/.nyc_output/be006597-158b-404c-aed6-72c7cce3e612.json +0 -1
- package/.nyc_output/processinfo/3d263a21-c592-478a-a9b6-71ff681d5523.json +0 -1
- package/.nyc_output/processinfo/be006597-158b-404c-aed6-72c7cce3e612.json +0 -1
package/lib/intrinsic.js
CHANGED
|
@@ -48,10 +48,16 @@ intrinsic.cidr = (ipBlock, count, cidrBits) => {
|
|
|
48
48
|
* key-value pairs.
|
|
49
49
|
* @param {string} attr - The second-level key name, which is set to one of the
|
|
50
50
|
* keys from the list assigned to key.
|
|
51
|
+
* @param {string} defaultValue - The value that will resolve to if the key and/or attr can not be found from the mapping map.
|
|
52
|
+
* This field is optional and requires AWS::LanguageExtensions to be defined in the template.
|
|
51
53
|
* @returns The value that is assigned to SecondLevelKey.
|
|
52
54
|
*/
|
|
53
|
-
intrinsic.findInMap = (mapping, key, attr) => {
|
|
54
|
-
|
|
55
|
+
intrinsic.findInMap = (mapping, key, attr, defaultValue) => {
|
|
56
|
+
const lookup = [mapping, key, attr];
|
|
57
|
+
if (defaultValue) {
|
|
58
|
+
lookup.push({ DefaultValue: defaultValue });
|
|
59
|
+
}
|
|
60
|
+
return { 'Fn::FindInMap': lookup };
|
|
55
61
|
};
|
|
56
62
|
|
|
57
63
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapbox/cloudfriend",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"description": "Helper functions for assembling CloudFormation templates in JavaScript",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"engines": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"lint": "eslint index.js test lib bin cloudformation",
|
|
12
12
|
"lint:fix": "npm run lint -- --fix",
|
|
13
13
|
"test": "nyc tape test/*.test.js | tap-spec",
|
|
14
|
+
"test:update": "UPDATE=1 npm run test",
|
|
14
15
|
"coverage": "nyc --reporter html tape test/*.test.js && opener coverage/index.html",
|
|
15
16
|
"build-ci-template": "bin/build-template.js cloudformation/ci.template.js > cloudformation/ci.template.json",
|
|
16
17
|
"shortcuts-api-doc": "jsdoc2md lib/shortcuts/*.js > lib/shortcuts/api.md"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"Type": "AWS::ApiGateway::Stage",
|
|
29
29
|
"Properties": {
|
|
30
30
|
"DeploymentId": {
|
|
31
|
-
"Ref": "
|
|
31
|
+
"Ref": "PassDeployment2a35d33e"
|
|
32
32
|
},
|
|
33
33
|
"StageName": "hookshot",
|
|
34
34
|
"RestApiId": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
]
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
|
-
"
|
|
50
|
+
"PassDeployment2a35d33e": {
|
|
51
51
|
"Type": "AWS::ApiGateway::Deployment",
|
|
52
52
|
"DependsOn": "PassMethod",
|
|
53
53
|
"Properties": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"Type": "AWS::ApiGateway::Stage",
|
|
25
25
|
"Properties": {
|
|
26
26
|
"DeploymentId": {
|
|
27
|
-
"Ref": "
|
|
27
|
+
"Ref": "PassDeployment2a35d33e"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeployment2a35d33e": {
|
|
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": "
|
|
27
|
+
"Ref": "PassDeployment2a35d33e"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeployment2a35d33e": {
|
|
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": "
|
|
27
|
+
"Ref": "PassDeployment2a35d33e"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
|
-
"
|
|
55
|
+
"PassDeployment2a35d33e": {
|
|
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": "
|
|
27
|
+
"Ref": "PassDeployment2a35d33e"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeployment2a35d33e": {
|
|
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": "
|
|
27
|
+
"Ref": "PassDeployment2a35d33e"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeployment2a35d33e": {
|
|
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": "
|
|
27
|
+
"Ref": "PassDeployment2a35d33e"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeployment2a35d33e": {
|
|
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": "
|
|
27
|
+
"Ref": "PassDeployment2a35d33e"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeployment2a35d33e": {
|
|
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": "
|
|
27
|
+
"Ref": "PassDeployment2a35d33e"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeployment2a35d33e": {
|
|
47
47
|
"Type": "AWS::ApiGateway::Deployment",
|
|
48
48
|
"DependsOn": "PassMethod",
|
|
49
49
|
"Properties": {
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
"Mappings": {},
|
|
7
7
|
"Conditions": {
|
|
8
8
|
"Always": {
|
|
9
|
-
"Fn::Equals": [
|
|
9
|
+
"Fn::Equals": [
|
|
10
|
+
"1",
|
|
11
|
+
"1"
|
|
12
|
+
]
|
|
10
13
|
}
|
|
11
14
|
},
|
|
12
15
|
"Resources": {
|
|
@@ -49,7 +52,9 @@
|
|
|
49
52
|
"FunctionName": "my-function",
|
|
50
53
|
"Handler": "index.something",
|
|
51
54
|
"KmsKeyArn": "arn:aws:kms:us-east-1:123456789012:key/fake",
|
|
52
|
-
"Layers": [
|
|
55
|
+
"Layers": [
|
|
56
|
+
"arn:aws:fake:layer/abc"
|
|
57
|
+
],
|
|
53
58
|
"MemorySize": 512,
|
|
54
59
|
"ReservedConcurrentExecutions": 10,
|
|
55
60
|
"Runtime": "nodejs18.x",
|
|
@@ -58,8 +63,12 @@
|
|
|
58
63
|
"Mode": "Active"
|
|
59
64
|
},
|
|
60
65
|
"VpcConfig": {
|
|
61
|
-
"SecurityGroupIds": [
|
|
62
|
-
|
|
66
|
+
"SecurityGroupIds": [
|
|
67
|
+
"sg-12345"
|
|
68
|
+
],
|
|
69
|
+
"SubnetIds": [
|
|
70
|
+
"fake"
|
|
71
|
+
]
|
|
63
72
|
},
|
|
64
73
|
"Tags": [
|
|
65
74
|
{
|
|
@@ -68,7 +77,10 @@
|
|
|
68
77
|
}
|
|
69
78
|
],
|
|
70
79
|
"Role": {
|
|
71
|
-
"Fn::GetAtt": [
|
|
80
|
+
"Fn::GetAtt": [
|
|
81
|
+
"MyLambdaRole",
|
|
82
|
+
"Arn"
|
|
83
|
+
]
|
|
72
84
|
}
|
|
73
85
|
}
|
|
74
86
|
},
|
|
@@ -78,7 +90,9 @@
|
|
|
78
90
|
"Properties": {
|
|
79
91
|
"AlarmName": "my-alarm",
|
|
80
92
|
"AlarmDescription": "some alarm",
|
|
81
|
-
"AlarmActions": [
|
|
93
|
+
"AlarmActions": [
|
|
94
|
+
"devnull@mapbox.com"
|
|
95
|
+
],
|
|
82
96
|
"Period": 120,
|
|
83
97
|
"EvaluationPeriods": 2,
|
|
84
98
|
"DatapointsToAlarm": 1,
|
|
@@ -87,7 +101,9 @@
|
|
|
87
101
|
"ComparisonOperator": "LessThanThreshold",
|
|
88
102
|
"TreatMissingData": "breaching",
|
|
89
103
|
"EvaluateLowSampleCountPercentile": "ignore",
|
|
90
|
-
"OKActions": [
|
|
104
|
+
"OKActions": [
|
|
105
|
+
"devnull@mapbox.com"
|
|
106
|
+
],
|
|
91
107
|
"Namespace": "AWS/Lambda",
|
|
92
108
|
"Dimensions": [
|
|
93
109
|
{
|
|
@@ -118,7 +134,10 @@
|
|
|
118
134
|
"Effect": "Allow",
|
|
119
135
|
"Action": "logs:*",
|
|
120
136
|
"Resource": {
|
|
121
|
-
"Fn::GetAtt": [
|
|
137
|
+
"Fn::GetAtt": [
|
|
138
|
+
"MyLambdaLogs",
|
|
139
|
+
"Arn"
|
|
140
|
+
]
|
|
122
141
|
}
|
|
123
142
|
}
|
|
124
143
|
]
|
|
@@ -161,4 +180,4 @@
|
|
|
161
180
|
}
|
|
162
181
|
},
|
|
163
182
|
"Outputs": {}
|
|
164
|
-
}
|
|
183
|
+
}
|
|
@@ -167,21 +167,21 @@
|
|
|
167
167
|
"Properties": {
|
|
168
168
|
"BatchSize": 10000,
|
|
169
169
|
"MaximumBatchingWindowInSeconds": 300,
|
|
170
|
+
"Enabled": false,
|
|
171
|
+
"EventSourceArn": "arn:aws:kinesis:us-east-1:123456789012:stream/fake",
|
|
172
|
+
"FunctionName": {
|
|
173
|
+
"Ref": "MyLambda"
|
|
174
|
+
},
|
|
175
|
+
"StartingPosition": "TRIM_HORIZON",
|
|
170
176
|
"FilterCriteria": {
|
|
171
177
|
"Filters": [
|
|
172
178
|
{
|
|
173
179
|
"Pattern": "{\"eventName\":[\"INSERT\",\"MODIFY\"]}"
|
|
174
180
|
}
|
|
175
181
|
]
|
|
176
|
-
}
|
|
177
|
-
"Enabled": false,
|
|
178
|
-
"EventSourceArn": "arn:aws:kinesis:us-east-1:123456789012:stream/fake",
|
|
179
|
-
"FunctionName": {
|
|
180
|
-
"Ref": "MyLambda"
|
|
181
|
-
},
|
|
182
|
-
"StartingPosition": "TRIM_HORIZON"
|
|
182
|
+
}
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
},
|
|
186
186
|
"Outputs": {}
|
|
187
|
-
}
|
|
187
|
+
}
|
package/test/index.test.js
CHANGED
|
@@ -11,6 +11,7 @@ test('intrinsic functions', (assert) => {
|
|
|
11
11
|
assert.deepEqual(cloudfriend.base64('secret'), { 'Fn::Base64': 'secret' }, 'base64');
|
|
12
12
|
assert.deepEqual(cloudfriend.cidr('ipBlock', 1, 2), { 'Fn::Cidr': ['ipBlock', 1, 2] }, 'cidr');
|
|
13
13
|
assert.deepEqual(cloudfriend.findInMap('mapping', 'key', 'value'), { 'Fn::FindInMap': ['mapping', 'key', 'value'] }, 'lookup');
|
|
14
|
+
assert.deepEqual(cloudfriend.findInMap('mapping', 'key', 'value', 'hello-world'), { 'Fn::FindInMap': ['mapping', 'key', 'value', { DefaultValue: 'hello-world' }] }, 'lookup with default value');
|
|
14
15
|
assert.deepEqual(
|
|
15
16
|
cloudfriend.forEach('somethings', 'topic', ['abra', 'cadabra'], 'magic', {
|
|
16
17
|
Type: 'AWS::SNS::Topic',
|