@mapbox/cloudfriend 7.1.0 → 7.2.0-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.
Files changed (25) hide show
  1. package/.nyc_output/c85e6e5a-f842-4bd6-ad20-6f04ab728aac.json +1 -0
  2. package/.nyc_output/f52017b2-43bd-4f2e-a740-f75421866b4a.json +1 -0
  3. package/.nyc_output/processinfo/c85e6e5a-f842-4bd6-ad20-6f04ab728aac.json +1 -0
  4. package/.nyc_output/processinfo/f52017b2-43bd-4f2e-a740-f75421866b4a.json +1 -0
  5. package/.nyc_output/processinfo/index.json +1 -1
  6. package/lib/shortcuts/api.md +60 -0
  7. package/lib/shortcuts/event-lambda.js +37 -0
  8. package/lib/shortcuts/scheduled-lambda.js +32 -0
  9. package/package.json +3 -1
  10. package/test/fixtures/shortcuts/event-lambda-custom-eventbus.json +200 -0
  11. package/test/fixtures/shortcuts/hookshot-github-secret-ref.json +2 -2
  12. package/test/fixtures/shortcuts/hookshot-github-secret-string.json +2 -2
  13. package/test/fixtures/shortcuts/hookshot-github.json +2 -2
  14. package/test/fixtures/shortcuts/hookshot-passthrough-access-log-format.json +2 -2
  15. package/test/fixtures/shortcuts/hookshot-passthrough-alarms.json +2 -2
  16. package/test/fixtures/shortcuts/hookshot-passthrough-enhanced-logging.json +2 -2
  17. package/test/fixtures/shortcuts/hookshot-passthrough-full-blown-logging.json +2 -2
  18. package/test/fixtures/shortcuts/hookshot-passthrough-logging.json +2 -2
  19. package/test/fixtures/shortcuts/hookshot-passthrough.json +2 -2
  20. package/test/fixtures/shortcuts/scheduled-lambda-custom-eventbus.json +188 -0
  21. package/test/shortcuts.test.js +42 -0
  22. package/.nyc_output/222315fd-a3a2-4bed-8a08-850c3a05d3af.json +0 -1
  23. package/.nyc_output/73f67d80-cf5b-4c49-aa3f-4783ae74471b.json +0 -1
  24. package/.nyc_output/processinfo/222315fd-a3a2-4bed-8a08-850c3a05d3af.json +0 -1
  25. package/.nyc_output/processinfo/73f67d80-cf5b-4c49-aa3f-4783ae74471b.json +0 -1
@@ -0,0 +1,188 @@
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
+ "Code": {
29
+ "S3Bucket": "my-code-bucket",
30
+ "S3Key": "path/to/code.zip"
31
+ },
32
+ "Description": {
33
+ "Fn::Sub": "MyLambda in the ${AWS::StackName} stack"
34
+ },
35
+ "FunctionName": {
36
+ "Fn::Sub": "${AWS::StackName}-MyLambda"
37
+ },
38
+ "Handler": "index.handler",
39
+ "MemorySize": 128,
40
+ "Runtime": "nodejs18.x",
41
+ "Timeout": 300,
42
+ "Role": {
43
+ "Fn::GetAtt": [
44
+ "MyLambdaRole",
45
+ "Arn"
46
+ ]
47
+ }
48
+ }
49
+ },
50
+ "MyLambdaErrorAlarm": {
51
+ "Type": "AWS::CloudWatch::Alarm",
52
+ "Properties": {
53
+ "AlarmName": {
54
+ "Fn::Sub": "${AWS::StackName}-MyLambda-Errors-${AWS::Region}"
55
+ },
56
+ "AlarmDescription": {
57
+ "Fn::Sub": [
58
+ "Error alarm for ${name} lambda function in ${AWS::StackName} stack",
59
+ {
60
+ "name": {
61
+ "Fn::Sub": "${AWS::StackName}-MyLambda"
62
+ }
63
+ }
64
+ ]
65
+ },
66
+ "AlarmActions": [],
67
+ "Period": 60,
68
+ "EvaluationPeriods": 5,
69
+ "DatapointsToAlarm": 1,
70
+ "Statistic": "Sum",
71
+ "Threshold": 0,
72
+ "ComparisonOperator": "GreaterThanThreshold",
73
+ "TreatMissingData": "notBreaching",
74
+ "Namespace": "AWS/Lambda",
75
+ "Dimensions": [
76
+ {
77
+ "Name": "FunctionName",
78
+ "Value": {
79
+ "Ref": "MyLambda"
80
+ }
81
+ }
82
+ ],
83
+ "MetricName": "Errors"
84
+ }
85
+ },
86
+ "MyLambdaLogPolicy": {
87
+ "Type": "AWS::IAM::Policy",
88
+ "DependsOn": "MyLambdaRole",
89
+ "Properties": {
90
+ "PolicyName": "lambda-log-access",
91
+ "Roles": [
92
+ {
93
+ "Ref": "MyLambdaRole"
94
+ }
95
+ ],
96
+ "PolicyDocument": {
97
+ "Version": "2012-10-17",
98
+ "Statement": [
99
+ {
100
+ "Effect": "Allow",
101
+ "Action": "logs:*",
102
+ "Resource": {
103
+ "Fn::GetAtt": [
104
+ "MyLambdaLogs",
105
+ "Arn"
106
+ ]
107
+ }
108
+ }
109
+ ]
110
+ }
111
+ }
112
+ },
113
+ "MyLambdaRole": {
114
+ "Type": "AWS::IAM::Role",
115
+ "Properties": {
116
+ "AssumeRolePolicyDocument": {
117
+ "Statement": [
118
+ {
119
+ "Effect": "Allow",
120
+ "Action": "sts:AssumeRole",
121
+ "Principal": {
122
+ "Service": {
123
+ "Fn::Sub": "lambda.amazonaws.com"
124
+ }
125
+ }
126
+ }
127
+ ]
128
+ }
129
+ }
130
+ },
131
+ "MyLambdaSchedule": {
132
+ "Type": "AWS::Events::Rule",
133
+ "Properties": {
134
+ "Name": {
135
+ "Fn::Sub": "${AWS::StackName}-MyLambda"
136
+ },
137
+ "Description": {
138
+ "Fn::Sub": [
139
+ "Schedule for ${function} in ${AWS::StackName} stack",
140
+ {
141
+ "function": {
142
+ "Fn::Sub": "${AWS::StackName}-MyLambda"
143
+ }
144
+ }
145
+ ]
146
+ },
147
+ "State": "DISABLED",
148
+ "ScheduleExpression": "rate(1 hour)",
149
+ "Targets": [
150
+ {
151
+ "Id": {
152
+ "Fn::Sub": "${AWS::StackName}-MyLambda"
153
+ },
154
+ "Arn": {
155
+ "Fn::GetAtt": [
156
+ "MyLambda",
157
+ "Arn"
158
+ ]
159
+ }
160
+ }
161
+ ],
162
+ "EventBusName": "my-cool-eventbus"
163
+ }
164
+ },
165
+ "MyLambdaPermission": {
166
+ "Type": "AWS::Lambda::Permission",
167
+ "Properties": {
168
+ "Action": "lambda:InvokeFunction",
169
+ "FunctionName": {
170
+ "Fn::GetAtt": [
171
+ "MyLambda",
172
+ "Arn"
173
+ ]
174
+ },
175
+ "Principal": {
176
+ "Fn::Sub": "events.${AWS::URLSuffix}"
177
+ },
178
+ "SourceArn": {
179
+ "Fn::GetAtt": [
180
+ "MyLambdaSchedule",
181
+ "Arn"
182
+ ]
183
+ }
184
+ }
185
+ }
186
+ },
187
+ "Outputs": {}
188
+ }
@@ -346,6 +346,23 @@ test('[shortcuts] scheduled-lambda', (assert) => {
346
346
  'expected resources generated without defaults'
347
347
  );
348
348
 
349
+ lambda = new cf.shortcuts.ScheduledLambda({
350
+ LogicalName: 'MyLambda',
351
+ Code: {
352
+ S3Bucket: 'my-code-bucket',
353
+ S3Key: 'path/to/code.zip'
354
+ },
355
+ EventBusName: 'my-cool-eventbus',
356
+ ScheduleExpression: 'rate(1 hour)',
357
+ State: 'DISABLED'
358
+ });
359
+ template = cf.merge(lambda);
360
+ if (update) fixtures.update('scheduled-lambda-custom-eventbus', template);
361
+ assert.deepEqual(
362
+ noUndefined(template),
363
+ fixtures.get('scheduled-lambda-custom-eventbus'),
364
+ 'expected resources generated without defaults and a custom eventbus'
365
+ );
349
366
  assert.end();
350
367
  });
351
368
 
@@ -421,6 +438,31 @@ test('[shortcuts] event-lambda', (assert) => {
421
438
  'expected resources generated without defaults'
422
439
  );
423
440
 
441
+ lambda = new cf.shortcuts.EventLambda({
442
+ LogicalName: 'MyLambda',
443
+ Code: {
444
+ S3Bucket: 'my-code-bucket',
445
+ S3Key: 'path/to/code.zip'
446
+ },
447
+ EventBusName: 'my-cool-eventbus',
448
+ EventPattern: {
449
+ source: ['aws.ec2'],
450
+ 'detail-type': ['EC2 Instance State-change Notification'],
451
+ detail: {
452
+ state: ['running']
453
+ }
454
+ },
455
+ State: 'DISABLED'
456
+ });
457
+
458
+ template = cf.merge(lambda);
459
+ if (update) fixtures.update('event-lambda-custom-eventbus', template);
460
+ assert.deepEqual(
461
+ noUndefined(template),
462
+ fixtures.get('event-lambda-custom-eventbus'),
463
+ 'expected resources generated without defaults and a custom eventbus'
464
+ );
465
+
424
466
  assert.end();
425
467
  });
426
468