@mapbox/cloudfriend 7.3.0-5 → 7.3.0-8
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/4a01d8fd-0d41-4652-b62f-80a9e0ee2e82.json +1 -0
- package/.nyc_output/ffdc1617-095c-45f0-ab0f-449e05e7b3a9.json +1 -0
- package/.nyc_output/processinfo/{1fd23852-2043-434f-bb39-a9052f67b4a6.json → 4a01d8fd-0d41-4652-b62f-80a9e0ee2e82.json} +1 -1
- package/.nyc_output/processinfo/{11f7164b-7ffe-482b-97df-1421dd64f11d.json → ffdc1617-095c-45f0-ab0f-449e05e7b3a9.json} +1 -1
- package/.nyc_output/processinfo/index.json +1 -1
- package/changelog.md +15 -0
- package/lib/shortcuts/api.md +36 -5
- package/lib/shortcuts/scheduled-lambda.js +63 -23
- 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/test/fixtures/shortcuts/scheduled-lambda-defaults.json +47 -29
- package/test/fixtures/shortcuts/scheduled-lambda-full.json +48 -29
- package/test/shortcuts.test.js +2 -0
- package/.nyc_output/11f7164b-7ffe-482b-97df-1421dd64f11d.json +0 -1
- package/.nyc_output/1fd23852-2043-434f-bb39-a9052f67b4a6.json +0 -1
package/lib/shortcuts/api.md
CHANGED
|
@@ -670,11 +670,12 @@ a Lambda permission.
|
|
|
670
670
|
|
|
671
671
|
### new ScheduledLambda(options)
|
|
672
672
|
|
|
673
|
-
| Param | Type |
|
|
674
|
-
| --- | --- | --- |
|
|
675
|
-
| options | <code>Object</code> |
|
|
676
|
-
| options.ScheduleExpression | <code>String</code> |
|
|
677
|
-
| [options.
|
|
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 eventbride scheduler will use this role to invoke your lambda . _If this option is specified, do not use the Statement option; add the permissions you need to your Role directly._ See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-scheduler-schedule-target.html#cfn-scheduler-schedule-target-rolearn) |
|
|
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). |
|
|
678
679
|
|
|
679
680
|
**Example**
|
|
680
681
|
```js
|
|
@@ -693,6 +694,36 @@ const lambda = new cf.shortcuts.ScheduledLambda({
|
|
|
693
694
|
|
|
694
695
|
module.exports = cf.merge(myTemplate, lambda);
|
|
695
696
|
```
|
|
697
|
+
**Example**
|
|
698
|
+
```js
|
|
699
|
+
const cf = require('@mapbox/cloudfriend');
|
|
700
|
+
|
|
701
|
+
const myTemplate = { ... };
|
|
702
|
+
|
|
703
|
+
const role = new cf.shortcuts.ServiceRole({
|
|
704
|
+
LogicalName: 'MyRole',
|
|
705
|
+
Service: 'scheduler.amazonaws.com',
|
|
706
|
+
Statement: [
|
|
707
|
+
{
|
|
708
|
+
Effect: 'Allow',
|
|
709
|
+
Action: 'lambda:InvokeFunction',
|
|
710
|
+
Resource: 'arn:aws:lambda:us-east-1:012345678901:function:my-role-*'
|
|
711
|
+
}
|
|
712
|
+
]
|
|
713
|
+
});
|
|
714
|
+
|
|
715
|
+
const lambda = new cf.shortcuts.ScheduledLambda({
|
|
716
|
+
LogicalName: 'MyLambda',
|
|
717
|
+
Code: {
|
|
718
|
+
S3Bucket: 'my-code-bucket',
|
|
719
|
+
S3Key: 'path/to/code.zip'
|
|
720
|
+
},
|
|
721
|
+
ScheduleRoleArn: cf.ref('MyRole'),
|
|
722
|
+
ScheduleExpression: 'rate(1 hour)',
|
|
723
|
+
});
|
|
724
|
+
|
|
725
|
+
module.exports = cf.merge(myTemplate, role, lambda);
|
|
726
|
+
```
|
|
696
727
|
<a name="ServiceRole"></a>
|
|
697
728
|
|
|
698
729
|
## ServiceRole
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const Lambda = require('./lambda');
|
|
4
|
+
const merge = require('../merge');
|
|
5
|
+
const ServiceRole = require('./service-role');
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* A Lambda function that runs on in response to a CloudWatch Event. Includes
|
|
@@ -9,7 +11,9 @@ const Lambda = require('./lambda');
|
|
|
9
11
|
*
|
|
10
12
|
* @param {Object} options - Extends the options for [`Lambda`](#lambda) with the following additional attributes:
|
|
11
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).
|
|
12
|
-
* @param {String} [options.
|
|
14
|
+
* @param {String} [options.ScheduleRoleArn=undefined] If specified, the eventbride scheduler will use this role to invoke your lambda . _If this option is specified, do not use the Statement option; add the permissions you need to your Role directly._
|
|
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] - See [AWS documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-scheduler-schedule.html#cfn-scheduler-schedule-groupname).
|
|
13
17
|
*
|
|
14
18
|
* @example
|
|
15
19
|
* const cf = require('@mapbox/cloudfriend');
|
|
@@ -26,6 +30,35 @@ const Lambda = require('./lambda');
|
|
|
26
30
|
* });
|
|
27
31
|
*
|
|
28
32
|
* module.exports = cf.merge(myTemplate, lambda);
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const cf = require('@mapbox/cloudfriend');
|
|
36
|
+
*
|
|
37
|
+
* const myTemplate = { ... };
|
|
38
|
+
*
|
|
39
|
+
* const role = new cf.shortcuts.ServiceRole({
|
|
40
|
+
* LogicalName: 'MyRole',
|
|
41
|
+
* Service: 'scheduler.amazonaws.com',
|
|
42
|
+
* Statement: [
|
|
43
|
+
* {
|
|
44
|
+
* Effect: 'Allow',
|
|
45
|
+
* Action: 'lambda:InvokeFunction',
|
|
46
|
+
* Resource: 'arn:aws:lambda:us-east-1:012345678901:function:my-role-*'
|
|
47
|
+
* }
|
|
48
|
+
* ]
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* const lambda = new cf.shortcuts.ScheduledLambda({
|
|
52
|
+
* LogicalName: 'MyLambda',
|
|
53
|
+
* Code: {
|
|
54
|
+
* S3Bucket: 'my-code-bucket',
|
|
55
|
+
* S3Key: 'path/to/code.zip'
|
|
56
|
+
* },
|
|
57
|
+
* ScheduleRoleArn: cf.ref('MyRole'),
|
|
58
|
+
* ScheduleExpression: 'rate(1 hour)',
|
|
59
|
+
* });
|
|
60
|
+
*
|
|
61
|
+
* module.exports = cf.merge(myTemplate, role, lambda);
|
|
29
62
|
*/
|
|
30
63
|
class ScheduledLambda extends Lambda {
|
|
31
64
|
constructor(options) {
|
|
@@ -34,6 +67,8 @@ class ScheduledLambda extends Lambda {
|
|
|
34
67
|
|
|
35
68
|
const {
|
|
36
69
|
ScheduleExpression,
|
|
70
|
+
ScheduleRoleArn,
|
|
71
|
+
ScheduleGroupName,
|
|
37
72
|
State = 'ENABLED'
|
|
38
73
|
} = options;
|
|
39
74
|
|
|
@@ -57,33 +92,38 @@ class ScheduledLambda extends Lambda {
|
|
|
57
92
|
FlexibleTimeWindow: {
|
|
58
93
|
Mode: 'OFF'
|
|
59
94
|
},
|
|
60
|
-
Target:
|
|
95
|
+
Target: {
|
|
96
|
+
Arn: {
|
|
97
|
+
'Fn::GetAtt': [this.LogicalName, 'Arn']
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
if (ScheduleGroupName) {
|
|
104
|
+
this.Resources[`${this.LogicalName}EventBridgeSchedule`].Properties.GroupName = ScheduleGroupName;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (ScheduleRoleArn) {
|
|
108
|
+
this.Resources[`${this.LogicalName}EventBridgeSchedule`].Properties.Target.RoleArn = ScheduleRoleArn;
|
|
109
|
+
} else {
|
|
110
|
+
const serviceRole = new ServiceRole({
|
|
111
|
+
LogicalName: `${this.LogicalName}EventBridgeScheduleRole`,
|
|
112
|
+
Service: 'scheduler.amazonaws.com',
|
|
113
|
+
Condition: this.Condition,
|
|
114
|
+
Statement: [
|
|
61
115
|
{
|
|
62
|
-
|
|
63
|
-
|
|
116
|
+
Effect: 'Allow',
|
|
117
|
+
Action: 'lambda:InvokeFunction',
|
|
118
|
+
Resource: {
|
|
64
119
|
'Fn::GetAtt': [this.LogicalName, 'Arn']
|
|
65
120
|
}
|
|
66
121
|
}
|
|
67
122
|
]
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
Type: 'AWS::Lambda::Permission',
|
|
73
|
-
Condition: this.Condition,
|
|
74
|
-
Properties: {
|
|
75
|
-
Action: 'lambda:InvokeFunction',
|
|
76
|
-
FunctionName: {
|
|
77
|
-
'Fn::GetAtt': [this.LogicalName, 'Arn']
|
|
78
|
-
},
|
|
79
|
-
Principal: {
|
|
80
|
-
'Fn::Sub': 'events.${AWS::URLSuffix}'
|
|
81
|
-
},
|
|
82
|
-
SourceArn: {
|
|
83
|
-
'Fn::GetAtt': [`${this.LogicalName}EventBridgeSchedule`, 'Arn']
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
123
|
+
});
|
|
124
|
+
this.Resources[`${this.LogicalName}EventBridgeSchedule`].Properties.Target.RoleArn = { 'Fn::GetAtt': [`${this.LogicalName}EventBridgeScheduleRole`, 'Arn'] };
|
|
125
|
+
this.Resources = merge(this, serviceRole).Resources;
|
|
126
|
+
}
|
|
87
127
|
}
|
|
88
128
|
}
|
|
89
129
|
|
package/package.json
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"Type": "AWS::ApiGateway::Stage",
|
|
29
29
|
"Properties": {
|
|
30
30
|
"DeploymentId": {
|
|
31
|
-
"Ref": "
|
|
31
|
+
"Ref": "PassDeploymentd18750cb"
|
|
32
32
|
},
|
|
33
33
|
"StageName": "hookshot",
|
|
34
34
|
"RestApiId": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
]
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
|
-
"
|
|
50
|
+
"PassDeploymentd18750cb": {
|
|
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": "PassDeploymentd18750cb"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeploymentd18750cb": {
|
|
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": "PassDeploymentd18750cb"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeploymentd18750cb": {
|
|
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": "PassDeploymentd18750cb"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
|
-
"
|
|
55
|
+
"PassDeploymentd18750cb": {
|
|
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": "PassDeploymentd18750cb"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeploymentd18750cb": {
|
|
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": "PassDeploymentd18750cb"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeploymentd18750cb": {
|
|
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": "PassDeploymentd18750cb"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeploymentd18750cb": {
|
|
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": "PassDeploymentd18750cb"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeploymentd18750cb": {
|
|
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": "PassDeploymentd18750cb"
|
|
28
28
|
},
|
|
29
29
|
"StageName": "hookshot",
|
|
30
30
|
"RestApiId": {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
]
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
|
-
"
|
|
46
|
+
"PassDeploymentd18750cb": {
|
|
47
47
|
"Type": "AWS::ApiGateway::Deployment",
|
|
48
48
|
"DependsOn": "PassMethod",
|
|
49
49
|
"Properties": {
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
},
|
|
131
|
-
"
|
|
131
|
+
"MyLambdaEventBridgeSchedule": {
|
|
132
132
|
"Type": "AWS::Scheduler::Schedule",
|
|
133
133
|
"Properties": {
|
|
134
134
|
"Name": {
|
|
@@ -149,40 +149,58 @@
|
|
|
149
149
|
"FlexibleTimeWindow": {
|
|
150
150
|
"Mode": "OFF"
|
|
151
151
|
},
|
|
152
|
-
"Target":
|
|
153
|
-
{
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
152
|
+
"Target": {
|
|
153
|
+
"Arn": {
|
|
154
|
+
"Fn::GetAtt": [
|
|
155
|
+
"MyLambda",
|
|
156
|
+
"Arn"
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
"RoleArn": {
|
|
160
|
+
"Fn::GetAtt": [
|
|
161
|
+
"MyLambdaEventBridgeScheduleRole",
|
|
162
|
+
"Arn"
|
|
163
|
+
]
|
|
163
164
|
}
|
|
164
|
-
|
|
165
|
+
}
|
|
165
166
|
}
|
|
166
167
|
},
|
|
167
|
-
"
|
|
168
|
-
"Type": "AWS::
|
|
168
|
+
"MyLambdaEventBridgeScheduleRole": {
|
|
169
|
+
"Type": "AWS::IAM::Role",
|
|
169
170
|
"Properties": {
|
|
170
|
-
"
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
"AssumeRolePolicyDocument": {
|
|
172
|
+
"Statement": [
|
|
173
|
+
{
|
|
174
|
+
"Effect": "Allow",
|
|
175
|
+
"Action": "sts:AssumeRole",
|
|
176
|
+
"Principal": {
|
|
177
|
+
"Service": {
|
|
178
|
+
"Fn::Sub": "scheduler.${AWS::URLSuffix}"
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
175
182
|
]
|
|
176
183
|
},
|
|
177
|
-
"
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
"Policies": [
|
|
185
|
+
{
|
|
186
|
+
"PolicyName": "main",
|
|
187
|
+
"PolicyDocument": {
|
|
188
|
+
"Version": "2012-10-17",
|
|
189
|
+
"Statement": [
|
|
190
|
+
{
|
|
191
|
+
"Effect": "Allow",
|
|
192
|
+
"Action": "lambda:InvokeFunction",
|
|
193
|
+
"Resource": {
|
|
194
|
+
"Fn::GetAtt": [
|
|
195
|
+
"MyLambda",
|
|
196
|
+
"Arn"
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
]
|
|
186
204
|
}
|
|
187
205
|
}
|
|
188
206
|
},
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
130
|
},
|
|
131
|
-
"
|
|
131
|
+
"MyLambdaEventBridgeSchedule": {
|
|
132
132
|
"Type": "AWS::Scheduler::Schedule",
|
|
133
133
|
"Properties": {
|
|
134
134
|
"Name": {
|
|
@@ -149,40 +149,59 @@
|
|
|
149
149
|
"FlexibleTimeWindow": {
|
|
150
150
|
"Mode": "OFF"
|
|
151
151
|
},
|
|
152
|
-
"Target":
|
|
153
|
-
{
|
|
154
|
-
"
|
|
155
|
-
"
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
152
|
+
"Target": {
|
|
153
|
+
"Arn": {
|
|
154
|
+
"Fn::GetAtt": [
|
|
155
|
+
"MyLambda",
|
|
156
|
+
"Arn"
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
"RoleArn": {
|
|
160
|
+
"Fn::GetAtt": [
|
|
161
|
+
"MyLambdaEventBridgeScheduleRole",
|
|
162
|
+
"Arn"
|
|
163
|
+
]
|
|
163
164
|
}
|
|
164
|
-
|
|
165
|
+
},
|
|
166
|
+
"GroupName": "my-cool-stack"
|
|
165
167
|
}
|
|
166
168
|
},
|
|
167
|
-
"
|
|
168
|
-
"Type": "AWS::
|
|
169
|
+
"MyLambdaEventBridgeScheduleRole": {
|
|
170
|
+
"Type": "AWS::IAM::Role",
|
|
169
171
|
"Properties": {
|
|
170
|
-
"
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
"AssumeRolePolicyDocument": {
|
|
173
|
+
"Statement": [
|
|
174
|
+
{
|
|
175
|
+
"Effect": "Allow",
|
|
176
|
+
"Action": "sts:AssumeRole",
|
|
177
|
+
"Principal": {
|
|
178
|
+
"Service": {
|
|
179
|
+
"Fn::Sub": "scheduler.${AWS::URLSuffix}"
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
175
183
|
]
|
|
176
184
|
},
|
|
177
|
-
"
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
"Policies": [
|
|
186
|
+
{
|
|
187
|
+
"PolicyName": "main",
|
|
188
|
+
"PolicyDocument": {
|
|
189
|
+
"Version": "2012-10-17",
|
|
190
|
+
"Statement": [
|
|
191
|
+
{
|
|
192
|
+
"Effect": "Allow",
|
|
193
|
+
"Action": "lambda:InvokeFunction",
|
|
194
|
+
"Resource": {
|
|
195
|
+
"Fn::GetAtt": [
|
|
196
|
+
"MyLambda",
|
|
197
|
+
"Arn"
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
]
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
]
|
|
186
205
|
}
|
|
187
206
|
}
|
|
188
207
|
},
|
package/test/shortcuts.test.js
CHANGED
|
@@ -334,6 +334,8 @@ test('[shortcuts] scheduled-lambda', (assert) => {
|
|
|
334
334
|
S3Bucket: 'my-code-bucket',
|
|
335
335
|
S3Key: 'path/to/code.zip'
|
|
336
336
|
},
|
|
337
|
+
ScheduledRoleArn: 'arn:aws:iam::012345678901:role/MyCoolRole',
|
|
338
|
+
ScheduleGroupName: 'my-cool-stack',
|
|
337
339
|
ScheduleExpression: 'rate(1 hour)',
|
|
338
340
|
State: 'DISABLED'
|
|
339
341
|
});
|