@mapbox/cloudfriend 7.3.0-8 → 8.0.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/243d5bfa-9e45-4291-a944-4258a7a28148.json +1 -0
  2. package/.nyc_output/70bddb17-d1d1-4971-b79f-5fece324d8d2.json +1 -0
  3. package/.nyc_output/processinfo/243d5bfa-9e45-4291-a944-4258a7a28148.json +1 -0
  4. package/.nyc_output/processinfo/70bddb17-d1d1-4971-b79f-5fece324d8d2.json +1 -0
  5. package/.nyc_output/processinfo/index.json +1 -1
  6. package/changelog.md +11 -8
  7. package/lib/shortcuts/api.md +3 -3
  8. package/lib/shortcuts/scheduled-lambda.js +8 -8
  9. package/package.json +2 -2
  10. package/test/fixtures/shortcuts/hookshot-github-secret-ref.json +2 -2
  11. package/test/fixtures/shortcuts/hookshot-github-secret-string.json +2 -2
  12. package/test/fixtures/shortcuts/hookshot-github.json +2 -2
  13. package/test/fixtures/shortcuts/hookshot-passthrough-access-log-format.json +2 -2
  14. package/test/fixtures/shortcuts/hookshot-passthrough-alarms.json +2 -2
  15. package/test/fixtures/shortcuts/hookshot-passthrough-enhanced-logging.json +2 -2
  16. package/test/fixtures/shortcuts/hookshot-passthrough-full-blown-logging.json +2 -2
  17. package/test/fixtures/shortcuts/hookshot-passthrough-logging.json +2 -2
  18. package/test/fixtures/shortcuts/hookshot-passthrough.json +2 -2
  19. package/test/fixtures/shortcuts/scheduled-lambda-defaults.json +2 -2
  20. package/test/fixtures/shortcuts/scheduled-lambda-full.json +2 -2
  21. package/.nyc_output/4a01d8fd-0d41-4652-b62f-80a9e0ee2e82.json +0 -1
  22. package/.nyc_output/ffdc1617-095c-45f0-ab0f-449e05e7b3a9.json +0 -1
  23. package/.nyc_output/processinfo/4a01d8fd-0d41-4652-b62f-80a9e0ee2e82.json +0 -1
  24. package/.nyc_output/processinfo/ffdc1617-095c-45f0-ab0f-449e05e7b3a9.json +0 -1
  25. package/test/fixtures/shortcuts/scheduled-lambda-custom-eventbus.json +0 -188
@@ -674,7 +674,7 @@ a Lambda permission.
674
674
  | --- | --- | --- |
675
675
  | options | <code>Object</code> | Extends the options for [`Lambda`](#lambda) with the following additional attributes: |
676
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) |
677
+ | [options.ScheduleRoleArn] | <code>String</code> | If specified, the eventbride scheduler 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) |
678
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). |
679
679
 
680
680
  **Example**
@@ -707,7 +707,7 @@ const role = new cf.shortcuts.ServiceRole({
707
707
  {
708
708
  Effect: 'Allow',
709
709
  Action: 'lambda:InvokeFunction',
710
- Resource: 'arn:aws:lambda:us-east-1:012345678901:function:my-role-*'
710
+ Resource: cf.sub('arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:my-role-*')
711
711
  }
712
712
  ]
713
713
  });
@@ -718,7 +718,7 @@ const lambda = new cf.shortcuts.ScheduledLambda({
718
718
  S3Bucket: 'my-code-bucket',
719
719
  S3Key: 'path/to/code.zip'
720
720
  },
721
- ScheduleRoleArn: cf.ref('MyRole'),
721
+ ScheduleRoleArn: cf.getAtt('MyRole', 'Arn'),
722
722
  ScheduleExpression: 'rate(1 hour)',
723
723
  });
724
724
 
@@ -11,7 +11,7 @@ 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 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._
14
+ * @param {String} [options.ScheduleRoleArn=undefined] If specified, the eventbride scheduler 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
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).
17
17
  *
@@ -43,7 +43,7 @@ const ServiceRole = require('./service-role');
43
43
  * {
44
44
  * Effect: 'Allow',
45
45
  * Action: 'lambda:InvokeFunction',
46
- * Resource: 'arn:aws:lambda:us-east-1:012345678901:function:my-role-*'
46
+ * Resource: cf.sub('arn:aws:lambda:${AWS::Region}:${AWS::AccountId}:function:my-role-*')
47
47
  * }
48
48
  * ]
49
49
  * });
@@ -54,7 +54,7 @@ const ServiceRole = require('./service-role');
54
54
  * S3Bucket: 'my-code-bucket',
55
55
  * S3Key: 'path/to/code.zip'
56
56
  * },
57
- * ScheduleRoleArn: cf.ref('MyRole'),
57
+ * ScheduleRoleArn: cf.getAtt('MyRole', 'Arn'),
58
58
  * ScheduleExpression: 'rate(1 hour)',
59
59
  * });
60
60
  *
@@ -76,7 +76,7 @@ class ScheduledLambda extends Lambda {
76
76
  if (required.some((variable) => !variable))
77
77
  throw new Error('You must provide a ScheduleExpression');
78
78
 
79
- this.Resources[`${this.LogicalName}EventBridgeSchedule`] = {
79
+ this.Resources[`${this.LogicalName}Scheduler`] = {
80
80
  Type: 'AWS::Scheduler::Schedule',
81
81
  Condition: this.Condition,
82
82
  Properties: {
@@ -101,14 +101,14 @@ class ScheduledLambda extends Lambda {
101
101
  };
102
102
 
103
103
  if (ScheduleGroupName) {
104
- this.Resources[`${this.LogicalName}EventBridgeSchedule`].Properties.GroupName = ScheduleGroupName;
104
+ this.Resources[`${this.LogicalName}Scheduler`].Properties.GroupName = ScheduleGroupName;
105
105
  }
106
106
 
107
107
  if (ScheduleRoleArn) {
108
- this.Resources[`${this.LogicalName}EventBridgeSchedule`].Properties.Target.RoleArn = ScheduleRoleArn;
108
+ this.Resources[`${this.LogicalName}Scheduler`].Properties.Target.RoleArn = ScheduleRoleArn;
109
109
  } else {
110
110
  const serviceRole = new ServiceRole({
111
- LogicalName: `${this.LogicalName}EventBridgeScheduleRole`,
111
+ LogicalName: `${this.LogicalName}SchedulerRole`,
112
112
  Service: 'scheduler.amazonaws.com',
113
113
  Condition: this.Condition,
114
114
  Statement: [
@@ -121,7 +121,7 @@ class ScheduledLambda extends Lambda {
121
121
  }
122
122
  ]
123
123
  });
124
- this.Resources[`${this.LogicalName}EventBridgeSchedule`].Properties.Target.RoleArn = { 'Fn::GetAtt': [`${this.LogicalName}EventBridgeScheduleRole`, 'Arn'] };
124
+ this.Resources[`${this.LogicalName}Scheduler`].Properties.Target.RoleArn = { 'Fn::GetAtt': [`${this.LogicalName}EventBridgeScheduleRole`, 'Arn'] };
125
125
  this.Resources = merge(this, serviceRole).Resources;
126
126
  }
127
127
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@mapbox/cloudfriend",
3
- "version": "7.3.0-8",
3
+ "version": "8.0.0-0",
4
4
  "description": "Helper functions for assembling CloudFormation templates in JavaScript",
5
5
  "main": "index.js",
6
6
  "engines": {
7
7
  "node": ">=14"
8
8
  },
9
9
  "scripts": {
10
- "pretest": "eslint index.js test lib bin cloudformation && npm run shortcuts-api-doc",
10
+ "pretest": "npm run lint && npm run shortcuts-api-doc",
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",
@@ -28,7 +28,7 @@
28
28
  "Type": "AWS::ApiGateway::Stage",
29
29
  "Properties": {
30
30
  "DeploymentId": {
31
- "Ref": "PassDeploymentd18750cb"
31
+ "Ref": "PassDeploymentd5673243"
32
32
  },
33
33
  "StageName": "hookshot",
34
34
  "RestApiId": {
@@ -47,7 +47,7 @@
47
47
  ]
48
48
  }
49
49
  },
50
- "PassDeploymentd18750cb": {
50
+ "PassDeploymentd5673243": {
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": "PassDeploymentd18750cb"
27
+ "Ref": "PassDeploymentd5673243"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  }
45
45
  },
46
- "PassDeploymentd18750cb": {
46
+ "PassDeploymentd5673243": {
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": "PassDeploymentd18750cb"
27
+ "Ref": "PassDeploymentd5673243"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  }
45
45
  },
46
- "PassDeploymentd18750cb": {
46
+ "PassDeploymentd5673243": {
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": "PassDeploymentd18750cb"
27
+ "Ref": "PassDeploymentd5673243"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -52,7 +52,7 @@
52
52
  }
53
53
  }
54
54
  },
55
- "PassDeploymentd18750cb": {
55
+ "PassDeploymentd5673243": {
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": "PassDeploymentd18750cb"
27
+ "Ref": "PassDeploymentd5673243"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  }
45
45
  },
46
- "PassDeploymentd18750cb": {
46
+ "PassDeploymentd5673243": {
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": "PassDeploymentd18750cb"
27
+ "Ref": "PassDeploymentd5673243"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  }
45
45
  },
46
- "PassDeploymentd18750cb": {
46
+ "PassDeploymentd5673243": {
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": "PassDeploymentd18750cb"
27
+ "Ref": "PassDeploymentd5673243"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  }
45
45
  },
46
- "PassDeploymentd18750cb": {
46
+ "PassDeploymentd5673243": {
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": "PassDeploymentd18750cb"
27
+ "Ref": "PassDeploymentd5673243"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  }
45
45
  },
46
- "PassDeploymentd18750cb": {
46
+ "PassDeploymentd5673243": {
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": "PassDeploymentd18750cb"
27
+ "Ref": "PassDeploymentd5673243"
28
28
  },
29
29
  "StageName": "hookshot",
30
30
  "RestApiId": {
@@ -43,7 +43,7 @@
43
43
  ]
44
44
  }
45
45
  },
46
- "PassDeploymentd18750cb": {
46
+ "PassDeploymentd5673243": {
47
47
  "Type": "AWS::ApiGateway::Deployment",
48
48
  "DependsOn": "PassMethod",
49
49
  "Properties": {
@@ -128,7 +128,7 @@
128
128
  }
129
129
  }
130
130
  },
131
- "MyLambdaEventBridgeSchedule": {
131
+ "MyLambdaScheduler": {
132
132
  "Type": "AWS::Scheduler::Schedule",
133
133
  "Properties": {
134
134
  "Name": {
@@ -165,7 +165,7 @@
165
165
  }
166
166
  }
167
167
  },
168
- "MyLambdaEventBridgeScheduleRole": {
168
+ "MyLambdaSchedulerRole": {
169
169
  "Type": "AWS::IAM::Role",
170
170
  "Properties": {
171
171
  "AssumeRolePolicyDocument": {
@@ -128,7 +128,7 @@
128
128
  }
129
129
  }
130
130
  },
131
- "MyLambdaEventBridgeSchedule": {
131
+ "MyLambdaScheduler": {
132
132
  "Type": "AWS::Scheduler::Schedule",
133
133
  "Properties": {
134
134
  "Name": {
@@ -166,7 +166,7 @@
166
166
  "GroupName": "my-cool-stack"
167
167
  }
168
168
  },
169
- "MyLambdaEventBridgeScheduleRole": {
169
+ "MyLambdaSchedulerRole": {
170
170
  "Type": "AWS::IAM::Role",
171
171
  "Properties": {
172
172
  "AssumeRolePolicyDocument": {