@mapbox/cloudfriend 8.0.0-1 → 8.1.0-dev
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/.idea/cloudfriend.iml +12 -0
- package/.idea/inspectionProfiles/Project_Default.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/.nyc_output/3eb8bb63-d72c-4c53-9b7a-2c08ffed873e.json +1 -0
- package/.nyc_output/4cebf8b0-d44d-49b5-b0f8-c5d917495961.json +1 -0
- package/.nyc_output/processinfo/3eb8bb63-d72c-4c53-9b7a-2c08ffed873e.json +1 -0
- package/.nyc_output/processinfo/4cebf8b0-d44d-49b5-b0f8-c5d917495961.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -1
- package/changelog.md +4 -0
- package/lib/shortcuts/api.md +11 -7
- package/lib/shortcuts/scheduled-lambda.js +8 -3
- package/lib/shortcuts/stream-lambda.js +7 -1
- package/package.json +1 -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/.nyc_output/25f78265-3e11-410c-87cf-1aaad0405ccf.json +0 -1
- package/.nyc_output/e37d8799-114a-4f3f-ae6d-c76148100682.json +0 -1
- package/.nyc_output/processinfo/25f78265-3e11-410c-87cf-1aaad0405ccf.json +0 -1
- package/.nyc_output/processinfo/e37d8799-114a-4f3f-ae6d-c76148100682.json +0 -1
package/lib/shortcuts/api.md
CHANGED
|
@@ -394,6 +394,7 @@ Log Group, a Role, an Alarm on function errors, and the Lambda Function itself.
|
|
|
394
394
|
| [options.DeadLetterConfig] | <code>Object</code> | | See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-deadletterconfig). |
|
|
395
395
|
| [options.Description] | <code>String</code> | <code>'${logical name} in the ${stack name} stack'</code> | See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-description). |
|
|
396
396
|
| [options.Environment] | <code>Object</code> | | See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-environment). |
|
|
397
|
+
| [options.FilterCriteria] | <code>Object</code> | | See [AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html) |
|
|
397
398
|
| [options.FunctionName] | <code>String</code> | <code>'${stack name}-${logical name}'</code> | See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-functionname). |
|
|
398
399
|
| [options.Handler] | <code>String</code> | <code>'index.handler'</code> | See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-handler). |
|
|
399
400
|
| [options.KmsKeyArn] | <code>String</code> | | See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html#cfn-lambda-function-kmskeyarn). |
|
|
@@ -670,12 +671,13 @@ a Lambda permission.
|
|
|
670
671
|
|
|
671
672
|
### new ScheduledLambda(options)
|
|
672
673
|
|
|
673
|
-
| Param | Type | Description |
|
|
674
|
-
| --- | --- | --- |
|
|
675
|
-
| options | <code>Object</code> | Extends the options for [`Lambda`](#lambda) with the following additional attributes: |
|
|
676
|
-
| options.ScheduleExpression | <code>String</code> | See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-scheduleexpression). |
|
|
677
|
-
| [options.ScheduleRoleArn] | <code>String</code> | If specified, the
|
|
678
|
-
| [options.ScheduleGroupName] | <code>String</code> | See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-groupname). |
|
|
674
|
+
| Param | Type | Default | Description |
|
|
675
|
+
| --- | --- | --- | --- |
|
|
676
|
+
| options | <code>Object</code> | | Extends the options for [`Lambda`](#lambda) with the following additional attributes: |
|
|
677
|
+
| options.ScheduleExpression | <code>String</code> | | See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-scheduleexpression). |
|
|
678
|
+
| [options.ScheduleRoleArn] | <code>String</code> | | If specified, the eventbridge scheduler schedule will use this role to invoke your lambda . If not specified a service role with the correct scoped permissions is created for you. See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-rolearn) |
|
|
679
|
+
| [options.ScheduleGroupName] | <code>String</code> | | If specified, the eventbridge scheduler schedule is associated with this preexisting schedule group. If not specified the schedule is associated with the default schedule group. Note you cannot change a schedule's schedule group once it has been already associated with a schedule group. See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-groupname). |
|
|
680
|
+
| [options.State] | <code>String</code> | <code>'ENABLED'</code> | See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state). |
|
|
679
681
|
|
|
680
682
|
**Example**
|
|
681
683
|
```js
|
|
@@ -683,6 +685,7 @@ const cf = require('@mapbox/cloudfriend');
|
|
|
683
685
|
|
|
684
686
|
const myTemplate = { ... };
|
|
685
687
|
|
|
688
|
+
// A scheduler service role is already created for you internally with the correct permissions
|
|
686
689
|
const lambda = new cf.shortcuts.ScheduledLambda({
|
|
687
690
|
LogicalName: 'MyLambda',
|
|
688
691
|
Code: {
|
|
@@ -700,6 +703,7 @@ const cf = require('@mapbox/cloudfriend');
|
|
|
700
703
|
|
|
701
704
|
const myTemplate = { ... };
|
|
702
705
|
|
|
706
|
+
// If you are creating your own scheduler service role, be sure your permissions are correct!
|
|
703
707
|
const role = new cf.shortcuts.ServiceRole({
|
|
704
708
|
LogicalName: 'MyRole',
|
|
705
709
|
Service: 'scheduler.amazonaws.com',
|
|
@@ -707,7 +711,7 @@ const role = new cf.shortcuts.ServiceRole({
|
|
|
707
711
|
{
|
|
708
712
|
Effect: 'Allow',
|
|
709
713
|
Action: 'lambda:InvokeFunction',
|
|
710
|
-
Resource: cf.sub('arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function
|
|
714
|
+
Resource: cf.sub('arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AWS::StackName}-*')
|
|
711
715
|
}
|
|
712
716
|
]
|
|
713
717
|
});
|
|
@@ -11,15 +11,19 @@ const ServiceRole = require('./service-role');
|
|
|
11
11
|
*
|
|
12
12
|
* @param {Object} options - Extends the options for [`Lambda`](#lambda) with the following additional attributes:
|
|
13
13
|
* @param {String} options.ScheduleExpression - See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-scheduleexpression).
|
|
14
|
-
* @param {String} [options.ScheduleRoleArn=undefined] If specified, the
|
|
14
|
+
* @param {String} [options.ScheduleRoleArn=undefined] If specified, the eventbridge scheduler schedule will use this role to invoke your lambda . If not specified a service role with the correct scoped permissions is created for you.
|
|
15
15
|
* See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-rolearn)
|
|
16
|
-
* @param {String} [options.ScheduleGroupName=undefined] -
|
|
16
|
+
* @param {String} [options.ScheduleGroupName=undefined] - If specified, the eventbridge scheduler schedule is associated with this preexisting schedule group.
|
|
17
|
+
* If not specified the schedule is associated with the default schedule group. Note you cannot change a schedule's schedule group once it has been already associated with a schedule group.
|
|
18
|
+
* See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-groupname).
|
|
19
|
+
* @param {String} [options.State='ENABLED'] - See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-events-rule.html#cfn-events-rule-state).
|
|
17
20
|
*
|
|
18
21
|
* @example
|
|
19
22
|
* const cf = require('@mapbox/cloudfriend');
|
|
20
23
|
*
|
|
21
24
|
* const myTemplate = { ... };
|
|
22
25
|
*
|
|
26
|
+
* // A scheduler service role is already created for you internally with the correct permissions
|
|
23
27
|
* const lambda = new cf.shortcuts.ScheduledLambda({
|
|
24
28
|
* LogicalName: 'MyLambda',
|
|
25
29
|
* Code: {
|
|
@@ -36,6 +40,7 @@ const ServiceRole = require('./service-role');
|
|
|
36
40
|
*
|
|
37
41
|
* const myTemplate = { ... };
|
|
38
42
|
*
|
|
43
|
+
* // If you are creating your own scheduler service role, be sure your permissions are correct!
|
|
39
44
|
* const role = new cf.shortcuts.ServiceRole({
|
|
40
45
|
* LogicalName: 'MyRole',
|
|
41
46
|
* Service: 'scheduler.amazonaws.com',
|
|
@@ -43,7 +48,7 @@ const ServiceRole = require('./service-role');
|
|
|
43
48
|
* {
|
|
44
49
|
* Effect: 'Allow',
|
|
45
50
|
* Action: 'lambda:InvokeFunction',
|
|
46
|
-
* Resource: cf.sub('arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function
|
|
51
|
+
* Resource: cf.sub('arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:${AWS::StackName}-*')
|
|
47
52
|
* }
|
|
48
53
|
* ]
|
|
49
54
|
* });
|
|
@@ -13,6 +13,7 @@ const Lambda = require('./lambda');
|
|
|
13
13
|
* @param {Number} [options.MaximumBatchingWindowInSeconds=undefined] - See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-maximumbatchingwindowinseconds).
|
|
14
14
|
* @param {Boolean} [options.Enabled=true] - See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-enabled).
|
|
15
15
|
* @param {String} [options.StartingPosition='LATEST'] - See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html#cfn-lambda-eventsourcemapping-startingposition).
|
|
16
|
+
* @param {Object} [options.FilterCriteria] - See [AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html).
|
|
16
17
|
*
|
|
17
18
|
* @example
|
|
18
19
|
* const cf = require('@mapbox/cloudfriend');
|
|
@@ -40,7 +41,8 @@ class StreamLambda extends Lambda {
|
|
|
40
41
|
BatchSize = 1,
|
|
41
42
|
MaximumBatchingWindowInSeconds,
|
|
42
43
|
Enabled = true,
|
|
43
|
-
StartingPosition = 'LATEST'
|
|
44
|
+
StartingPosition = 'LATEST',
|
|
45
|
+
FilterCriteria = undefined
|
|
44
46
|
} = options;
|
|
45
47
|
|
|
46
48
|
const required = [EventSourceArn];
|
|
@@ -60,6 +62,10 @@ class StreamLambda extends Lambda {
|
|
|
60
62
|
}
|
|
61
63
|
};
|
|
62
64
|
|
|
65
|
+
if (FilterCriteria) {
|
|
66
|
+
this.Resources[`${this.LogicalName}EventSource`].Properties.FilterCriteria = FilterCriteria;
|
|
67
|
+
}
|
|
68
|
+
|
|
63
69
|
const generatedRoleRef = this.Resources[`${this.LogicalName}Role`];
|
|
64
70
|
const streamStatement = {
|
|
65
71
|
Effect: 'Allow',
|
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"Type": "AWS::ApiGateway::Stage",
|
|
29
29
|
"Properties": {
|
|
30
30
|
"DeploymentId": {
|
|
31
|
-
"Ref": "
|
|
31
|
+
"Ref": "PassDeploymentac7cb6b9"
|
|
32
32
|
},
|
|
33
33
|
"StageName": "hookshot",
|
|
34
34
|
"RestApiId": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
]
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
|
-
"
|
|
50
|
+
"PassDeploymentac7cb6b9": {
|
|
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": "PassDeploymentac7cb6b9"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeploymentac7cb6b9": {
|
|
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": "PassDeploymentac7cb6b9"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeploymentac7cb6b9": {
|
|
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": "PassDeploymentac7cb6b9"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
|
-
"
|
|
55
|
+
"PassDeploymentac7cb6b9": {
|
|
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": "PassDeploymentac7cb6b9"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeploymentac7cb6b9": {
|
|
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": "PassDeploymentac7cb6b9"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeploymentac7cb6b9": {
|
|
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": "PassDeploymentac7cb6b9"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeploymentac7cb6b9": {
|
|
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": "PassDeploymentac7cb6b9"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeploymentac7cb6b9": {
|
|
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": "PassDeploymentac7cb6b9"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeploymentac7cb6b9": {
|
|
47
47
|
"Type": "AWS::ApiGateway::Deployment",
|
|
48
48
|
"DependsOn": "PassMethod",
|
|
49
49
|
"Properties": {
|