@mapbox/cloudfriend 9.2.0 → 9.2.1
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/changelog.md +4 -0
- package/coverage/clover.xml +598 -0
- package/coverage/coverage-final.json +32 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/cloudfriend/bin/build-template.js.html +130 -0
- package/coverage/lcov-report/cloudfriend/bin/index.html +131 -0
- package/coverage/lcov-report/cloudfriend/bin/validate-template.js.html +142 -0
- package/coverage/lcov-report/cloudfriend/index.html +116 -0
- package/coverage/lcov-report/cloudfriend/index.js.html +307 -0
- package/coverage/lcov-report/cloudfriend/lib/build.js.html +217 -0
- package/coverage/lcov-report/cloudfriend/lib/conditions.js.html +430 -0
- package/coverage/lcov-report/cloudfriend/lib/index.html +206 -0
- package/coverage/lcov-report/cloudfriend/lib/intrinsic.js.html +979 -0
- package/coverage/lcov-report/cloudfriend/lib/merge.js.html +478 -0
- package/coverage/lcov-report/cloudfriend/lib/pseudo.js.html +370 -0
- package/coverage/lcov-report/cloudfriend/lib/rules.js.html +349 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/cross-account-role.js.html +244 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/event-lambda.js.html +367 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-database.js.html +286 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-json-table.js.html +235 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-orc-table.js.html +226 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-parquet-table.js.html +268 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-presto-view.js.html +358 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-spark-view.js.html +241 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/glue-table.js.html +481 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/hookshot.js.html +1504 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/index.html +416 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/index.js.html +154 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/kinesis-firehose-base.js.html +418 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/lambda.js.html +832 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/log-subscription-lambda.js.html +310 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/queue-lambda.js.html +364 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/queue.js.html +619 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/role.js.html +382 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/s3-kinesis-firehose.js.html +568 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/scheduled-lambda.js.html +490 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/service-role.js.html +307 -0
- package/coverage/lcov-report/cloudfriend/lib/shortcuts/stream-lambda.js.html +493 -0
- package/coverage/lcov-report/cloudfriend/lib/validate.js.html +154 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +161 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +210 -0
- package/coverage/lcov.info +1240 -0
- package/jest.config.js +14 -0
- package/package.json +15 -13
- package/readme.md +1 -1
- package/test/bin.test.js +18 -14
- package/test/fixtures/shortcuts/cross-account-role-defaults.json +1 -1
- package/test/fixtures/shortcuts/cross-account-role-no-defaults.json +1 -1
- package/test/fixtures/shortcuts/event-lambda-defaults.json +1 -1
- package/test/fixtures/shortcuts/event-lambda-full.json +1 -1
- package/test/fixtures/shortcuts/firehose-defaults.json +1 -1
- package/test/fixtures/shortcuts/firehose-with-stream.json +1 -1
- package/test/fixtures/shortcuts/glue-database-defaults.json +1 -1
- package/test/fixtures/shortcuts/glue-database-no-defaults.json +1 -1
- package/test/fixtures/shortcuts/glue-json-table-defaults.json +1 -1
- package/test/fixtures/shortcuts/glue-json-table-no-defaults.json +1 -1
- package/test/fixtures/shortcuts/glue-orc-table-defaults.json +1 -1
- package/test/fixtures/shortcuts/glue-orc-table-no-defaults.json +1 -1
- package/test/fixtures/shortcuts/glue-parquet-table-defaults.json +1 -1
- package/test/fixtures/shortcuts/glue-parquet-table-no-defaults.json +1 -1
- package/test/fixtures/shortcuts/glue-table-defaults.json +1 -1
- package/test/fixtures/shortcuts/glue-table-no-defaults.json +1 -1
- package/test/fixtures/shortcuts/glue-view-defaults.json +1 -1
- package/test/fixtures/shortcuts/glue-view-no-defaults.json +1 -1
- package/test/fixtures/shortcuts/hookshot-github-secret-ref.json +1 -1
- package/test/fixtures/shortcuts/hookshot-github-secret-string.json +1 -1
- package/test/fixtures/shortcuts/hookshot-github.json +1 -1
- package/test/fixtures/shortcuts/hookshot-passthrough-access-log-format.json +1 -1
- package/test/fixtures/shortcuts/hookshot-passthrough-alarms.json +1 -1
- package/test/fixtures/shortcuts/hookshot-passthrough-enhanced-logging.json +1 -1
- package/test/fixtures/shortcuts/hookshot-passthrough-full-blown-logging.json +1 -1
- package/test/fixtures/shortcuts/hookshot-passthrough-logging.json +1 -1
- package/test/fixtures/shortcuts/hookshot-passthrough.json +1 -1
- package/test/fixtures/shortcuts/lambda-defaults.json +1 -1
- package/test/fixtures/shortcuts/lambda-docker.json +1 -1
- package/test/fixtures/shortcuts/lambda-full.json +1 -1
- package/test/fixtures/shortcuts/lambda-provided-role.json +1 -1
- package/test/fixtures/shortcuts/lambda-zipfile.json +1 -1
- package/test/fixtures/shortcuts/log-subscription-lambda-defaults.json +1 -1
- package/test/fixtures/shortcuts/log-subscription-lambda-no-defaults.json +1 -1
- package/test/fixtures/shortcuts/queue-defaults.json +1 -1
- package/test/fixtures/shortcuts/queue-external-topic-ref.json +1 -1
- package/test/fixtures/shortcuts/queue-external-topic.json +1 -1
- package/test/fixtures/shortcuts/queue-fifo-queuename.json +1 -1
- package/test/fixtures/shortcuts/queue-fifo.json +1 -1
- package/test/fixtures/shortcuts/queue-full.json +1 -1
- package/test/fixtures/shortcuts/queue-lambda-zero.json +1 -1
- package/test/fixtures/shortcuts/queue-lambda.json +1 -1
- package/test/fixtures/shortcuts/role-defaults.json +1 -1
- package/test/fixtures/shortcuts/role-no-defaults.json +1 -1
- package/test/fixtures/shortcuts/scheduled-lambda-defaults.json +1 -1
- package/test/fixtures/shortcuts/scheduled-lambda-full.json +1 -1
- package/test/fixtures/shortcuts/service-role-defaults.json +1 -1
- package/test/fixtures/shortcuts/service-role-no-defaults.json +1 -1
- package/test/fixtures/shortcuts/service-role-no-url-suffix.json +1 -1
- package/test/fixtures/shortcuts/service-role-url-suffix-with-replacement.json +1 -1
- package/test/fixtures/shortcuts/service-role-url-suffix.json +1 -1
- package/test/fixtures/shortcuts/stream-lambda-defaults.json +1 -1
- package/test/fixtures/shortcuts/stream-lambda-no-defaults.json +1 -1
- package/test/index.test.js +383 -235
- package/test/shortcuts.test.js +1224 -1475
- package/.nyc_output/2b544c0b-2830-4ad0-97cd-8e661710b0bb.json +0 -1
- package/.nyc_output/65e58b48-bf1c-412d-8dd4-d7b564b12d76.json +0 -1
- package/.nyc_output/processinfo/2b544c0b-2830-4ad0-97cd-8e661710b0bb.json +0 -1
- package/.nyc_output/processinfo/65e58b48-bf1c-412d-8dd4-d7b564b12d76.json +0 -1
- package/.nyc_output/processinfo/index.json +0 -1
package/test/shortcuts.test.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
const cp = require('child_process');
|
|
4
4
|
const path = require('path');
|
|
5
5
|
const fs = require('fs');
|
|
6
|
-
const test = require('tape');
|
|
7
6
|
const cf = require('..');
|
|
8
7
|
const fixtures = require('./fixtures/shortcuts');
|
|
9
8
|
const util = require('util');
|
|
@@ -13,7 +12,7 @@ const update = !!process.env.UPDATE;
|
|
|
13
12
|
|
|
14
13
|
const noUndefined = (template) => JSON.parse(JSON.stringify(template));
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
describe('[shortcuts] fixture validation', () => {
|
|
17
16
|
// Runs cfn-lint, ignoring "warnings". Install via pip or Homebrew to run these
|
|
18
17
|
// tests locally.
|
|
19
18
|
const cfnLint = (filepath) => new Promise((resolve, reject) => {
|
|
@@ -27,36 +26,25 @@ test('[shortcuts] fixture validation', async (assert) => {
|
|
|
27
26
|
.readdirSync(path.join(__dirname, 'fixtures', 'shortcuts'))
|
|
28
27
|
.filter((filename) => path.extname(filename) === '.json');
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
const filename = toValidate.shift();
|
|
29
|
+
test.each(toValidate)('%s fixture passes validation', async (filename) => {
|
|
32
30
|
await Promise.all([
|
|
33
|
-
cfnLint(path.join(__dirname, 'fixtures', 'shortcuts', filename))
|
|
34
|
-
.then(() => assert.pass(`${filename} fixture passed validation`))
|
|
35
|
-
.catch((err) => {
|
|
36
|
-
assert.fail(`${filename} fixture fails validation`);
|
|
37
|
-
console.log(err.message);
|
|
38
|
-
}),
|
|
31
|
+
cfnLint(path.join(__dirname, 'fixtures', 'shortcuts', filename)),
|
|
39
32
|
sleep(1000)
|
|
40
33
|
]);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
assert.end();
|
|
34
|
+
});
|
|
44
35
|
});
|
|
45
36
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
() => new cf.shortcuts.Lambda()
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
/You must provide a LogicalName, and Code/,
|
|
55
|
-
'throws without required parameters'
|
|
56
|
-
);
|
|
37
|
+
describe('[shortcuts] lambda', () => {
|
|
38
|
+
test('throws without options', () => {
|
|
39
|
+
expect(() => new cf.shortcuts.Lambda()).toThrow('Options required');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('throws without required parameters', () => {
|
|
43
|
+
expect(() => new cf.shortcuts.Lambda({})).toThrow(/You must provide a LogicalName, and Code/);
|
|
44
|
+
});
|
|
57
45
|
|
|
58
|
-
|
|
59
|
-
() => new cf.shortcuts.Lambda({
|
|
46
|
+
test('throws for RoleArn and Statements both provided', () => {
|
|
47
|
+
expect(() => new cf.shortcuts.Lambda({
|
|
60
48
|
LogicalName: 'MyLambda',
|
|
61
49
|
Code: {
|
|
62
50
|
S3Bucket: 'my-code-bucket',
|
|
@@ -68,469 +56,400 @@ test('[shortcuts] lambda', (assert) => {
|
|
|
68
56
|
Action: 's3:GetObject',
|
|
69
57
|
Resource: 'arn:aws:s3:::my-bucket/*'
|
|
70
58
|
}]
|
|
71
|
-
})
|
|
72
|
-
/You cannot specify both Statements and a RoleArn/,
|
|
73
|
-
'throws for RoleArn and Statements both provided'
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
let lambda = new cf.shortcuts.Lambda({
|
|
77
|
-
LogicalName: 'MyLambda',
|
|
78
|
-
Code: {
|
|
79
|
-
S3Bucket: 'my-code-bucket',
|
|
80
|
-
S3Key: 'path/to/code.zip'
|
|
81
|
-
}
|
|
59
|
+
})).toThrow(/You cannot specify both Statements and a RoleArn/);
|
|
82
60
|
});
|
|
83
61
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
62
|
+
test('expected resources generated using all default values', () => {
|
|
63
|
+
const lambda = new cf.shortcuts.Lambda({
|
|
64
|
+
LogicalName: 'MyLambda',
|
|
65
|
+
Code: {
|
|
66
|
+
S3Bucket: 'my-code-bucket',
|
|
67
|
+
S3Key: 'path/to/code.zip'
|
|
68
|
+
}
|
|
69
|
+
});
|
|
91
70
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
LogPolicyDeletionPolicy: 'Retain'
|
|
71
|
+
const template = cf.merge(lambda);
|
|
72
|
+
if (update) fixtures.update('lambda-defaults', template);
|
|
73
|
+
expect(noUndefined(template)).toEqual(fixtures.get('lambda-defaults'));
|
|
96
74
|
});
|
|
97
|
-
const templateWithRetain = cf.merge(lambdaWithRetain);
|
|
98
|
-
assert.equal(
|
|
99
|
-
templateWithRetain.Resources.MyLambdaLogPolicy.DeletionPolicy,
|
|
100
|
-
'Retain',
|
|
101
|
-
'LogPolicyDeletionPolicy=Retain sets DeletionPolicy on IAM Policy resource'
|
|
102
|
-
);
|
|
103
75
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
76
|
+
test('LogPolicyDeletionPolicy=Retain sets DeletionPolicy on IAM Policy resource', () => {
|
|
77
|
+
const lambdaWithRetain = new cf.shortcuts.Lambda({
|
|
78
|
+
LogicalName: 'MyLambda',
|
|
79
|
+
Code: { S3Bucket: 'my-code-bucket', S3Key: 'path/to/code.zip' },
|
|
80
|
+
LogPolicyDeletionPolicy: 'Retain'
|
|
81
|
+
});
|
|
82
|
+
const templateWithRetain = cf.merge(lambdaWithRetain);
|
|
83
|
+
expect(templateWithRetain.Resources.MyLambdaLogPolicy.DeletionPolicy).toBe('Retain');
|
|
109
84
|
});
|
|
110
85
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
86
|
+
test('expected resources generated using all default values and a docker image', () => {
|
|
87
|
+
const lambda = new cf.shortcuts.Lambda({
|
|
88
|
+
LogicalName: 'MyLambda',
|
|
89
|
+
Code: {
|
|
90
|
+
ImageUri: 'MyImage'
|
|
91
|
+
}
|
|
92
|
+
});
|
|
118
93
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
ZipFile: 'fake code'
|
|
123
|
-
}
|
|
94
|
+
const template = cf.merge(lambda);
|
|
95
|
+
if (update) fixtures.update('lambda-docker', template);
|
|
96
|
+
expect(noUndefined(template)).toEqual(fixtures.get('lambda-docker'));
|
|
124
97
|
});
|
|
125
98
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
99
|
+
test('expected resources generated using all default values and inline code', () => {
|
|
100
|
+
const lambda = new cf.shortcuts.Lambda({
|
|
101
|
+
LogicalName: 'MyLambda',
|
|
102
|
+
Code: {
|
|
103
|
+
ZipFile: 'fake code'
|
|
104
|
+
}
|
|
105
|
+
});
|
|
133
106
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
107
|
+
const template = cf.merge(lambda);
|
|
108
|
+
if (update) fixtures.update('lambda-zipfile', template);
|
|
109
|
+
expect(noUndefined(template)).toEqual(fixtures.get('lambda-zipfile'));
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('expected resources generated if RoleArn provided', () => {
|
|
113
|
+
const lambda = new cf.shortcuts.Lambda({
|
|
114
|
+
LogicalName: 'MyLambda',
|
|
115
|
+
Code: {
|
|
116
|
+
S3Bucket: 'my-code-bucket',
|
|
117
|
+
S3Key: 'path/to/code.zip'
|
|
118
|
+
},
|
|
119
|
+
RoleArn: cf.getAtt('CustomLambdaRole', 'Arn')
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const template = cf.merge(lambda, {
|
|
123
|
+
Resources: {
|
|
124
|
+
'CustomLambdaRole': {
|
|
125
|
+
Type: 'AWS::IAM::Role',
|
|
126
|
+
Properties: {
|
|
127
|
+
AssumeRolePolicyDocument: {}
|
|
128
|
+
}
|
|
149
129
|
}
|
|
150
130
|
}
|
|
151
|
-
}
|
|
131
|
+
});
|
|
132
|
+
if (update) fixtures.update('lambda-provided-role', template);
|
|
133
|
+
expect(noUndefined(template)).toEqual(fixtures.get('lambda-provided-role'));
|
|
152
134
|
});
|
|
153
|
-
if (update) fixtures.update('lambda-provided-role', template);
|
|
154
|
-
assert.deepEqual(
|
|
155
|
-
noUndefined(template),
|
|
156
|
-
fixtures.get('lambda-provided-role'),
|
|
157
|
-
'expected resources generated if RoleArn provided'
|
|
158
|
-
);
|
|
159
135
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
template = cf.merge(
|
|
210
|
-
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
211
|
-
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
212
|
-
lambda
|
|
213
|
-
);
|
|
214
|
-
if (update) fixtures.update('lambda-full', template);
|
|
215
|
-
assert.deepEqual(
|
|
216
|
-
noUndefined(template),
|
|
217
|
-
fixtures.get('lambda-full'),
|
|
218
|
-
'expected resources generated using no default values'
|
|
219
|
-
);
|
|
136
|
+
test('expected resources generated using no default values', () => {
|
|
137
|
+
const lambda = new cf.shortcuts.Lambda({
|
|
138
|
+
LogicalName: 'MyLambda',
|
|
139
|
+
Code: {
|
|
140
|
+
S3Bucket: 'my-code-bucket',
|
|
141
|
+
S3Key: 'path/to/code.zip'
|
|
142
|
+
},
|
|
143
|
+
DeadLetterConfig: {
|
|
144
|
+
TargetArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake'
|
|
145
|
+
},
|
|
146
|
+
Description: 'my description',
|
|
147
|
+
Environment: { Variables: { MyCoolEnv: 'a' } },
|
|
148
|
+
FunctionName: 'my-function',
|
|
149
|
+
Handler: 'index.something',
|
|
150
|
+
KmsKeyArn: 'arn:aws:kms:us-east-1:123456789012:key/fake',
|
|
151
|
+
Layers: ['arn:aws:lambda:us-east-2:590474943231:layer:AWS-Parameters-and-Secrets-Lambda-Extension:4'],
|
|
152
|
+
MemorySize: 512,
|
|
153
|
+
ReservedConcurrentExecutions: 10,
|
|
154
|
+
Runtime: 'nodejs22.x',
|
|
155
|
+
Tags: [{ Key: 'a', Value: 'b' }],
|
|
156
|
+
Timeout: 30,
|
|
157
|
+
TracingConfig: { Mode: 'Active' },
|
|
158
|
+
VpcConfig: {
|
|
159
|
+
SecurityGroupIds: ['sg-12345678'],
|
|
160
|
+
SubnetIds: ['fake']
|
|
161
|
+
},
|
|
162
|
+
Condition: 'Always',
|
|
163
|
+
DependsOn: 'AnotherThing',
|
|
164
|
+
Statement: [
|
|
165
|
+
{
|
|
166
|
+
Effect: 'Allow',
|
|
167
|
+
Action: 's3:GetObject',
|
|
168
|
+
Resource: 'arn:aws:s3:::fake/data'
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
AlarmName: 'my-alarm',
|
|
172
|
+
AlarmDescription: 'some alarm',
|
|
173
|
+
AlarmActions: ['devnull@mapbox.com'],
|
|
174
|
+
Period: 120,
|
|
175
|
+
EvaluationPeriods: 2,
|
|
176
|
+
Statistic: 'Minimum',
|
|
177
|
+
Threshold: 10,
|
|
178
|
+
ComparisonOperator: 'LessThanThreshold',
|
|
179
|
+
TreatMissingData: 'breaching',
|
|
180
|
+
EvaluateLowSampleCountPercentile: 'ignore',
|
|
181
|
+
ExtendedStatistics: 'p100',
|
|
182
|
+
OKActions: ['devnull@mapbox.com'],
|
|
183
|
+
LogRetentionInDays: 30
|
|
184
|
+
});
|
|
220
185
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
186
|
+
const template = cf.merge(
|
|
187
|
+
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
188
|
+
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
189
|
+
lambda
|
|
190
|
+
);
|
|
191
|
+
if (update) fixtures.update('lambda-full', template);
|
|
192
|
+
expect(noUndefined(template)).toEqual(fixtures.get('lambda-full'));
|
|
228
193
|
});
|
|
229
194
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
195
|
+
test('LogPolicyName parameter correctly overrides the default policy name', () => {
|
|
196
|
+
const lambda = new cf.shortcuts.Lambda({
|
|
197
|
+
LogicalName: 'MyLambda',
|
|
198
|
+
Code: {
|
|
199
|
+
S3Bucket: 'my-code-bucket',
|
|
200
|
+
S3Key: 'path/to/code.zip'
|
|
201
|
+
},
|
|
202
|
+
LogPolicyName: 'CustomLogPolicyName'
|
|
203
|
+
});
|
|
236
204
|
|
|
237
|
-
|
|
205
|
+
const template = cf.merge(lambda);
|
|
206
|
+
expect(template.Resources.MyLambdaLogPolicy.Properties.PolicyName).toBe('CustomLogPolicyName');
|
|
207
|
+
});
|
|
238
208
|
});
|
|
239
209
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
() => new cf.shortcuts.QueueLambda()
|
|
243
|
-
|
|
244
|
-
'throws without options'
|
|
245
|
-
);
|
|
246
|
-
assert.throws(
|
|
247
|
-
() => new cf.shortcuts.QueueLambda({}),
|
|
248
|
-
/You must provide a LogicalName, and Code/,
|
|
249
|
-
'throws without basic lambda required parameters'
|
|
250
|
-
);
|
|
210
|
+
describe('[shortcuts] queue-lambda', () => {
|
|
211
|
+
test('throws without options', () => {
|
|
212
|
+
expect(() => new cf.shortcuts.QueueLambda()).toThrow('Options required');
|
|
213
|
+
});
|
|
251
214
|
|
|
252
|
-
|
|
253
|
-
() =>
|
|
254
|
-
|
|
255
|
-
LogicalName: 'MyLambda',
|
|
256
|
-
Code: {
|
|
257
|
-
S3Bucket: 'my-code-bucket',
|
|
258
|
-
S3Key: 'path/to/code.zip'
|
|
259
|
-
}
|
|
260
|
-
}),
|
|
261
|
-
/You must provide an EventSourceArn and ReservedConcurrentExecutions/,
|
|
262
|
-
'throws without queue-lambda required parameters'
|
|
263
|
-
);
|
|
215
|
+
test('throws without basic lambda required parameters', () => {
|
|
216
|
+
expect(() => new cf.shortcuts.QueueLambda({})).toThrow(/You must provide a LogicalName, and Code/);
|
|
217
|
+
});
|
|
264
218
|
|
|
265
|
-
|
|
266
|
-
() =>
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
ReservedConcurrentExecutions: -1
|
|
275
|
-
}),
|
|
276
|
-
/ReservedConcurrentExecutions must be greater than or equal to 0/,
|
|
277
|
-
'throws when ReservedConcurrentExecutions is a negative number'
|
|
278
|
-
);
|
|
219
|
+
test('throws without queue-lambda required parameters', () => {
|
|
220
|
+
expect(() => new cf.shortcuts.QueueLambda({
|
|
221
|
+
LogicalName: 'MyLambda',
|
|
222
|
+
Code: {
|
|
223
|
+
S3Bucket: 'my-code-bucket',
|
|
224
|
+
S3Key: 'path/to/code.zip'
|
|
225
|
+
}
|
|
226
|
+
})).toThrow(/You must provide an EventSourceArn and ReservedConcurrentExecutions/);
|
|
227
|
+
});
|
|
279
228
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
assert.deepEqual(
|
|
292
|
-
noUndefined(zeroTemplate),
|
|
293
|
-
fixtures.get('queue-lambda-zero'),
|
|
294
|
-
'expected resources generated'
|
|
295
|
-
);
|
|
229
|
+
test('throws when ReservedConcurrentExecutions is a negative number', () => {
|
|
230
|
+
expect(() => new cf.shortcuts.QueueLambda({
|
|
231
|
+
LogicalName: 'MyLambda',
|
|
232
|
+
Code: {
|
|
233
|
+
S3Bucket: 'my-code-bucket',
|
|
234
|
+
S3Key: 'path/to/code.zip'
|
|
235
|
+
},
|
|
236
|
+
EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
|
|
237
|
+
ReservedConcurrentExecutions: -1
|
|
238
|
+
})).toThrow(/ReservedConcurrentExecutions must be greater than or equal to 0/);
|
|
239
|
+
});
|
|
296
240
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
241
|
+
test('expected resources generated with zero concurrency', () => {
|
|
242
|
+
const zeroLambda = new cf.shortcuts.QueueLambda({
|
|
243
|
+
LogicalName: 'MyLambda',
|
|
244
|
+
Code: {
|
|
245
|
+
S3Bucket: 'my-code-bucket',
|
|
246
|
+
S3Key: 'path/to/code.zip'
|
|
247
|
+
},
|
|
248
|
+
EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
|
|
249
|
+
ReservedConcurrentExecutions: 0
|
|
250
|
+
});
|
|
251
|
+
const zeroTemplate = cf.merge(zeroLambda);
|
|
252
|
+
if (update) fixtures.update('queue-lambda-zero', zeroTemplate);
|
|
253
|
+
expect(noUndefined(zeroTemplate)).toEqual(fixtures.get('queue-lambda-zero'));
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
test('expected resources generated', () => {
|
|
257
|
+
const lambda = new cf.shortcuts.QueueLambda({
|
|
258
|
+
LogicalName: 'MyLambda',
|
|
259
|
+
Code: {
|
|
260
|
+
S3Bucket: 'my-code-bucket',
|
|
261
|
+
S3Key: 'path/to/code.zip'
|
|
262
|
+
},
|
|
263
|
+
EventSourceArn: 'arn:aws:sqs:us-east-1:123456789012:queue/fake',
|
|
264
|
+
ReservedConcurrentExecutions: 10
|
|
265
|
+
});
|
|
314
266
|
|
|
315
|
-
|
|
267
|
+
const template = cf.merge(lambda);
|
|
268
|
+
if (update) fixtures.update('queue-lambda', template);
|
|
269
|
+
expect(noUndefined(template)).toEqual(fixtures.get('queue-lambda'));
|
|
270
|
+
});
|
|
316
271
|
});
|
|
317
272
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
() => new cf.shortcuts.ScheduledLambda()
|
|
321
|
-
|
|
322
|
-
'throws without options'
|
|
323
|
-
);
|
|
324
|
-
assert.throws(
|
|
325
|
-
() => new cf.shortcuts.ScheduledLambda({}),
|
|
326
|
-
/You must provide a LogicalName, and Code/,
|
|
327
|
-
'throws without basic lambda required parameters'
|
|
328
|
-
);
|
|
273
|
+
describe('[shortcuts] scheduled-lambda', () => {
|
|
274
|
+
test('throws without options', () => {
|
|
275
|
+
expect(() => new cf.shortcuts.ScheduledLambda()).toThrow('Options required');
|
|
276
|
+
});
|
|
329
277
|
|
|
330
|
-
|
|
331
|
-
() =>
|
|
332
|
-
|
|
333
|
-
LogicalName: 'MyLambda',
|
|
334
|
-
Code: {
|
|
335
|
-
S3Bucket: 'my-code-bucket',
|
|
336
|
-
S3Key: 'path/to/code.zip'
|
|
337
|
-
}
|
|
338
|
-
}),
|
|
339
|
-
/You must provide a ScheduleExpression/,
|
|
340
|
-
'throws without scheduled-lambda required parameters'
|
|
341
|
-
);
|
|
278
|
+
test('throws without basic lambda required parameters', () => {
|
|
279
|
+
expect(() => new cf.shortcuts.ScheduledLambda({})).toThrow(/You must provide a LogicalName, and Code/);
|
|
280
|
+
});
|
|
342
281
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
let template = cf.merge(lambda);
|
|
353
|
-
if (update) fixtures.update('scheduled-lambda-defaults', template);
|
|
354
|
-
assert.deepEqual(
|
|
355
|
-
noUndefined(template),
|
|
356
|
-
fixtures.get('scheduled-lambda-defaults'),
|
|
357
|
-
'expected resources generated with defaults'
|
|
358
|
-
);
|
|
282
|
+
test('throws without scheduled-lambda required parameters', () => {
|
|
283
|
+
expect(() => new cf.shortcuts.ScheduledLambda({
|
|
284
|
+
LogicalName: 'MyLambda',
|
|
285
|
+
Code: {
|
|
286
|
+
S3Bucket: 'my-code-bucket',
|
|
287
|
+
S3Key: 'path/to/code.zip'
|
|
288
|
+
}
|
|
289
|
+
})).toThrow(/You must provide a ScheduleExpression/);
|
|
290
|
+
});
|
|
359
291
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
State: 'DISABLED'
|
|
370
|
-
});
|
|
371
|
-
|
|
372
|
-
template = cf.merge(lambda);
|
|
373
|
-
if (update) fixtures.update('scheduled-lambda-full', template);
|
|
374
|
-
assert.deepEqual(
|
|
375
|
-
noUndefined(template),
|
|
376
|
-
fixtures.get('scheduled-lambda-full'),
|
|
377
|
-
'expected resources generated without defaults'
|
|
378
|
-
);
|
|
292
|
+
test('expected resources generated with defaults', () => {
|
|
293
|
+
const lambda = new cf.shortcuts.ScheduledLambda({
|
|
294
|
+
LogicalName: 'MyLambda',
|
|
295
|
+
Code: {
|
|
296
|
+
S3Bucket: 'my-code-bucket',
|
|
297
|
+
S3Key: 'path/to/code.zip'
|
|
298
|
+
},
|
|
299
|
+
ScheduleExpression: 'rate(1 hour)'
|
|
300
|
+
});
|
|
379
301
|
|
|
380
|
-
|
|
302
|
+
const template = cf.merge(lambda);
|
|
303
|
+
if (update) fixtures.update('scheduled-lambda-defaults', template);
|
|
304
|
+
expect(noUndefined(template)).toEqual(fixtures.get('scheduled-lambda-defaults'));
|
|
305
|
+
});
|
|
306
|
+
|
|
307
|
+
test('expected resources generated without defaults', () => {
|
|
308
|
+
const lambda = new cf.shortcuts.ScheduledLambda({
|
|
309
|
+
LogicalName: 'MyLambda',
|
|
310
|
+
Code: {
|
|
311
|
+
S3Bucket: 'my-code-bucket',
|
|
312
|
+
S3Key: 'path/to/code.zip'
|
|
313
|
+
},
|
|
314
|
+
ScheduleRoleArn: 'arn:aws:iam::012345678901:role/MyCoolRole',
|
|
315
|
+
ScheduleGroupName: 'my-cool-stack',
|
|
316
|
+
ScheduleExpression: 'rate(1 hour)',
|
|
317
|
+
State: 'DISABLED'
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
const template = cf.merge(lambda);
|
|
321
|
+
if (update) fixtures.update('scheduled-lambda-full', template);
|
|
322
|
+
expect(noUndefined(template)).toEqual(fixtures.get('scheduled-lambda-full'));
|
|
323
|
+
});
|
|
381
324
|
});
|
|
382
325
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
() => new cf.shortcuts.EventLambda()
|
|
386
|
-
|
|
387
|
-
'throws without options'
|
|
388
|
-
);
|
|
389
|
-
assert.throws(
|
|
390
|
-
() => new cf.shortcuts.EventLambda({}),
|
|
391
|
-
/You must provide a LogicalName, and Code/,
|
|
392
|
-
'throws without basic lambda required parameters'
|
|
393
|
-
);
|
|
326
|
+
describe('[shortcuts] event-lambda', () => {
|
|
327
|
+
test('throws without options', () => {
|
|
328
|
+
expect(() => new cf.shortcuts.EventLambda()).toThrow('Options required');
|
|
329
|
+
});
|
|
394
330
|
|
|
395
|
-
|
|
396
|
-
() =>
|
|
397
|
-
|
|
398
|
-
LogicalName: 'MyLambda',
|
|
399
|
-
Code: {
|
|
400
|
-
S3Bucket: 'my-code-bucket',
|
|
401
|
-
S3Key: 'path/to/code.zip'
|
|
402
|
-
}
|
|
403
|
-
}),
|
|
404
|
-
/You must provide an EventPattern/,
|
|
405
|
-
'throws without event-lambda required parameters'
|
|
406
|
-
);
|
|
331
|
+
test('throws without basic lambda required parameters', () => {
|
|
332
|
+
expect(() => new cf.shortcuts.EventLambda({})).toThrow(/You must provide a LogicalName, and Code/);
|
|
333
|
+
});
|
|
407
334
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
EventPattern: {
|
|
415
|
-
source: ['aws.ec2'],
|
|
416
|
-
'detail-type': ['EC2 Instance State-change Notification'],
|
|
417
|
-
detail: {
|
|
418
|
-
state: ['running']
|
|
335
|
+
test('throws without event-lambda required parameters', () => {
|
|
336
|
+
expect(() => new cf.shortcuts.EventLambda({
|
|
337
|
+
LogicalName: 'MyLambda',
|
|
338
|
+
Code: {
|
|
339
|
+
S3Bucket: 'my-code-bucket',
|
|
340
|
+
S3Key: 'path/to/code.zip'
|
|
419
341
|
}
|
|
420
|
-
}
|
|
342
|
+
})).toThrow(/You must provide an EventPattern/);
|
|
421
343
|
});
|
|
422
344
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
},
|
|
437
|
-
EventPattern: {
|
|
438
|
-
source: ['aws.ec2'],
|
|
439
|
-
'detail-type': ['EC2 Instance State-change Notification'],
|
|
440
|
-
detail: {
|
|
441
|
-
state: ['running']
|
|
345
|
+
test('expected resources generated with defaults', () => {
|
|
346
|
+
const lambda = new cf.shortcuts.EventLambda({
|
|
347
|
+
LogicalName: 'MyLambda',
|
|
348
|
+
Code: {
|
|
349
|
+
S3Bucket: 'my-code-bucket',
|
|
350
|
+
S3Key: 'path/to/code.zip'
|
|
351
|
+
},
|
|
352
|
+
EventPattern: {
|
|
353
|
+
source: ['aws.ec2'],
|
|
354
|
+
'detail-type': ['EC2 Instance State-change Notification'],
|
|
355
|
+
detail: {
|
|
356
|
+
state: ['running']
|
|
357
|
+
}
|
|
442
358
|
}
|
|
443
|
-
}
|
|
444
|
-
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
const template = cf.merge(lambda);
|
|
362
|
+
if (update) fixtures.update('event-lambda-defaults', template);
|
|
363
|
+
expect(noUndefined(template)).toEqual(fixtures.get('event-lambda-defaults'));
|
|
445
364
|
});
|
|
446
365
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
366
|
+
test('expected resources generated without defaults', () => {
|
|
367
|
+
const lambda = new cf.shortcuts.EventLambda({
|
|
368
|
+
LogicalName: 'MyLambda',
|
|
369
|
+
Code: {
|
|
370
|
+
S3Bucket: 'my-code-bucket',
|
|
371
|
+
S3Key: 'path/to/code.zip'
|
|
372
|
+
},
|
|
373
|
+
EventPattern: {
|
|
374
|
+
source: ['aws.ec2'],
|
|
375
|
+
'detail-type': ['EC2 Instance State-change Notification'],
|
|
376
|
+
detail: {
|
|
377
|
+
state: ['running']
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
State: 'DISABLED'
|
|
381
|
+
});
|
|
454
382
|
|
|
455
|
-
|
|
383
|
+
const template = cf.merge(lambda);
|
|
384
|
+
if (update) fixtures.update('event-lambda-full', template);
|
|
385
|
+
expect(noUndefined(template)).toEqual(fixtures.get('event-lambda-full'));
|
|
386
|
+
});
|
|
456
387
|
});
|
|
457
388
|
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
() => new cf.shortcuts.StreamLambda()
|
|
461
|
-
|
|
462
|
-
'throws without options'
|
|
463
|
-
);
|
|
464
|
-
assert.throws(
|
|
465
|
-
() => new cf.shortcuts.StreamLambda({}),
|
|
466
|
-
/You must provide a LogicalName, and Code/,
|
|
467
|
-
'throws without basic lambda required parameters'
|
|
468
|
-
);
|
|
389
|
+
describe('[shortcuts] stream-lambda', () => {
|
|
390
|
+
test('throws without options', () => {
|
|
391
|
+
expect(() => new cf.shortcuts.StreamLambda()).toThrow('Options required');
|
|
392
|
+
});
|
|
469
393
|
|
|
470
|
-
|
|
471
|
-
() =>
|
|
472
|
-
|
|
473
|
-
LogicalName: 'MyLambda',
|
|
474
|
-
Code: {
|
|
475
|
-
S3Bucket: 'my-code-bucket',
|
|
476
|
-
S3Key: 'path/to/code.zip'
|
|
477
|
-
}
|
|
478
|
-
}),
|
|
479
|
-
/You must provide an EventSourceArn/,
|
|
480
|
-
'throws without stream-lambda required parameters'
|
|
481
|
-
);
|
|
394
|
+
test('throws without basic lambda required parameters', () => {
|
|
395
|
+
expect(() => new cf.shortcuts.StreamLambda({})).toThrow(/You must provide a LogicalName, and Code/);
|
|
396
|
+
});
|
|
482
397
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
let template = cf.merge(lambda);
|
|
493
|
-
if (update) fixtures.update('stream-lambda-defaults', template);
|
|
494
|
-
assert.deepEqual(
|
|
495
|
-
noUndefined(template),
|
|
496
|
-
fixtures.get('stream-lambda-defaults'),
|
|
497
|
-
'expected resources generated via defaults'
|
|
498
|
-
);
|
|
398
|
+
test('throws without stream-lambda required parameters', () => {
|
|
399
|
+
expect(() => new cf.shortcuts.StreamLambda({
|
|
400
|
+
LogicalName: 'MyLambda',
|
|
401
|
+
Code: {
|
|
402
|
+
S3Bucket: 'my-code-bucket',
|
|
403
|
+
S3Key: 'path/to/code.zip'
|
|
404
|
+
}
|
|
405
|
+
})).toThrow(/You must provide an EventSourceArn/);
|
|
406
|
+
});
|
|
499
407
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
BatchSize: 10000,
|
|
515
|
-
MaximumBatchingWindowInSeconds: 300,
|
|
516
|
-
Enabled: false,
|
|
517
|
-
StartingPosition: 'TRIM_HORIZON'
|
|
518
|
-
});
|
|
519
|
-
|
|
520
|
-
template = cf.merge(lambda);
|
|
521
|
-
if (update) fixtures.update('stream-lambda-no-defaults', template);
|
|
522
|
-
assert.deepEqual(
|
|
523
|
-
noUndefined(template),
|
|
524
|
-
fixtures.get('stream-lambda-no-defaults'),
|
|
525
|
-
'expected resources generated without defaults'
|
|
526
|
-
);
|
|
408
|
+
test('expected resources generated via defaults', () => {
|
|
409
|
+
const lambda = new cf.shortcuts.StreamLambda({
|
|
410
|
+
LogicalName: 'MyLambda',
|
|
411
|
+
Code: {
|
|
412
|
+
S3Bucket: 'my-code-bucket',
|
|
413
|
+
S3Key: 'path/to/code.zip'
|
|
414
|
+
},
|
|
415
|
+
EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake'
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
const template = cf.merge(lambda);
|
|
419
|
+
if (update) fixtures.update('stream-lambda-defaults', template);
|
|
420
|
+
expect(noUndefined(template)).toEqual(fixtures.get('stream-lambda-defaults'));
|
|
421
|
+
});
|
|
527
422
|
|
|
528
|
-
|
|
423
|
+
test('expected resources generated without defaults', () => {
|
|
424
|
+
const lambda = new cf.shortcuts.StreamLambda({
|
|
425
|
+
LogicalName: 'MyLambda',
|
|
426
|
+
Code: {
|
|
427
|
+
S3Bucket: 'my-code-bucket',
|
|
428
|
+
S3Key: 'path/to/code.zip'
|
|
429
|
+
},
|
|
430
|
+
EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
|
|
431
|
+
FilterCriteria: {
|
|
432
|
+
Filters: [
|
|
433
|
+
{
|
|
434
|
+
Pattern: JSON.stringify({ eventName: ['INSERT', 'MODIFY'] })
|
|
435
|
+
}
|
|
436
|
+
]
|
|
437
|
+
},
|
|
438
|
+
BatchSize: 10000,
|
|
439
|
+
MaximumBatchingWindowInSeconds: 300,
|
|
440
|
+
Enabled: false,
|
|
441
|
+
StartingPosition: 'TRIM_HORIZON'
|
|
442
|
+
});
|
|
443
|
+
|
|
444
|
+
const template = cf.merge(lambda);
|
|
445
|
+
if (update) fixtures.update('stream-lambda-no-defaults', template);
|
|
446
|
+
expect(noUndefined(template)).toEqual(fixtures.get('stream-lambda-no-defaults'));
|
|
447
|
+
});
|
|
529
448
|
});
|
|
530
449
|
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
() => new cf.shortcuts.StreamLambda({
|
|
450
|
+
describe('[shortcuts] StreamLambda FilterCriteria', () => {
|
|
451
|
+
test('FilterCriteria must be a JSON-like object', () => {
|
|
452
|
+
expect(() => new cf.shortcuts.StreamLambda({
|
|
534
453
|
LogicalName: 'MyLambda',
|
|
535
454
|
Code: {
|
|
536
455
|
S3Bucket: 'my-code-bucket',
|
|
@@ -538,11 +457,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
|
|
|
538
457
|
},
|
|
539
458
|
EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
|
|
540
459
|
FilterCriteria: ['test']
|
|
541
|
-
})
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
() => new cf.shortcuts.StreamLambda({
|
|
460
|
+
})).toThrow();
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
test('FilterCriteria must contain property Filter of type array', () => {
|
|
464
|
+
expect(() => new cf.shortcuts.StreamLambda({
|
|
546
465
|
LogicalName: 'MyLambda',
|
|
547
466
|
Code: {
|
|
548
467
|
S3Bucket: 'my-code-bucket',
|
|
@@ -550,11 +469,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
|
|
|
550
469
|
},
|
|
551
470
|
EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
|
|
552
471
|
FilterCriteria: {}
|
|
553
|
-
})
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
() => new cf.shortcuts.StreamLambda({
|
|
472
|
+
})).toThrow();
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
test('FilterCriteria.Filter must be an array', () => {
|
|
476
|
+
expect(() => new cf.shortcuts.StreamLambda({
|
|
558
477
|
LogicalName: 'MyLambda',
|
|
559
478
|
Code: {
|
|
560
479
|
S3Bucket: 'my-code-bucket',
|
|
@@ -564,11 +483,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
|
|
|
564
483
|
FilterCriteria: {
|
|
565
484
|
Filter: 613
|
|
566
485
|
}
|
|
567
|
-
})
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
() => new cf.shortcuts.StreamLambda({
|
|
486
|
+
})).toThrow();
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
test('FilterCriteria.Filter objects must have Pattern property', () => {
|
|
490
|
+
expect(() => new cf.shortcuts.StreamLambda({
|
|
572
491
|
LogicalName: 'MyLambda',
|
|
573
492
|
Code: {
|
|
574
493
|
S3Bucket: 'my-code-bucket',
|
|
@@ -585,11 +504,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
|
|
|
585
504
|
}
|
|
586
505
|
]
|
|
587
506
|
}
|
|
588
|
-
})
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
() => new cf.shortcuts.StreamLambda({
|
|
507
|
+
})).toThrow();
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
test('FilterCriteria.Filter Pattern must be JSON parseable string', () => {
|
|
511
|
+
expect(() => new cf.shortcuts.StreamLambda({
|
|
593
512
|
LogicalName: 'MyLambda',
|
|
594
513
|
Code: {
|
|
595
514
|
S3Bucket: 'my-code-bucket',
|
|
@@ -606,930 +525,798 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
|
|
|
606
525
|
}
|
|
607
526
|
]
|
|
608
527
|
}
|
|
609
|
-
})
|
|
610
|
-
|
|
611
|
-
);
|
|
612
|
-
assert.end();
|
|
528
|
+
})).toThrow();
|
|
529
|
+
});
|
|
613
530
|
});
|
|
614
531
|
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
() => new cf.shortcuts.LogSubscriptionLambda()
|
|
618
|
-
|
|
619
|
-
'throws without options'
|
|
620
|
-
);
|
|
621
|
-
assert.throws(
|
|
622
|
-
() => new cf.shortcuts.LogSubscriptionLambda({}),
|
|
623
|
-
/You must provide a LogicalName, and Code/,
|
|
624
|
-
'throws without basic lambda required parameters'
|
|
625
|
-
);
|
|
532
|
+
describe('[shortcuts] log-subscription-lambda', () => {
|
|
533
|
+
test('throws without options', () => {
|
|
534
|
+
expect(() => new cf.shortcuts.LogSubscriptionLambda()).toThrow('Options required');
|
|
535
|
+
});
|
|
626
536
|
|
|
627
|
-
|
|
628
|
-
() =>
|
|
629
|
-
|
|
630
|
-
LogicalName: 'MyLambda',
|
|
631
|
-
Code: {
|
|
632
|
-
S3Bucket: 'my-code-bucket',
|
|
633
|
-
S3Key: 'path/to/code.zip'
|
|
634
|
-
}
|
|
635
|
-
}),
|
|
636
|
-
/You must provide a LogGroupName/,
|
|
637
|
-
'throws without log-subscription-lambda required parameters'
|
|
638
|
-
);
|
|
537
|
+
test('throws without basic lambda required parameters', () => {
|
|
538
|
+
expect(() => new cf.shortcuts.LogSubscriptionLambda({})).toThrow(/You must provide a LogicalName, and Code/);
|
|
539
|
+
});
|
|
639
540
|
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
let template = cf.merge(lambda);
|
|
650
|
-
if (update) fixtures.update('log-subscription-lambda-defaults', template);
|
|
651
|
-
assert.deepEqual(
|
|
652
|
-
noUndefined(template),
|
|
653
|
-
fixtures.get('log-subscription-lambda-defaults'),
|
|
654
|
-
'expected resources generated via defaults'
|
|
655
|
-
);
|
|
541
|
+
test('throws without log-subscription-lambda required parameters', () => {
|
|
542
|
+
expect(() => new cf.shortcuts.LogSubscriptionLambda({
|
|
543
|
+
LogicalName: 'MyLambda',
|
|
544
|
+
Code: {
|
|
545
|
+
S3Bucket: 'my-code-bucket',
|
|
546
|
+
S3Key: 'path/to/code.zip'
|
|
547
|
+
}
|
|
548
|
+
})).toThrow(/You must provide a LogGroupName/);
|
|
549
|
+
});
|
|
656
550
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
template = cf.merge(lambda);
|
|
668
|
-
if (update) fixtures.update('log-subscription-lambda-no-defaults', template);
|
|
669
|
-
assert.deepEqual(
|
|
670
|
-
noUndefined(template),
|
|
671
|
-
fixtures.get('log-subscription-lambda-no-defaults'),
|
|
672
|
-
'expected resources generated without defaults'
|
|
673
|
-
);
|
|
551
|
+
test('expected resources generated via defaults', () => {
|
|
552
|
+
const lambda = new cf.shortcuts.LogSubscriptionLambda({
|
|
553
|
+
LogicalName: 'MyLambda',
|
|
554
|
+
Code: {
|
|
555
|
+
S3Bucket: 'my-code-bucket',
|
|
556
|
+
S3Key: 'path/to/code.zip'
|
|
557
|
+
},
|
|
558
|
+
LogGroupName: 'my-log-group'
|
|
559
|
+
});
|
|
674
560
|
|
|
675
|
-
|
|
561
|
+
const template = cf.merge(lambda);
|
|
562
|
+
if (update) fixtures.update('log-subscription-lambda-defaults', template);
|
|
563
|
+
expect(noUndefined(template)).toEqual(fixtures.get('log-subscription-lambda-defaults'));
|
|
564
|
+
});
|
|
565
|
+
|
|
566
|
+
test('expected resources generated without defaults', () => {
|
|
567
|
+
const lambda = new cf.shortcuts.LogSubscriptionLambda({
|
|
568
|
+
LogicalName: 'MyLambda',
|
|
569
|
+
Code: {
|
|
570
|
+
S3Bucket: 'my-code-bucket',
|
|
571
|
+
S3Key: 'path/to/code.zip'
|
|
572
|
+
},
|
|
573
|
+
FilterPattern: '{ $.errorCode = 400 }',
|
|
574
|
+
LogGroupName: 'my-log-group'
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
const template = cf.merge(lambda);
|
|
578
|
+
if (update) fixtures.update('log-subscription-lambda-no-defaults', template);
|
|
579
|
+
expect(noUndefined(template)).toEqual(fixtures.get('log-subscription-lambda-no-defaults'));
|
|
580
|
+
});
|
|
676
581
|
});
|
|
677
582
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
() => new cf.shortcuts.Queue()
|
|
681
|
-
|
|
682
|
-
'throws without options'
|
|
683
|
-
);
|
|
684
|
-
assert.throws(
|
|
685
|
-
() => new cf.shortcuts.Queue({}),
|
|
686
|
-
/You must provide a LogicalName/,
|
|
687
|
-
'throws without required parameters'
|
|
688
|
-
);
|
|
583
|
+
describe('[shortcuts] queue', () => {
|
|
584
|
+
test('throws without options', () => {
|
|
585
|
+
expect(() => new cf.shortcuts.Queue()).toThrow('Options required');
|
|
586
|
+
});
|
|
689
587
|
|
|
690
|
-
|
|
691
|
-
LogicalName
|
|
588
|
+
test('throws without required parameters', () => {
|
|
589
|
+
expect(() => new cf.shortcuts.Queue({})).toThrow(/You must provide a LogicalName/);
|
|
692
590
|
});
|
|
693
591
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
fixtures.get('queue-defaults'),
|
|
699
|
-
'expected resources generated for full defaults'
|
|
700
|
-
);
|
|
592
|
+
test('expected resources generated for full defaults', () => {
|
|
593
|
+
const queue = new cf.shortcuts.Queue({
|
|
594
|
+
LogicalName: 'MyQueue'
|
|
595
|
+
});
|
|
701
596
|
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
DelaySeconds: 60,
|
|
707
|
-
KmsMasterKeyId: 'alias/my-key',
|
|
708
|
-
KmsDataKeyReusePeriondSeconds: 86400,
|
|
709
|
-
MaximumMessageSize: 1024,
|
|
710
|
-
MessageRetentionPeriod: 60,
|
|
711
|
-
QueueName: 'my-queue',
|
|
712
|
-
ReceiveMessageWaitTimeSeconds: 20,
|
|
713
|
-
Condition: 'Always',
|
|
714
|
-
DependsOn: 'AnotherThing',
|
|
715
|
-
TopicName: 'my-topic',
|
|
716
|
-
DisplayName: 'topic-display-name',
|
|
717
|
-
DeadLetterVisibilityTimeout: 60
|
|
718
|
-
});
|
|
719
|
-
|
|
720
|
-
template = cf.merge(
|
|
721
|
-
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
722
|
-
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
723
|
-
queue
|
|
724
|
-
);
|
|
725
|
-
if (update) fixtures.update('queue-full', template);
|
|
726
|
-
assert.deepEqual(
|
|
727
|
-
noUndefined(template),
|
|
728
|
-
fixtures.get('queue-full'),
|
|
729
|
-
'expected resources generated no defaults'
|
|
730
|
-
);
|
|
597
|
+
const template = cf.merge(queue);
|
|
598
|
+
if (update) fixtures.update('queue-defaults', template);
|
|
599
|
+
expect(noUndefined(template)).toEqual(fixtures.get('queue-defaults'));
|
|
600
|
+
});
|
|
731
601
|
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
602
|
+
test('expected resources generated no defaults', () => {
|
|
603
|
+
const queue = new cf.shortcuts.Queue({
|
|
604
|
+
LogicalName: 'MyQueue',
|
|
605
|
+
VisibilityTimeout: 60,
|
|
606
|
+
maxReceiveCount: 100,
|
|
607
|
+
DelaySeconds: 60,
|
|
608
|
+
KmsMasterKeyId: 'alias/my-key',
|
|
609
|
+
KmsDataKeyReusePeriondSeconds: 86400,
|
|
610
|
+
MaximumMessageSize: 1024,
|
|
611
|
+
MessageRetentionPeriod: 60,
|
|
612
|
+
QueueName: 'my-queue',
|
|
613
|
+
ReceiveMessageWaitTimeSeconds: 20,
|
|
614
|
+
Condition: 'Always',
|
|
615
|
+
DependsOn: 'AnotherThing',
|
|
616
|
+
TopicName: 'my-topic',
|
|
617
|
+
DisplayName: 'topic-display-name',
|
|
618
|
+
DeadLetterVisibilityTimeout: 60
|
|
619
|
+
});
|
|
620
|
+
|
|
621
|
+
const template = cf.merge(
|
|
622
|
+
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
623
|
+
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
624
|
+
queue
|
|
625
|
+
);
|
|
626
|
+
if (update) fixtures.update('queue-full', template);
|
|
627
|
+
expect(noUndefined(template)).toEqual(fixtures.get('queue-full'));
|
|
735
628
|
});
|
|
736
|
-
template = cf.merge(queue);
|
|
737
|
-
if (update) fixtures.update('queue-external-topic', template);
|
|
738
|
-
assert.deepEqual(
|
|
739
|
-
noUndefined(template),
|
|
740
|
-
fixtures.get('queue-external-topic'),
|
|
741
|
-
'expected resources generated for external topic'
|
|
742
|
-
);
|
|
743
629
|
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
630
|
+
test('expected resources generated for external topic', () => {
|
|
631
|
+
const queue = new cf.shortcuts.Queue({
|
|
632
|
+
LogicalName: 'MyQueue',
|
|
633
|
+
ExistingTopicArn: 'arn:aws:sns:us-east-1:111122223333:MyTopic'
|
|
634
|
+
});
|
|
635
|
+
const template = cf.merge(queue);
|
|
636
|
+
if (update) fixtures.update('queue-external-topic', template);
|
|
637
|
+
expect(noUndefined(template)).toEqual(fixtures.get('queue-external-topic'));
|
|
747
638
|
});
|
|
748
|
-
template = cf.merge(
|
|
749
|
-
{ Resources: { TopicForOtherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
750
|
-
queue
|
|
751
|
-
);
|
|
752
|
-
if (update) fixtures.update('queue-external-topic-ref', template);
|
|
753
|
-
assert.deepEqual(
|
|
754
|
-
noUndefined(template),
|
|
755
|
-
fixtures.get('queue-external-topic-ref'),
|
|
756
|
-
'expected resources generated for external topic identified by ref'
|
|
757
|
-
);
|
|
758
639
|
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
640
|
+
test('expected resources generated for external topic identified by ref', () => {
|
|
641
|
+
const queue = new cf.shortcuts.Queue({
|
|
642
|
+
LogicalName: 'MyQueue',
|
|
643
|
+
ExistingTopicArn: { Ref: 'TopicForOtherThing' }
|
|
644
|
+
});
|
|
645
|
+
const template = cf.merge(
|
|
646
|
+
{ Resources: { TopicForOtherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
647
|
+
queue
|
|
648
|
+
);
|
|
649
|
+
if (update) fixtures.update('queue-external-topic-ref', template);
|
|
650
|
+
expect(noUndefined(template)).toEqual(fixtures.get('queue-external-topic-ref'));
|
|
762
651
|
});
|
|
763
|
-
template = cf.merge(queue);
|
|
764
|
-
if (update) fixtures.update('queue-fifo', template);
|
|
765
|
-
assert.deepEqual(
|
|
766
|
-
noUndefined(template),
|
|
767
|
-
fixtures.get('queue-fifo'),
|
|
768
|
-
'expected resources generated for FIFO queue'
|
|
769
|
-
);
|
|
770
652
|
|
|
771
|
-
queue
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
fixtures.get('queue-fifo-queuename'),
|
|
781
|
-
'expected resources generated for FIFO queue with specified QueueName'
|
|
782
|
-
);
|
|
653
|
+
test('expected resources generated for FIFO queue', () => {
|
|
654
|
+
const queue = new cf.shortcuts.Queue({
|
|
655
|
+
LogicalName: 'MyFifoQueue',
|
|
656
|
+
FifoQueue: true
|
|
657
|
+
});
|
|
658
|
+
const template = cf.merge(queue);
|
|
659
|
+
if (update) fixtures.update('queue-fifo', template);
|
|
660
|
+
expect(noUndefined(template)).toEqual(fixtures.get('queue-fifo'));
|
|
661
|
+
});
|
|
783
662
|
|
|
784
|
-
queue
|
|
785
|
-
|
|
786
|
-
|
|
663
|
+
test('expected resources generated for FIFO queue with specified QueueName', () => {
|
|
664
|
+
const queue = new cf.shortcuts.Queue({
|
|
665
|
+
LogicalName: 'MyFifoQueue',
|
|
666
|
+
QueueName: 'custom-and-fancy',
|
|
667
|
+
FifoQueue: true
|
|
668
|
+
});
|
|
669
|
+
const template = cf.merge(queue);
|
|
670
|
+
if (update) fixtures.update('queue-fifo-queuename', template);
|
|
671
|
+
expect(noUndefined(template)).toEqual(fixtures.get('queue-fifo-queuename'));
|
|
787
672
|
});
|
|
788
|
-
template = cf.merge(queue);
|
|
789
|
-
assert.equal(
|
|
790
|
-
template.Resources.MyFifoFalseQueue.Properties.FifoQueue,
|
|
791
|
-
undefined,
|
|
792
|
-
'the FifoQueue value false is converted to undefined, to pass CFN validation'
|
|
793
|
-
);
|
|
794
673
|
|
|
795
|
-
|
|
674
|
+
test('the FifoQueue value false is converted to undefined, to pass CFN validation', () => {
|
|
675
|
+
const queue = new cf.shortcuts.Queue({
|
|
676
|
+
LogicalName: 'MyFifoFalseQueue',
|
|
677
|
+
FifoQueue: false
|
|
678
|
+
});
|
|
679
|
+
const template = cf.merge(queue);
|
|
680
|
+
expect(template.Resources.MyFifoFalseQueue.Properties.FifoQueue).toBeUndefined();
|
|
681
|
+
});
|
|
796
682
|
});
|
|
797
683
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
() => new cf.shortcuts.S3KinesisFirehose()
|
|
801
|
-
|
|
802
|
-
'throws without options'
|
|
803
|
-
);
|
|
804
|
-
assert.throws(
|
|
805
|
-
() => new cf.shortcuts.S3KinesisFirehose({}),
|
|
806
|
-
/You must provide a LogicalName/,
|
|
807
|
-
'throws without required LogicalName parameter'
|
|
808
|
-
);
|
|
684
|
+
describe('[shortcuts] s3 kinesis firehose', () => {
|
|
685
|
+
test('throws without options', () => {
|
|
686
|
+
expect(() => new cf.shortcuts.S3KinesisFirehose()).toThrow('Options required');
|
|
687
|
+
});
|
|
809
688
|
|
|
810
|
-
|
|
811
|
-
() => new cf.shortcuts.S3KinesisFirehose({
|
|
812
|
-
|
|
813
|
-
}),
|
|
814
|
-
/You must provide a DestinationBucket/,
|
|
815
|
-
'throws without required DestinationBucket parameter'
|
|
816
|
-
);
|
|
689
|
+
test('throws without required LogicalName parameter', () => {
|
|
690
|
+
expect(() => new cf.shortcuts.S3KinesisFirehose({})).toThrow(/You must provide a LogicalName/);
|
|
691
|
+
});
|
|
817
692
|
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
693
|
+
test('throws without required DestinationBucket parameter', () => {
|
|
694
|
+
expect(() => new cf.shortcuts.S3KinesisFirehose({
|
|
695
|
+
LogicalName: 'MyKinesisFirehose'
|
|
696
|
+
})).toThrow(/You must provide a DestinationBucket/);
|
|
821
697
|
});
|
|
822
698
|
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
'expected resources generated for full defaults'
|
|
829
|
-
);
|
|
699
|
+
test('expected resources generated for full defaults', () => {
|
|
700
|
+
const firehose = new cf.shortcuts.S3KinesisFirehose({
|
|
701
|
+
LogicalName: 'MyKinesisFirehose',
|
|
702
|
+
DestinationBucket: 'mah-bukkit'
|
|
703
|
+
});
|
|
830
704
|
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
KinesisStreamARN: 'arn:aws:kinesis:us-east-1:111122223333:stream/my-stream'
|
|
705
|
+
const template = cf.merge(firehose);
|
|
706
|
+
if (update) fixtures.update('firehose-defaults', template);
|
|
707
|
+
expect(noUndefined(template)).toEqual(fixtures.get('firehose-defaults'));
|
|
835
708
|
});
|
|
836
709
|
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
assert.deepEqual(
|
|
844
|
-
noUndefined(template),
|
|
845
|
-
fixtures.get('firehose-with-stream'),
|
|
846
|
-
'expected resources generated with stream'
|
|
847
|
-
);
|
|
710
|
+
test('expected resources generated with stream', () => {
|
|
711
|
+
const firehose = new cf.shortcuts.S3KinesisFirehose({
|
|
712
|
+
LogicalName: 'MyKinesisFirehose',
|
|
713
|
+
DestinationBucket: 'mah-bukkit',
|
|
714
|
+
KinesisStreamARN: 'arn:aws:kinesis:us-east-1:111122223333:stream/my-stream'
|
|
715
|
+
});
|
|
848
716
|
|
|
849
|
-
|
|
717
|
+
const template = cf.merge(
|
|
718
|
+
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
719
|
+
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
720
|
+
firehose
|
|
721
|
+
);
|
|
722
|
+
if (update) fixtures.update('firehose-with-stream', template);
|
|
723
|
+
expect(noUndefined(template)).toEqual(fixtures.get('firehose-with-stream'));
|
|
724
|
+
});
|
|
850
725
|
});
|
|
851
726
|
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
() => new cf.shortcuts.Role()
|
|
855
|
-
|
|
856
|
-
'throws without options'
|
|
857
|
-
);
|
|
858
|
-
assert.throws(
|
|
859
|
-
() => new cf.shortcuts.Role({}),
|
|
860
|
-
/You must provide a LogicalName and AssumeRolePrincipals/,
|
|
861
|
-
'throws without required parameters'
|
|
862
|
-
);
|
|
727
|
+
describe('[shortcuts] role', () => {
|
|
728
|
+
test('throws without options', () => {
|
|
729
|
+
expect(() => new cf.shortcuts.Role()).toThrow('Options required');
|
|
730
|
+
});
|
|
863
731
|
|
|
864
|
-
|
|
865
|
-
LogicalName
|
|
866
|
-
AssumeRolePrincipals: [{ Service: 'ec2.amazonaws.com' }]
|
|
732
|
+
test('throws without required parameters', () => {
|
|
733
|
+
expect(() => new cf.shortcuts.Role({})).toThrow(/You must provide a LogicalName and AssumeRolePrincipals/);
|
|
867
734
|
});
|
|
868
735
|
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
'expected resources generated with defaults'
|
|
875
|
-
);
|
|
736
|
+
test('expected resources generated with defaults', () => {
|
|
737
|
+
const role = new cf.shortcuts.Role({
|
|
738
|
+
LogicalName: 'MyRole',
|
|
739
|
+
AssumeRolePrincipals: [{ Service: 'ec2.amazonaws.com' }]
|
|
740
|
+
});
|
|
876
741
|
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
{
|
|
882
|
-
Effect: 'Allow',
|
|
883
|
-
Action: 's3:GetObject',
|
|
884
|
-
Resource: 'arn:aws:s3:::fake/data'
|
|
885
|
-
}
|
|
886
|
-
],
|
|
887
|
-
ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
|
|
888
|
-
MaxSessionDuration: 3600,
|
|
889
|
-
Path: '/fake/',
|
|
890
|
-
RoleName: 'my-role',
|
|
891
|
-
Tags: [{ Key: 'pipeline-name', Value: 'test' }],
|
|
892
|
-
Condition: 'Always',
|
|
893
|
-
DependsOn: 'AnotherThing'
|
|
894
|
-
});
|
|
895
|
-
|
|
896
|
-
template = cf.merge(
|
|
897
|
-
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
898
|
-
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
899
|
-
role
|
|
900
|
-
);
|
|
901
|
-
if (update) fixtures.update('role-no-defaults', template);
|
|
902
|
-
assert.deepEqual(
|
|
903
|
-
noUndefined(template),
|
|
904
|
-
fixtures.get('role-no-defaults'),
|
|
905
|
-
'expected resources generated without defaults'
|
|
906
|
-
);
|
|
742
|
+
const template = cf.merge(role);
|
|
743
|
+
if (update) fixtures.update('role-defaults', template);
|
|
744
|
+
expect(noUndefined(template)).toEqual(fixtures.get('role-defaults'));
|
|
745
|
+
});
|
|
907
746
|
|
|
908
|
-
|
|
747
|
+
test('expected resources generated without defaults', () => {
|
|
748
|
+
const role = new cf.shortcuts.Role({
|
|
749
|
+
LogicalName: 'MyRole',
|
|
750
|
+
AssumeRolePrincipals: [{ Service: 'ec2.amazonaws.com' }],
|
|
751
|
+
Statement: [
|
|
752
|
+
{
|
|
753
|
+
Effect: 'Allow',
|
|
754
|
+
Action: 's3:GetObject',
|
|
755
|
+
Resource: 'arn:aws:s3:::fake/data'
|
|
756
|
+
}
|
|
757
|
+
],
|
|
758
|
+
ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
|
|
759
|
+
MaxSessionDuration: 3600,
|
|
760
|
+
Path: '/fake/',
|
|
761
|
+
RoleName: 'my-role',
|
|
762
|
+
Tags: [{ Key: 'pipeline-name', Value: 'test' }],
|
|
763
|
+
Condition: 'Always',
|
|
764
|
+
DependsOn: 'AnotherThing'
|
|
765
|
+
});
|
|
766
|
+
|
|
767
|
+
const template = cf.merge(
|
|
768
|
+
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
769
|
+
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
770
|
+
role
|
|
771
|
+
);
|
|
772
|
+
if (update) fixtures.update('role-no-defaults', template);
|
|
773
|
+
expect(noUndefined(template)).toEqual(fixtures.get('role-no-defaults'));
|
|
774
|
+
});
|
|
909
775
|
});
|
|
910
776
|
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
() => new cf.shortcuts.CrossAccountRole()
|
|
914
|
-
|
|
915
|
-
'throws without options'
|
|
916
|
-
);
|
|
917
|
-
assert.throws(
|
|
918
|
-
() => new cf.shortcuts.CrossAccountRole({}),
|
|
919
|
-
/You must provide a LogicalName and Accounts/,
|
|
920
|
-
'throws without required parameters'
|
|
921
|
-
);
|
|
777
|
+
describe('[shortcuts] cross-account role', () => {
|
|
778
|
+
test('throws without options', () => {
|
|
779
|
+
expect(() => new cf.shortcuts.CrossAccountRole()).toThrow('Options required');
|
|
780
|
+
});
|
|
922
781
|
|
|
923
|
-
|
|
924
|
-
LogicalName
|
|
925
|
-
|
|
926
|
-
'123456789012',
|
|
927
|
-
'arn:aws:iam::123456789012:root',
|
|
928
|
-
{ 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:root' }
|
|
929
|
-
]
|
|
930
|
-
});
|
|
931
|
-
|
|
932
|
-
let template = cf.merge(role);
|
|
933
|
-
if (update) fixtures.update('cross-account-role-defaults', template);
|
|
934
|
-
assert.deepEqual(
|
|
935
|
-
noUndefined(template),
|
|
936
|
-
fixtures.get('cross-account-role-defaults'),
|
|
937
|
-
'expected resources generated with defaults'
|
|
938
|
-
);
|
|
782
|
+
test('throws without required parameters', () => {
|
|
783
|
+
expect(() => new cf.shortcuts.CrossAccountRole({})).toThrow(/You must provide a LogicalName and Accounts/);
|
|
784
|
+
});
|
|
939
785
|
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
786
|
+
test('expected resources generated with defaults', () => {
|
|
787
|
+
const role = new cf.shortcuts.CrossAccountRole({
|
|
788
|
+
LogicalName: 'MyRole',
|
|
789
|
+
Accounts: [
|
|
790
|
+
'123456789012',
|
|
791
|
+
'arn:aws:iam::123456789012:root',
|
|
792
|
+
{ 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:root' }
|
|
793
|
+
]
|
|
794
|
+
});
|
|
795
|
+
|
|
796
|
+
const template = cf.merge(role);
|
|
797
|
+
if (update) fixtures.update('cross-account-role-defaults', template);
|
|
798
|
+
expect(noUndefined(template)).toEqual(fixtures.get('cross-account-role-defaults'));
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
test('expected resources generated without defaults', () => {
|
|
802
|
+
const role = new cf.shortcuts.CrossAccountRole({
|
|
803
|
+
LogicalName: 'MyRole',
|
|
804
|
+
Accounts: [
|
|
805
|
+
'123456789012',
|
|
806
|
+
'arn:aws:iam::123456789012:root',
|
|
807
|
+
{ 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:root' }
|
|
808
|
+
],
|
|
809
|
+
Statement: [
|
|
810
|
+
{
|
|
811
|
+
Effect: 'Allow',
|
|
812
|
+
Action: 's3:GetObject',
|
|
813
|
+
Resource: 'arn:aws:s3:::fake/data'
|
|
814
|
+
}
|
|
815
|
+
],
|
|
816
|
+
ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
|
|
817
|
+
MaxSessionDuration: 3600,
|
|
818
|
+
Path: '/fake/',
|
|
819
|
+
RoleName: 'my-role',
|
|
820
|
+
Condition: 'Always',
|
|
821
|
+
DependsOn: 'AnotherThing'
|
|
822
|
+
});
|
|
973
823
|
|
|
974
|
-
|
|
824
|
+
const template = cf.merge(
|
|
825
|
+
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
826
|
+
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
827
|
+
role
|
|
828
|
+
);
|
|
829
|
+
if (update) fixtures.update('cross-account-role-no-defaults', template);
|
|
830
|
+
expect(noUndefined(template)).toEqual(fixtures.get('cross-account-role-no-defaults'));
|
|
831
|
+
});
|
|
975
832
|
});
|
|
976
833
|
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
() => new cf.shortcuts.ServiceRole()
|
|
980
|
-
|
|
981
|
-
'throws without options'
|
|
982
|
-
);
|
|
983
|
-
assert.throws(
|
|
984
|
-
() => new cf.shortcuts.ServiceRole({}),
|
|
985
|
-
/You must provide a LogicalName and Service/,
|
|
986
|
-
'throws without required parameters'
|
|
987
|
-
);
|
|
834
|
+
describe('[shortcuts] service role', () => {
|
|
835
|
+
test('throws without options', () => {
|
|
836
|
+
expect(() => new cf.shortcuts.ServiceRole()).toThrow('Options required');
|
|
837
|
+
});
|
|
988
838
|
|
|
989
|
-
|
|
990
|
-
LogicalName
|
|
991
|
-
Service: 'lambda'
|
|
839
|
+
test('throws without required parameters', () => {
|
|
840
|
+
expect(() => new cf.shortcuts.ServiceRole({})).toThrow(/You must provide a LogicalName and Service/);
|
|
992
841
|
});
|
|
993
842
|
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
'expected resources generated with defaults'
|
|
1000
|
-
);
|
|
843
|
+
test('expected resources generated with defaults', () => {
|
|
844
|
+
const role = new cf.shortcuts.ServiceRole({
|
|
845
|
+
LogicalName: 'MyRole',
|
|
846
|
+
Service: 'lambda'
|
|
847
|
+
});
|
|
1001
848
|
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
849
|
+
const template = cf.merge(role);
|
|
850
|
+
if (update) fixtures.update('service-role-defaults', template);
|
|
851
|
+
expect(noUndefined(template)).toEqual(fixtures.get('service-role-defaults'));
|
|
1005
852
|
});
|
|
1006
853
|
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
'expected resources generated, service for which AWS::URLSuffix is invalid'
|
|
1013
|
-
);
|
|
854
|
+
test('expected resources generated, service for which AWS::URLSuffix is invalid', () => {
|
|
855
|
+
const role = new cf.shortcuts.ServiceRole({
|
|
856
|
+
LogicalName: 'MyRole',
|
|
857
|
+
Service: 'lambda.amazonaws.com'
|
|
858
|
+
});
|
|
1014
859
|
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
860
|
+
const template = cf.merge(role);
|
|
861
|
+
if (update) fixtures.update('service-role-no-url-suffix', template);
|
|
862
|
+
expect(noUndefined(template)).toEqual(fixtures.get('service-role-no-url-suffix'));
|
|
1018
863
|
});
|
|
1019
864
|
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
'expected resources generated, service for which AWS::URLSuffix is invalid'
|
|
1026
|
-
);
|
|
865
|
+
test('expected resources generated, service for which AWS::URLSuffix is valid', () => {
|
|
866
|
+
const role = new cf.shortcuts.ServiceRole({
|
|
867
|
+
LogicalName: 'MyRole',
|
|
868
|
+
Service: 'ec2'
|
|
869
|
+
});
|
|
1027
870
|
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
871
|
+
const template = cf.merge(role);
|
|
872
|
+
if (update) fixtures.update('service-role-url-suffix', template);
|
|
873
|
+
expect(noUndefined(template)).toEqual(fixtures.get('service-role-url-suffix'));
|
|
1031
874
|
});
|
|
1032
875
|
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
fixtures.get('service-role-url-suffix-with-replacement'),
|
|
1039
|
-
'expected resources generated, service for which AWS::URLSuffix is invalid specified with a suffix'
|
|
1040
|
-
);
|
|
876
|
+
test('expected resources generated, service for which AWS::URLSuffix is invalid specified with a suffix', () => {
|
|
877
|
+
const role = new cf.shortcuts.ServiceRole({
|
|
878
|
+
LogicalName: 'MyRole',
|
|
879
|
+
Service: 'ec2.amazonaws.com'
|
|
880
|
+
});
|
|
1041
881
|
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
if (update) fixtures.update('service-role-no-defaults', template);
|
|
1066
|
-
assert.deepEqual(
|
|
1067
|
-
noUndefined(template),
|
|
1068
|
-
fixtures.get('service-role-no-defaults'),
|
|
1069
|
-
'expected resources generated without defaults'
|
|
1070
|
-
);
|
|
882
|
+
const template = cf.merge(role);
|
|
883
|
+
if (update) fixtures.update('service-role-url-suffix-with-replacement', template);
|
|
884
|
+
expect(noUndefined(template)).toEqual(fixtures.get('service-role-url-suffix-with-replacement'));
|
|
885
|
+
});
|
|
886
|
+
|
|
887
|
+
test('expected resources generated without defaults', () => {
|
|
888
|
+
const role = new cf.shortcuts.ServiceRole({
|
|
889
|
+
LogicalName: 'MyRole',
|
|
890
|
+
Service: 'lambda.amazonaws.com',
|
|
891
|
+
Statement: [
|
|
892
|
+
{
|
|
893
|
+
Effect: 'Allow',
|
|
894
|
+
Action: 's3:GetObject',
|
|
895
|
+
Resource: 'arn:aws:s3:::fake/data'
|
|
896
|
+
}
|
|
897
|
+
],
|
|
898
|
+
ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
|
|
899
|
+
MaxSessionDuration: 3600,
|
|
900
|
+
Path: '/fake/',
|
|
901
|
+
RoleName: 'my-role',
|
|
902
|
+
Condition: 'Always',
|
|
903
|
+
DependsOn: 'AnotherThing'
|
|
904
|
+
});
|
|
1071
905
|
|
|
1072
|
-
|
|
906
|
+
const template = cf.merge(
|
|
907
|
+
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
908
|
+
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
909
|
+
role
|
|
910
|
+
);
|
|
911
|
+
if (update) fixtures.update('service-role-no-defaults', template);
|
|
912
|
+
expect(noUndefined(template)).toEqual(fixtures.get('service-role-no-defaults'));
|
|
913
|
+
});
|
|
1073
914
|
});
|
|
1074
915
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
() => new cf.shortcuts.GlueDatabase()
|
|
1078
|
-
|
|
1079
|
-
'throws without options'
|
|
1080
|
-
);
|
|
1081
|
-
assert.throws(
|
|
1082
|
-
() => new cf.shortcuts.GlueDatabase({}),
|
|
1083
|
-
/You must provide a LogicalName and Name/,
|
|
1084
|
-
'throws without required parameters'
|
|
1085
|
-
);
|
|
916
|
+
describe('[shortcuts] glue database', () => {
|
|
917
|
+
test('throws without options', () => {
|
|
918
|
+
expect(() => new cf.shortcuts.GlueDatabase()).toThrow('Options required');
|
|
919
|
+
});
|
|
1086
920
|
|
|
1087
|
-
|
|
1088
|
-
LogicalName
|
|
1089
|
-
Name: 'my_database'
|
|
921
|
+
test('throws without required parameters', () => {
|
|
922
|
+
expect(() => new cf.shortcuts.GlueDatabase({})).toThrow(/You must provide a LogicalName and Name/);
|
|
1090
923
|
});
|
|
1091
924
|
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
'expected resources generated with defaults'
|
|
1098
|
-
);
|
|
925
|
+
test('expected resources generated with defaults', () => {
|
|
926
|
+
const db = new cf.shortcuts.GlueDatabase({
|
|
927
|
+
LogicalName: 'MyDatabase',
|
|
928
|
+
Name: 'my_database'
|
|
929
|
+
});
|
|
1099
930
|
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
if (update) fixtures.update('glue-database-no-defaults', template);
|
|
1117
|
-
assert.deepEqual(
|
|
1118
|
-
noUndefined(template),
|
|
1119
|
-
fixtures.get('glue-database-no-defaults'),
|
|
1120
|
-
'expected resources generated without defaults'
|
|
1121
|
-
);
|
|
931
|
+
const template = cf.merge(db);
|
|
932
|
+
if (update) fixtures.update('glue-database-defaults', template);
|
|
933
|
+
expect(noUndefined(template)).toEqual(fixtures.get('glue-database-defaults'));
|
|
934
|
+
});
|
|
935
|
+
|
|
936
|
+
test('expected resources generated without defaults', () => {
|
|
937
|
+
const db = new cf.shortcuts.GlueDatabase({
|
|
938
|
+
LogicalName: 'MyDatabase',
|
|
939
|
+
Name: 'my_database',
|
|
940
|
+
CatalogId: '123456',
|
|
941
|
+
Description: 'my_database description',
|
|
942
|
+
LocationUri: 'fakeuri',
|
|
943
|
+
Parameters: { thing: 'a' },
|
|
944
|
+
Condition: 'Always',
|
|
945
|
+
DependsOn: 'AnotherThing'
|
|
946
|
+
});
|
|
1122
947
|
|
|
1123
|
-
|
|
948
|
+
const template = cf.merge(
|
|
949
|
+
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
950
|
+
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
951
|
+
db
|
|
952
|
+
);
|
|
953
|
+
if (update) fixtures.update('glue-database-no-defaults', template);
|
|
954
|
+
expect(noUndefined(template)).toEqual(fixtures.get('glue-database-no-defaults'));
|
|
955
|
+
});
|
|
1124
956
|
});
|
|
1125
957
|
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
() => new cf.shortcuts.GlueTable()
|
|
1129
|
-
|
|
1130
|
-
'throws without options'
|
|
1131
|
-
);
|
|
1132
|
-
assert.throws(
|
|
1133
|
-
() => new cf.shortcuts.GlueTable({}),
|
|
1134
|
-
/You must provide a LogicalName, Name, DatabaseName, and Columns/,
|
|
1135
|
-
'throws without required parameters'
|
|
1136
|
-
);
|
|
958
|
+
describe('[shortcuts] glue table', () => {
|
|
959
|
+
test('throws without options', () => {
|
|
960
|
+
expect(() => new cf.shortcuts.GlueTable()).toThrow('Options required');
|
|
961
|
+
});
|
|
1137
962
|
|
|
1138
|
-
|
|
1139
|
-
LogicalName
|
|
1140
|
-
|
|
1141
|
-
Name: 'my_table',
|
|
1142
|
-
Columns: [
|
|
1143
|
-
{ Name: 'column', Type: 'string' }
|
|
1144
|
-
]
|
|
1145
|
-
});
|
|
1146
|
-
|
|
1147
|
-
let template = cf.merge(db);
|
|
1148
|
-
if (update) fixtures.update('glue-table-defaults', template);
|
|
1149
|
-
assert.deepEqual(
|
|
1150
|
-
noUndefined(template),
|
|
1151
|
-
fixtures.get('glue-table-defaults'),
|
|
1152
|
-
'expected resources generated with defaults'
|
|
1153
|
-
);
|
|
963
|
+
test('throws without required parameters', () => {
|
|
964
|
+
expect(() => new cf.shortcuts.GlueTable({})).toThrow(/You must provide a LogicalName, Name, DatabaseName, and Columns/);
|
|
965
|
+
});
|
|
1154
966
|
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
ViewOriginalText: '/* Presto View: abc123= */',
|
|
1170
|
-
BucketColumns: ['column'],
|
|
1171
|
-
Compressed: true,
|
|
1172
|
-
InputFormat: 'fake.input.format',
|
|
1173
|
-
Location: 's3://fake/location',
|
|
1174
|
-
OutputFormat: 'fake.output.format',
|
|
1175
|
-
StorageParameters: { storage: 'parameters' },
|
|
1176
|
-
SerdeInfo: {
|
|
1177
|
-
SerializationLibrary: 'fake.serde'
|
|
1178
|
-
},
|
|
1179
|
-
SkewedColumns: {
|
|
1180
|
-
SkewedColumnNames: ['column'],
|
|
1181
|
-
SkewedColumnValueLocationMap: { fake: 'map' },
|
|
1182
|
-
SkewedColumnValues: ['value']
|
|
1183
|
-
},
|
|
1184
|
-
SortColumns: [
|
|
1185
|
-
{ Column: 'column', SortOrder: 0 }
|
|
1186
|
-
],
|
|
1187
|
-
StoredAsSubdirectory: true,
|
|
1188
|
-
Condition: 'Always',
|
|
1189
|
-
DependsOn: 'AnotherThing'
|
|
1190
|
-
});
|
|
1191
|
-
|
|
1192
|
-
template = cf.merge(
|
|
1193
|
-
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
1194
|
-
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
1195
|
-
db
|
|
1196
|
-
);
|
|
1197
|
-
if (update) fixtures.update('glue-table-no-defaults', template);
|
|
1198
|
-
assert.deepEqual(
|
|
1199
|
-
noUndefined(template),
|
|
1200
|
-
fixtures.get('glue-table-no-defaults'),
|
|
1201
|
-
'expected resources generated without defaults'
|
|
1202
|
-
);
|
|
967
|
+
test('expected resources generated with defaults', () => {
|
|
968
|
+
const db = new cf.shortcuts.GlueTable({
|
|
969
|
+
LogicalName: 'MyTable',
|
|
970
|
+
DatabaseName: 'my_database',
|
|
971
|
+
Name: 'my_table',
|
|
972
|
+
Columns: [
|
|
973
|
+
{ Name: 'column', Type: 'string' }
|
|
974
|
+
]
|
|
975
|
+
});
|
|
976
|
+
|
|
977
|
+
const template = cf.merge(db);
|
|
978
|
+
if (update) fixtures.update('glue-table-defaults', template);
|
|
979
|
+
expect(noUndefined(template)).toEqual(fixtures.get('glue-table-defaults'));
|
|
980
|
+
});
|
|
1203
981
|
|
|
1204
|
-
|
|
982
|
+
test('expected resources generated without defaults', () => {
|
|
983
|
+
const db = new cf.shortcuts.GlueTable({
|
|
984
|
+
LogicalName: 'MyTable',
|
|
985
|
+
DatabaseName: 'my_database',
|
|
986
|
+
Name: 'my_table',
|
|
987
|
+
Columns: [
|
|
988
|
+
{ Name: 'column', Type: 'string' }
|
|
989
|
+
],
|
|
990
|
+
CatalogId: '1234',
|
|
991
|
+
Owner: 'Team',
|
|
992
|
+
Parameters: { table: 'params' },
|
|
993
|
+
Description: 'my_table description',
|
|
994
|
+
Retention: 12,
|
|
995
|
+
TableType: 'EXTERNAL_TABLE',
|
|
996
|
+
ViewExpandedText: '/* Presto View */',
|
|
997
|
+
ViewOriginalText: '/* Presto View: abc123= */',
|
|
998
|
+
BucketColumns: ['column'],
|
|
999
|
+
Compressed: true,
|
|
1000
|
+
InputFormat: 'fake.input.format',
|
|
1001
|
+
Location: 's3://fake/location',
|
|
1002
|
+
OutputFormat: 'fake.output.format',
|
|
1003
|
+
StorageParameters: { storage: 'parameters' },
|
|
1004
|
+
SerdeInfo: {
|
|
1005
|
+
SerializationLibrary: 'fake.serde'
|
|
1006
|
+
},
|
|
1007
|
+
SkewedColumns: {
|
|
1008
|
+
SkewedColumnNames: ['column'],
|
|
1009
|
+
SkewedColumnValueLocationMap: { fake: 'map' },
|
|
1010
|
+
SkewedColumnValues: ['value']
|
|
1011
|
+
},
|
|
1012
|
+
SortColumns: [
|
|
1013
|
+
{ Column: 'column', SortOrder: 0 }
|
|
1014
|
+
],
|
|
1015
|
+
StoredAsSubdirectory: true,
|
|
1016
|
+
Condition: 'Always',
|
|
1017
|
+
DependsOn: 'AnotherThing'
|
|
1018
|
+
});
|
|
1019
|
+
|
|
1020
|
+
const template = cf.merge(
|
|
1021
|
+
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
1022
|
+
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
1023
|
+
db
|
|
1024
|
+
);
|
|
1025
|
+
if (update) fixtures.update('glue-table-no-defaults', template);
|
|
1026
|
+
expect(noUndefined(template)).toEqual(fixtures.get('glue-table-no-defaults'));
|
|
1027
|
+
});
|
|
1205
1028
|
});
|
|
1206
1029
|
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
() => new cf.shortcuts.GlueJsonTable()
|
|
1210
|
-
|
|
1211
|
-
'throws without options'
|
|
1212
|
-
);
|
|
1213
|
-
assert.throws(
|
|
1214
|
-
() => new cf.shortcuts.GlueJsonTable({}),
|
|
1215
|
-
/You must provide a Location/,
|
|
1216
|
-
'throws without required parameters'
|
|
1217
|
-
);
|
|
1030
|
+
describe('[shortcuts] glue json table', () => {
|
|
1031
|
+
test('throws without options', () => {
|
|
1032
|
+
expect(() => new cf.shortcuts.GlueJsonTable()).toThrow('Options required');
|
|
1033
|
+
});
|
|
1218
1034
|
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
Name: 'my_table',
|
|
1223
|
-
Columns: [
|
|
1224
|
-
{ Name: 'column', Type: 'string' }
|
|
1225
|
-
],
|
|
1226
|
-
Location: 's3://fake/location'
|
|
1227
|
-
});
|
|
1228
|
-
|
|
1229
|
-
let template = cf.merge(db);
|
|
1230
|
-
if (update) fixtures.update('glue-json-table-defaults', template);
|
|
1231
|
-
assert.deepEqual(
|
|
1232
|
-
noUndefined(template),
|
|
1233
|
-
fixtures.get('glue-json-table-defaults'),
|
|
1234
|
-
'expected resources generated with defaults'
|
|
1235
|
-
);
|
|
1035
|
+
test('throws without required parameters', () => {
|
|
1036
|
+
expect(() => new cf.shortcuts.GlueJsonTable({})).toThrow(/You must provide a Location/);
|
|
1037
|
+
});
|
|
1236
1038
|
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
Description: 'my_table description',
|
|
1248
|
-
Retention: 12,
|
|
1249
|
-
TableType: 'EXTERNAL_TABLE',
|
|
1250
|
-
ViewExpandedText: '/* Presto View */',
|
|
1251
|
-
ViewOriginalText: '/* Presto View: abc123= */',
|
|
1252
|
-
BucketColumns: ['column'],
|
|
1253
|
-
Compressed: true,
|
|
1254
|
-
Location: 's3://fake/location',
|
|
1255
|
-
InputFormat: 'fake.input.format',
|
|
1256
|
-
OutputFormat: 'fake.output.format',
|
|
1257
|
-
StorageParameters: { storage: 'parameters' },
|
|
1258
|
-
SerdeInfo: {
|
|
1259
|
-
SerializationLibrary: 'fake.serde'
|
|
1260
|
-
},
|
|
1261
|
-
SkewedColumns: {
|
|
1262
|
-
SkewedColumnNames: ['column'],
|
|
1263
|
-
SkewedColumnValueLocationMap: { fake: 'map' },
|
|
1264
|
-
SkewedColumnValues: ['value']
|
|
1265
|
-
},
|
|
1266
|
-
SortColumns: [
|
|
1267
|
-
{ Column: 'column', SortOrder: 0 }
|
|
1268
|
-
],
|
|
1269
|
-
StoredAsSubdirectory: true,
|
|
1270
|
-
Condition: 'Always',
|
|
1271
|
-
DependsOn: 'AnotherThing'
|
|
1272
|
-
});
|
|
1273
|
-
|
|
1274
|
-
template = cf.merge(
|
|
1275
|
-
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
1276
|
-
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
1277
|
-
db
|
|
1278
|
-
);
|
|
1279
|
-
if (update) fixtures.update('glue-json-table-no-defaults', template);
|
|
1280
|
-
assert.deepEqual(
|
|
1281
|
-
noUndefined(template),
|
|
1282
|
-
fixtures.get('glue-json-table-no-defaults'),
|
|
1283
|
-
'expected resources generated without defaults'
|
|
1284
|
-
);
|
|
1039
|
+
test('expected resources generated with defaults', () => {
|
|
1040
|
+
const db = new cf.shortcuts.GlueJsonTable({
|
|
1041
|
+
LogicalName: 'MyTable',
|
|
1042
|
+
DatabaseName: 'my_database',
|
|
1043
|
+
Name: 'my_table',
|
|
1044
|
+
Columns: [
|
|
1045
|
+
{ Name: 'column', Type: 'string' }
|
|
1046
|
+
],
|
|
1047
|
+
Location: 's3://fake/location'
|
|
1048
|
+
});
|
|
1285
1049
|
|
|
1286
|
-
|
|
1050
|
+
const template = cf.merge(db);
|
|
1051
|
+
if (update) fixtures.update('glue-json-table-defaults', template);
|
|
1052
|
+
expect(noUndefined(template)).toEqual(fixtures.get('glue-json-table-defaults'));
|
|
1053
|
+
});
|
|
1054
|
+
|
|
1055
|
+
test('expected resources generated without defaults', () => {
|
|
1056
|
+
const db = new cf.shortcuts.GlueJsonTable({
|
|
1057
|
+
LogicalName: 'MyTable',
|
|
1058
|
+
DatabaseName: 'my_database',
|
|
1059
|
+
Name: 'my_table',
|
|
1060
|
+
Columns: [
|
|
1061
|
+
{ Name: 'column', Type: 'string' }
|
|
1062
|
+
],
|
|
1063
|
+
CatalogId: '1234',
|
|
1064
|
+
Owner: 'Team',
|
|
1065
|
+
Parameters: { table: 'params' },
|
|
1066
|
+
Description: 'my_table description',
|
|
1067
|
+
Retention: 12,
|
|
1068
|
+
TableType: 'EXTERNAL_TABLE',
|
|
1069
|
+
ViewExpandedText: '/* Presto View */',
|
|
1070
|
+
ViewOriginalText: '/* Presto View: abc123= */',
|
|
1071
|
+
BucketColumns: ['column'],
|
|
1072
|
+
Compressed: true,
|
|
1073
|
+
Location: 's3://fake/location',
|
|
1074
|
+
InputFormat: 'fake.input.format',
|
|
1075
|
+
OutputFormat: 'fake.output.format',
|
|
1076
|
+
StorageParameters: { storage: 'parameters' },
|
|
1077
|
+
SerdeInfo: {
|
|
1078
|
+
SerializationLibrary: 'fake.serde'
|
|
1079
|
+
},
|
|
1080
|
+
SkewedColumns: {
|
|
1081
|
+
SkewedColumnNames: ['column'],
|
|
1082
|
+
SkewedColumnValueLocationMap: { fake: 'map' },
|
|
1083
|
+
SkewedColumnValues: ['value']
|
|
1084
|
+
},
|
|
1085
|
+
SortColumns: [
|
|
1086
|
+
{ Column: 'column', SortOrder: 0 }
|
|
1087
|
+
],
|
|
1088
|
+
StoredAsSubdirectory: true,
|
|
1089
|
+
Condition: 'Always',
|
|
1090
|
+
DependsOn: 'AnotherThing'
|
|
1091
|
+
});
|
|
1092
|
+
|
|
1093
|
+
const template = cf.merge(
|
|
1094
|
+
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
1095
|
+
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
1096
|
+
db
|
|
1097
|
+
);
|
|
1098
|
+
if (update) fixtures.update('glue-json-table-no-defaults', template);
|
|
1099
|
+
expect(noUndefined(template)).toEqual(fixtures.get('glue-json-table-no-defaults'));
|
|
1100
|
+
});
|
|
1287
1101
|
});
|
|
1288
1102
|
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
() => new cf.shortcuts.GlueOrcTable()
|
|
1292
|
-
|
|
1293
|
-
'throws without options'
|
|
1294
|
-
);
|
|
1295
|
-
assert.throws(
|
|
1296
|
-
() => new cf.shortcuts.GlueOrcTable({}),
|
|
1297
|
-
/You must provide a Location/,
|
|
1298
|
-
'throws without required parameters'
|
|
1299
|
-
);
|
|
1103
|
+
describe('[shortcuts] glue orc table', () => {
|
|
1104
|
+
test('throws without options', () => {
|
|
1105
|
+
expect(() => new cf.shortcuts.GlueOrcTable()).toThrow('Options required');
|
|
1106
|
+
});
|
|
1300
1107
|
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
Name: 'my_table',
|
|
1305
|
-
Columns: [
|
|
1306
|
-
{ Name: 'column', Type: 'string' }
|
|
1307
|
-
],
|
|
1308
|
-
Location: 's3://fake/location'
|
|
1309
|
-
});
|
|
1310
|
-
|
|
1311
|
-
let template = cf.merge(db);
|
|
1312
|
-
if (update) fixtures.update('glue-orc-table-defaults', template);
|
|
1313
|
-
assert.deepEqual(
|
|
1314
|
-
noUndefined(template),
|
|
1315
|
-
fixtures.get('glue-orc-table-defaults'),
|
|
1316
|
-
'expected resources generated with defaults'
|
|
1317
|
-
);
|
|
1108
|
+
test('throws without required parameters', () => {
|
|
1109
|
+
expect(() => new cf.shortcuts.GlueOrcTable({})).toThrow(/You must provide a Location/);
|
|
1110
|
+
});
|
|
1318
1111
|
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1112
|
+
test('expected resources generated with defaults', () => {
|
|
1113
|
+
const db = new cf.shortcuts.GlueOrcTable({
|
|
1114
|
+
LogicalName: 'MyTable',
|
|
1115
|
+
DatabaseName: 'my_database',
|
|
1116
|
+
Name: 'my_table',
|
|
1117
|
+
Columns: [
|
|
1118
|
+
{ Name: 'column', Type: 'string' }
|
|
1119
|
+
],
|
|
1120
|
+
Location: 's3://fake/location'
|
|
1121
|
+
});
|
|
1122
|
+
|
|
1123
|
+
const template = cf.merge(db);
|
|
1124
|
+
if (update) fixtures.update('glue-orc-table-defaults', template);
|
|
1125
|
+
expect(noUndefined(template)).toEqual(fixtures.get('glue-orc-table-defaults'));
|
|
1126
|
+
});
|
|
1127
|
+
|
|
1128
|
+
test('expected resources generated without defaults', () => {
|
|
1129
|
+
const db = new cf.shortcuts.GlueOrcTable({
|
|
1130
|
+
LogicalName: 'MyTable',
|
|
1131
|
+
DatabaseName: 'my_database',
|
|
1132
|
+
Name: 'my_table',
|
|
1133
|
+
Columns: [
|
|
1134
|
+
{ Name: 'column', Type: 'string' }
|
|
1135
|
+
],
|
|
1136
|
+
CatalogId: '1234',
|
|
1137
|
+
Owner: 'Team',
|
|
1138
|
+
Parameters: { table: 'params' },
|
|
1139
|
+
Description: 'my_table description',
|
|
1140
|
+
Retention: 12,
|
|
1141
|
+
TableType: 'EXTERNAL_TABLE',
|
|
1142
|
+
ViewExpandedText: '/* Presto View */',
|
|
1143
|
+
ViewOriginalText: '/* Presto View: abc123= */',
|
|
1144
|
+
BucketColumns: ['column'],
|
|
1145
|
+
Compressed: true,
|
|
1146
|
+
Location: 's3://fake/location',
|
|
1147
|
+
InputFormat: 'fake.input.format',
|
|
1148
|
+
OutputFormat: 'fake.output.format',
|
|
1149
|
+
StorageParameters: { storage: 'parameters' },
|
|
1150
|
+
SerdeInfo: {
|
|
1151
|
+
SerializationLibrary: 'fake.serde'
|
|
1152
|
+
},
|
|
1153
|
+
SkewedColumns: {
|
|
1154
|
+
SkewedColumnNames: ['column'],
|
|
1155
|
+
SkewedColumnValueLocationMap: { fake: 'map' },
|
|
1156
|
+
SkewedColumnValues: ['value']
|
|
1157
|
+
},
|
|
1158
|
+
SortColumns: [
|
|
1159
|
+
{ Column: 'column', SortOrder: 0 }
|
|
1160
|
+
],
|
|
1161
|
+
StoredAsSubdirectory: true,
|
|
1162
|
+
Condition: 'Always',
|
|
1163
|
+
DependsOn: 'AnotherThing'
|
|
1164
|
+
});
|
|
1367
1165
|
|
|
1368
|
-
|
|
1166
|
+
const template = cf.merge(
|
|
1167
|
+
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
1168
|
+
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
1169
|
+
db
|
|
1170
|
+
);
|
|
1171
|
+
if (update) fixtures.update('glue-orc-table-no-defaults', template);
|
|
1172
|
+
expect(noUndefined(template)).toEqual(fixtures.get('glue-orc-table-no-defaults'));
|
|
1173
|
+
});
|
|
1369
1174
|
});
|
|
1370
1175
|
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
() => new cf.shortcuts.GlueParquetTable()
|
|
1374
|
-
|
|
1375
|
-
'throws without options'
|
|
1376
|
-
);
|
|
1377
|
-
assert.throws(
|
|
1378
|
-
() => new cf.shortcuts.GlueParquetTable({}),
|
|
1379
|
-
/You must provide a Location/,
|
|
1380
|
-
'throws without required parameters'
|
|
1381
|
-
);
|
|
1176
|
+
describe('[shortcuts] glue parquet table', () => {
|
|
1177
|
+
test('throws without options', () => {
|
|
1178
|
+
expect(() => new cf.shortcuts.GlueParquetTable()).toThrow('Options required');
|
|
1179
|
+
});
|
|
1382
1180
|
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
Name: 'my_table',
|
|
1387
|
-
Columns: [
|
|
1388
|
-
{ Name: 'column', Type: 'string' }
|
|
1389
|
-
],
|
|
1390
|
-
Location: 's3://fake/location'
|
|
1391
|
-
});
|
|
1392
|
-
|
|
1393
|
-
let template = cf.merge(db);
|
|
1394
|
-
if (update) fixtures.update('glue-parquet-table-defaults', template);
|
|
1395
|
-
assert.deepEqual(
|
|
1396
|
-
noUndefined(template),
|
|
1397
|
-
fixtures.get('glue-parquet-table-defaults'),
|
|
1398
|
-
'expected resources generated with defaults'
|
|
1399
|
-
);
|
|
1181
|
+
test('throws without required parameters', () => {
|
|
1182
|
+
expect(() => new cf.shortcuts.GlueParquetTable({})).toThrow(/You must provide a Location/);
|
|
1183
|
+
});
|
|
1400
1184
|
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1185
|
+
test('expected resources generated with defaults', () => {
|
|
1186
|
+
const db = new cf.shortcuts.GlueParquetTable({
|
|
1187
|
+
LogicalName: 'MyTable',
|
|
1188
|
+
DatabaseName: 'my_database',
|
|
1189
|
+
Name: 'my_table',
|
|
1190
|
+
Columns: [
|
|
1191
|
+
{ Name: 'column', Type: 'string' }
|
|
1192
|
+
],
|
|
1193
|
+
Location: 's3://fake/location'
|
|
1194
|
+
});
|
|
1195
|
+
|
|
1196
|
+
const template = cf.merge(db);
|
|
1197
|
+
if (update) fixtures.update('glue-parquet-table-defaults', template);
|
|
1198
|
+
expect(noUndefined(template)).toEqual(fixtures.get('glue-parquet-table-defaults'));
|
|
1199
|
+
});
|
|
1200
|
+
|
|
1201
|
+
test('expected resources generated without defaults', () => {
|
|
1202
|
+
const db = new cf.shortcuts.GlueParquetTable({
|
|
1203
|
+
LogicalName: 'MyTable',
|
|
1204
|
+
DatabaseName: 'my_database',
|
|
1205
|
+
Name: 'my_table',
|
|
1206
|
+
Columns: [
|
|
1207
|
+
{ Name: 'column', Type: 'string' }
|
|
1208
|
+
],
|
|
1209
|
+
CatalogId: '1234',
|
|
1210
|
+
Owner: 'Team',
|
|
1211
|
+
Parameters: { table: 'params' },
|
|
1212
|
+
Description: 'my_table description',
|
|
1213
|
+
Retention: 12,
|
|
1214
|
+
TableType: 'EXTERNAL_TABLE',
|
|
1215
|
+
ViewExpandedText: '/* Presto View */',
|
|
1216
|
+
ViewOriginalText: '/* Presto View: abc123= */',
|
|
1217
|
+
BucketColumns: ['column'],
|
|
1218
|
+
Compressed: true,
|
|
1219
|
+
Location: 's3://fake/location',
|
|
1220
|
+
InputFormat: 'fake.input.format',
|
|
1221
|
+
OutputFormat: 'fake.output.format',
|
|
1222
|
+
StorageParameters: { storage: 'parameters' },
|
|
1223
|
+
SerdeInfo: {
|
|
1224
|
+
SerializationLibrary: 'fake.serde'
|
|
1225
|
+
},
|
|
1226
|
+
SkewedColumns: {
|
|
1227
|
+
SkewedColumnNames: ['column'],
|
|
1228
|
+
SkewedColumnValueLocationMap: { fake: 'map' },
|
|
1229
|
+
SkewedColumnValues: ['value']
|
|
1230
|
+
},
|
|
1231
|
+
SortColumns: [
|
|
1232
|
+
{ Column: 'column', SortOrder: 0 }
|
|
1233
|
+
],
|
|
1234
|
+
StoredAsSubdirectory: true,
|
|
1235
|
+
Condition: 'Always',
|
|
1236
|
+
DependsOn: 'AnotherThing'
|
|
1237
|
+
});
|
|
1449
1238
|
|
|
1450
|
-
|
|
1239
|
+
const template = cf.merge(
|
|
1240
|
+
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
1241
|
+
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
1242
|
+
db
|
|
1243
|
+
);
|
|
1244
|
+
if (update) fixtures.update('glue-parquet-table-no-defaults', template);
|
|
1245
|
+
expect(noUndefined(template)).toEqual(fixtures.get('glue-parquet-table-no-defaults'));
|
|
1246
|
+
});
|
|
1451
1247
|
});
|
|
1452
1248
|
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
() => new cf.shortcuts.GluePrestoView()
|
|
1456
|
-
|
|
1457
|
-
'throws without options'
|
|
1458
|
-
);
|
|
1459
|
-
assert.throws(
|
|
1460
|
-
() => new cf.shortcuts.GluePrestoView({}),
|
|
1461
|
-
/You must provide a DatabaseName, Columns, and OriginalSql/,
|
|
1462
|
-
'throws without required parameters'
|
|
1463
|
-
);
|
|
1249
|
+
describe('[shortcuts] glue view', () => {
|
|
1250
|
+
test('throws without options', () => {
|
|
1251
|
+
expect(() => new cf.shortcuts.GluePrestoView()).toThrow('Options required');
|
|
1252
|
+
});
|
|
1464
1253
|
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
Name: 'my_view',
|
|
1469
|
-
Columns: [
|
|
1470
|
-
{ Name: 'column', Type: 'string' }
|
|
1471
|
-
],
|
|
1472
|
-
OriginalSql: 'SELECT * FROM another.table'
|
|
1473
|
-
});
|
|
1474
|
-
|
|
1475
|
-
let template = cf.merge(db);
|
|
1476
|
-
if (update) fixtures.update('glue-view-defaults', template);
|
|
1477
|
-
assert.deepEqual(
|
|
1478
|
-
noUndefined(template),
|
|
1479
|
-
fixtures.get('glue-view-defaults'),
|
|
1480
|
-
'expected resources generated with defaults'
|
|
1481
|
-
);
|
|
1254
|
+
test('throws without required parameters', () => {
|
|
1255
|
+
expect(() => new cf.shortcuts.GluePrestoView({})).toThrow(/You must provide a DatabaseName, Columns, and OriginalSql/);
|
|
1256
|
+
});
|
|
1482
1257
|
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
Parameters: { table: 'params' },
|
|
1494
|
-
Description: 'my_view description',
|
|
1495
|
-
Retention: 12,
|
|
1496
|
-
TableType: 'EXTERNAL_TABLE',
|
|
1497
|
-
BucketColumns: ['column'],
|
|
1498
|
-
Compressed: true,
|
|
1499
|
-
Location: 's3://fake/location',
|
|
1500
|
-
InputFormat: 'fake.input.format',
|
|
1501
|
-
OutputFormat: 'fake.output.format',
|
|
1502
|
-
StorageParameters: { storage: 'parameters' },
|
|
1503
|
-
SerdeInfo: {
|
|
1504
|
-
SerializationLibrary: 'fake.serde'
|
|
1505
|
-
},
|
|
1506
|
-
SkewedColumns: {
|
|
1507
|
-
SkewedColumnNames: ['column'],
|
|
1508
|
-
SkewedColumnValueLocationMap: { fake: 'map' },
|
|
1509
|
-
SkewedColumnValues: ['value']
|
|
1510
|
-
},
|
|
1511
|
-
SortColumns: [
|
|
1512
|
-
{ Column: 'column', SortOrder: 0 }
|
|
1513
|
-
],
|
|
1514
|
-
StoredAsSubdirectory: true,
|
|
1515
|
-
SqlVariables: { env: { Ref: 'AWS::StackName' } },
|
|
1516
|
-
Condition: 'Always',
|
|
1517
|
-
DependsOn: 'AnotherThing'
|
|
1518
|
-
});
|
|
1519
|
-
|
|
1520
|
-
template = cf.merge(
|
|
1521
|
-
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
1522
|
-
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
1523
|
-
db
|
|
1524
|
-
);
|
|
1525
|
-
if (update) fixtures.update('glue-view-no-defaults', template);
|
|
1526
|
-
assert.deepEqual(
|
|
1527
|
-
noUndefined(template),
|
|
1528
|
-
fixtures.get('glue-view-no-defaults'),
|
|
1529
|
-
'expected resources generated without defaults'
|
|
1530
|
-
);
|
|
1258
|
+
test('expected resources generated with defaults', () => {
|
|
1259
|
+
const db = new cf.shortcuts.GluePrestoView({
|
|
1260
|
+
LogicalName: 'MyView',
|
|
1261
|
+
DatabaseName: 'my_database',
|
|
1262
|
+
Name: 'my_view',
|
|
1263
|
+
Columns: [
|
|
1264
|
+
{ Name: 'column', Type: 'string' }
|
|
1265
|
+
],
|
|
1266
|
+
OriginalSql: 'SELECT * FROM another.table'
|
|
1267
|
+
});
|
|
1531
1268
|
|
|
1532
|
-
|
|
1269
|
+
const template = cf.merge(db);
|
|
1270
|
+
if (update) fixtures.update('glue-view-defaults', template);
|
|
1271
|
+
expect(noUndefined(template)).toEqual(fixtures.get('glue-view-defaults'));
|
|
1272
|
+
});
|
|
1273
|
+
|
|
1274
|
+
test('expected resources generated without defaults', () => {
|
|
1275
|
+
const db = new cf.shortcuts.GluePrestoView({
|
|
1276
|
+
LogicalName: 'MyTable',
|
|
1277
|
+
DatabaseName: 'my_database',
|
|
1278
|
+
Name: 'my_view',
|
|
1279
|
+
Columns: [
|
|
1280
|
+
{ Name: 'column', Type: 'string' }
|
|
1281
|
+
],
|
|
1282
|
+
OriginalSql: 'SELECT * FROM another.table',
|
|
1283
|
+
CatalogId: '1234',
|
|
1284
|
+
Owner: 'Team',
|
|
1285
|
+
Parameters: { table: 'params' },
|
|
1286
|
+
Description: 'my_view description',
|
|
1287
|
+
Retention: 12,
|
|
1288
|
+
TableType: 'EXTERNAL_TABLE',
|
|
1289
|
+
BucketColumns: ['column'],
|
|
1290
|
+
Compressed: true,
|
|
1291
|
+
Location: 's3://fake/location',
|
|
1292
|
+
InputFormat: 'fake.input.format',
|
|
1293
|
+
OutputFormat: 'fake.output.format',
|
|
1294
|
+
StorageParameters: { storage: 'parameters' },
|
|
1295
|
+
SerdeInfo: {
|
|
1296
|
+
SerializationLibrary: 'fake.serde'
|
|
1297
|
+
},
|
|
1298
|
+
SkewedColumns: {
|
|
1299
|
+
SkewedColumnNames: ['column'],
|
|
1300
|
+
SkewedColumnValueLocationMap: { fake: 'map' },
|
|
1301
|
+
SkewedColumnValues: ['value']
|
|
1302
|
+
},
|
|
1303
|
+
SortColumns: [
|
|
1304
|
+
{ Column: 'column', SortOrder: 0 }
|
|
1305
|
+
],
|
|
1306
|
+
StoredAsSubdirectory: true,
|
|
1307
|
+
SqlVariables: { env: { Ref: 'AWS::StackName' } },
|
|
1308
|
+
Condition: 'Always',
|
|
1309
|
+
DependsOn: 'AnotherThing'
|
|
1310
|
+
});
|
|
1311
|
+
|
|
1312
|
+
const template = cf.merge(
|
|
1313
|
+
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
1314
|
+
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
1315
|
+
db
|
|
1316
|
+
);
|
|
1317
|
+
if (update) fixtures.update('glue-view-no-defaults', template);
|
|
1318
|
+
expect(noUndefined(template)).toEqual(fixtures.get('glue-view-no-defaults'));
|
|
1319
|
+
});
|
|
1533
1320
|
});
|
|
1534
1321
|
|
|
1535
1322
|
const normalizeDeployment = (template) => {
|
|
@@ -1540,230 +1327,192 @@ const normalizeDeployment = (template) => {
|
|
|
1540
1327
|
return JSON.parse(str);
|
|
1541
1328
|
};
|
|
1542
1329
|
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
() => new cf.shortcuts.hookshot.Passthrough()
|
|
1546
|
-
|
|
1547
|
-
'throws without options'
|
|
1548
|
-
);
|
|
1549
|
-
assert.throws(
|
|
1550
|
-
() => new cf.shortcuts.hookshot.Passthrough({}),
|
|
1551
|
-
/You must provide a Prefix, and PassthroughTo/,
|
|
1552
|
-
'throws without required parameters'
|
|
1553
|
-
);
|
|
1330
|
+
describe('[shortcuts] hookshot passthrough', () => {
|
|
1331
|
+
test('throws without options', () => {
|
|
1332
|
+
expect(() => new cf.shortcuts.hookshot.Passthrough()).toThrow('Options required');
|
|
1333
|
+
});
|
|
1554
1334
|
|
|
1555
|
-
|
|
1556
|
-
() =>
|
|
1557
|
-
|
|
1558
|
-
Prefix: 'Pass',
|
|
1559
|
-
PassthroughTo: 'Destination',
|
|
1560
|
-
LoggingLevel: 'HAM'
|
|
1561
|
-
}),
|
|
1562
|
-
/LoggingLevel must be one of OFF, INFO, or ERROR/,
|
|
1563
|
-
'throws with invalid LoggingLevel'
|
|
1564
|
-
);
|
|
1335
|
+
test('throws without required parameters', () => {
|
|
1336
|
+
expect(() => new cf.shortcuts.hookshot.Passthrough({})).toThrow(/You must provide a Prefix, and PassthroughTo/);
|
|
1337
|
+
});
|
|
1565
1338
|
|
|
1566
|
-
|
|
1567
|
-
() =>
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
}),
|
|
1574
|
-
/Only valid nodejs runtimes are supported for hookshot lambdas, received: 'python3.7'/,
|
|
1575
|
-
'throws with invalid lambda Runtime python3.7'
|
|
1576
|
-
);
|
|
1339
|
+
test('throws with invalid LoggingLevel', () => {
|
|
1340
|
+
expect(() => new cf.shortcuts.hookshot.Passthrough({
|
|
1341
|
+
Prefix: 'Pass',
|
|
1342
|
+
PassthroughTo: 'Destination',
|
|
1343
|
+
LoggingLevel: 'HAM'
|
|
1344
|
+
})).toThrow(/LoggingLevel must be one of OFF, INFO, or ERROR/);
|
|
1345
|
+
});
|
|
1577
1346
|
|
|
1578
|
-
|
|
1579
|
-
() =>
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
/Only nodejs runtimes >= 18 are supported for hookshot lambdas, received: 'nodejs16.x'/,
|
|
1587
|
-
'throws with invalid lambda Runtime nodejs16.x'
|
|
1588
|
-
);
|
|
1347
|
+
test('throws with invalid lambda Runtime python3.7', () => {
|
|
1348
|
+
expect(() => new cf.shortcuts.hookshot.Passthrough({
|
|
1349
|
+
Prefix: 'Pass',
|
|
1350
|
+
PassthroughTo: 'Destination',
|
|
1351
|
+
LoggingLevel: 'INFO',
|
|
1352
|
+
Runtime: 'python3.7'
|
|
1353
|
+
})).toThrow(/Only valid nodejs runtimes are supported for hookshot lambdas, received: 'python3.7'/);
|
|
1354
|
+
});
|
|
1589
1355
|
|
|
1590
|
-
|
|
1356
|
+
test('throws with invalid lambda Runtime nodejs16.x', () => {
|
|
1357
|
+
expect(() => new cf.shortcuts.hookshot.Passthrough({
|
|
1358
|
+
Prefix: 'Pass',
|
|
1359
|
+
PassthroughTo: 'Destination',
|
|
1360
|
+
LoggingLevel: 'INFO',
|
|
1361
|
+
Runtime: 'nodejs16.x'
|
|
1362
|
+
})).toThrow(/Only nodejs runtimes >= 18 are supported for hookshot lambdas, received: 'nodejs16.x'/);
|
|
1363
|
+
});
|
|
1364
|
+
|
|
1365
|
+
const getDestinationLambda = () => new cf.shortcuts.Lambda({
|
|
1591
1366
|
LogicalName: 'Destination',
|
|
1592
1367
|
Code: {
|
|
1593
1368
|
ZipFile: 'module.exports.handler = (e, c, cb) => cb();'
|
|
1594
1369
|
}
|
|
1595
1370
|
});
|
|
1596
1371
|
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1372
|
+
test('expected resources generated with defaults', () => {
|
|
1373
|
+
const to = getDestinationLambda();
|
|
1374
|
+
const passthrough = new cf.shortcuts.hookshot.Passthrough({
|
|
1375
|
+
Prefix: 'Pass',
|
|
1376
|
+
PassthroughTo: 'Destination'
|
|
1377
|
+
});
|
|
1378
|
+
|
|
1379
|
+
const template = cf.merge(passthrough, to);
|
|
1380
|
+
if (update) fixtures.update('hookshot-passthrough', template);
|
|
1381
|
+
expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough')));
|
|
1600
1382
|
});
|
|
1601
1383
|
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1384
|
+
test('expected resources generated with alarm config', () => {
|
|
1385
|
+
const to = getDestinationLambda();
|
|
1386
|
+
const passthrough = new cf.shortcuts.hookshot.Passthrough({
|
|
1387
|
+
Prefix: 'Pass',
|
|
1388
|
+
PassthroughTo: 'Destination',
|
|
1389
|
+
AlarmActions: ['devnull@mapbox.com']
|
|
1390
|
+
});
|
|
1609
1391
|
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
AlarmActions: ['devnull@mapbox.com']
|
|
1392
|
+
const template = cf.merge(passthrough, to);
|
|
1393
|
+
if (update) fixtures.update('hookshot-passthrough-alarms', template);
|
|
1394
|
+
expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-alarms')));
|
|
1614
1395
|
});
|
|
1615
1396
|
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1397
|
+
test('expected resources generated with configured LoggingLevel', () => {
|
|
1398
|
+
const to = getDestinationLambda();
|
|
1399
|
+
const passthrough = new cf.shortcuts.hookshot.Passthrough({
|
|
1400
|
+
Prefix: 'Pass',
|
|
1401
|
+
PassthroughTo: 'Destination',
|
|
1402
|
+
LoggingLevel: 'INFO'
|
|
1403
|
+
});
|
|
1623
1404
|
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
LoggingLevel: 'INFO'
|
|
1405
|
+
const template = cf.merge(passthrough, to);
|
|
1406
|
+
if (update) fixtures.update('hookshot-passthrough-logging', template);
|
|
1407
|
+
expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-logging')));
|
|
1628
1408
|
});
|
|
1629
1409
|
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1410
|
+
test('expected resources generated with detailed logging and metrics', () => {
|
|
1411
|
+
const to = getDestinationLambda();
|
|
1412
|
+
const passthrough = new cf.shortcuts.hookshot.Passthrough({
|
|
1413
|
+
Prefix: 'Pass',
|
|
1414
|
+
PassthroughTo: 'Destination',
|
|
1415
|
+
DataTraceEnabled: true,
|
|
1416
|
+
MetricsEnabled: true
|
|
1417
|
+
});
|
|
1637
1418
|
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
DataTraceEnabled: true,
|
|
1642
|
-
MetricsEnabled: true
|
|
1419
|
+
const template = cf.merge(passthrough, to);
|
|
1420
|
+
if (update) fixtures.update('hookshot-passthrough-enhanced-logging', template);
|
|
1421
|
+
expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-enhanced-logging')));
|
|
1643
1422
|
});
|
|
1644
1423
|
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
passthrough = new cf.shortcuts.hookshot.Passthrough({
|
|
1655
|
-
Prefix: 'Pass',
|
|
1656
|
-
PassthroughTo: 'Destination',
|
|
1657
|
-
DataTraceEnabled: true,
|
|
1658
|
-
MetricsEnabled: true,
|
|
1659
|
-
LoggingLevel: 'INFO'
|
|
1660
|
-
});
|
|
1661
|
-
|
|
1662
|
-
template = cf.merge(passthrough, to);
|
|
1663
|
-
if (update)
|
|
1664
|
-
fixtures.update('hookshot-passthrough-full-blown-logging', template);
|
|
1665
|
-
assert.deepEqual(
|
|
1666
|
-
normalizeDeployment(noUndefined(template)),
|
|
1667
|
-
normalizeDeployment(
|
|
1668
|
-
fixtures.get('hookshot-passthrough-full-blown-logging')
|
|
1669
|
-
),
|
|
1670
|
-
'LoggingLevel respected with detailed logging and metrics'
|
|
1671
|
-
);
|
|
1424
|
+
test('LoggingLevel respected with detailed logging and metrics', () => {
|
|
1425
|
+
const to = getDestinationLambda();
|
|
1426
|
+
const passthrough = new cf.shortcuts.hookshot.Passthrough({
|
|
1427
|
+
Prefix: 'Pass',
|
|
1428
|
+
PassthroughTo: 'Destination',
|
|
1429
|
+
DataTraceEnabled: true,
|
|
1430
|
+
MetricsEnabled: true,
|
|
1431
|
+
LoggingLevel: 'INFO'
|
|
1432
|
+
});
|
|
1672
1433
|
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
AccessLogFormat: '{ "requestId":"$context.requestId" }'
|
|
1434
|
+
const template = cf.merge(passthrough, to);
|
|
1435
|
+
if (update) fixtures.update('hookshot-passthrough-full-blown-logging', template);
|
|
1436
|
+
expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-full-blown-logging')));
|
|
1677
1437
|
});
|
|
1678
1438
|
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
);
|
|
1439
|
+
test('expected resources generated with access logs', () => {
|
|
1440
|
+
const to = getDestinationLambda();
|
|
1441
|
+
const passthrough = new cf.shortcuts.hookshot.Passthrough({
|
|
1442
|
+
Prefix: 'Pass',
|
|
1443
|
+
PassthroughTo: 'Destination',
|
|
1444
|
+
AccessLogFormat: '{ "requestId":"$context.requestId" }'
|
|
1445
|
+
});
|
|
1687
1446
|
|
|
1688
|
-
|
|
1447
|
+
const template = cf.merge(passthrough, to);
|
|
1448
|
+
if (update) fixtures.update('hookshot-passthrough-access-log-format', template);
|
|
1449
|
+
expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-passthrough-access-log-format')));
|
|
1450
|
+
});
|
|
1689
1451
|
});
|
|
1690
1452
|
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
() => new cf.shortcuts.hookshot.Github(),
|
|
1694
|
-
|
|
1695
|
-
'throws without required parameters'
|
|
1696
|
-
);
|
|
1453
|
+
describe('[shortcuts] hookshot github', () => {
|
|
1454
|
+
test('throws without required parameters', () => {
|
|
1455
|
+
expect(() => new cf.shortcuts.hookshot.Github()).toThrow(/You must provide a Prefix, and PassthroughTo/);
|
|
1456
|
+
});
|
|
1697
1457
|
|
|
1698
|
-
|
|
1699
|
-
() =>
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
/Only valid nodejs runtimes are supported for hookshot lambdas, received: 'python3.7'/,
|
|
1706
|
-
'throws with invalid lambda Runtime python3.7'
|
|
1707
|
-
);
|
|
1458
|
+
test('throws with invalid lambda Runtime python3.7', () => {
|
|
1459
|
+
expect(() => new cf.shortcuts.hookshot.Github({
|
|
1460
|
+
Prefix: 'Pass',
|
|
1461
|
+
PassthroughTo: 'Destination',
|
|
1462
|
+
Runtime: 'python3.7'
|
|
1463
|
+
})).toThrow(/Only valid nodejs runtimes are supported for hookshot lambdas, received: 'python3.7'/);
|
|
1464
|
+
});
|
|
1708
1465
|
|
|
1709
|
-
|
|
1710
|
-
() =>
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
/Only nodejs runtimes >= 18 are supported for hookshot lambdas, received: 'nodejs16.x'/,
|
|
1717
|
-
'throws with invalid lambda Runtime nodejs16.x'
|
|
1718
|
-
);
|
|
1466
|
+
test('throws with invalid lambda Runtime nodejs16.x', () => {
|
|
1467
|
+
expect(() => new cf.shortcuts.hookshot.Github({
|
|
1468
|
+
Prefix: 'Pass',
|
|
1469
|
+
PassthroughTo: 'Destination',
|
|
1470
|
+
Runtime: 'nodejs16.x'
|
|
1471
|
+
})).toThrow(/Only nodejs runtimes >= 18 are supported for hookshot lambdas, received: 'nodejs16.x'/);
|
|
1472
|
+
});
|
|
1719
1473
|
|
|
1720
|
-
const
|
|
1474
|
+
const getDestinationLambda = () => new cf.shortcuts.Lambda({
|
|
1721
1475
|
LogicalName: 'Destination',
|
|
1722
1476
|
Code: {
|
|
1723
1477
|
ZipFile: 'module.exports.handler = (e, c, cb) => cb();'
|
|
1724
1478
|
}
|
|
1725
1479
|
});
|
|
1726
1480
|
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
if (update) fixtures.update('hookshot-github', template);
|
|
1734
|
-
assert.deepEqual(
|
|
1735
|
-
normalizeDeployment(noUndefined(template)),
|
|
1736
|
-
normalizeDeployment(fixtures.get('hookshot-github')),
|
|
1737
|
-
'expected resources generated with defaults'
|
|
1738
|
-
);
|
|
1481
|
+
test('expected resources generated with defaults', () => {
|
|
1482
|
+
const to = getDestinationLambda();
|
|
1483
|
+
const github = new cf.shortcuts.hookshot.Github({
|
|
1484
|
+
Prefix: 'Pass',
|
|
1485
|
+
PassthroughTo: 'Destination'
|
|
1486
|
+
});
|
|
1739
1487
|
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
WebhookSecret: 'abc123'
|
|
1488
|
+
const template = cf.merge(github, to);
|
|
1489
|
+
if (update) fixtures.update('hookshot-github', template);
|
|
1490
|
+
expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-github')));
|
|
1744
1491
|
});
|
|
1745
1492
|
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1493
|
+
test('expected resources generated when secret passed as string', () => {
|
|
1494
|
+
const to = getDestinationLambda();
|
|
1495
|
+
const github = new cf.shortcuts.hookshot.Github({
|
|
1496
|
+
Prefix: 'Pass',
|
|
1497
|
+
PassthroughTo: 'Destination',
|
|
1498
|
+
WebhookSecret: 'abc123'
|
|
1499
|
+
});
|
|
1753
1500
|
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
});
|
|
1759
|
-
const Parameters = { SomeParameter: { Type: 'String' } };
|
|
1760
|
-
template = cf.merge(github, to, { Parameters });
|
|
1761
|
-
if (update) fixtures.update('hookshot-github-secret-ref', template);
|
|
1762
|
-
assert.deepEqual(
|
|
1763
|
-
normalizeDeployment(noUndefined(template)),
|
|
1764
|
-
normalizeDeployment(fixtures.get('hookshot-github-secret-ref')),
|
|
1765
|
-
'expected resources generated when secret passed as ref'
|
|
1766
|
-
);
|
|
1501
|
+
const template = cf.merge(github, to);
|
|
1502
|
+
if (update) fixtures.update('hookshot-github-secret-string', template);
|
|
1503
|
+
expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-github-secret-string')));
|
|
1504
|
+
});
|
|
1767
1505
|
|
|
1768
|
-
|
|
1506
|
+
test('expected resources generated when secret passed as ref', () => {
|
|
1507
|
+
const to = getDestinationLambda();
|
|
1508
|
+
const github = new cf.shortcuts.hookshot.Github({
|
|
1509
|
+
Prefix: 'Pass',
|
|
1510
|
+
PassthroughTo: 'Destination',
|
|
1511
|
+
WebhookSecret: cf.ref('SomeParameter')
|
|
1512
|
+
});
|
|
1513
|
+
const Parameters = { SomeParameter: { Type: 'String' } };
|
|
1514
|
+
const template = cf.merge(github, to, { Parameters });
|
|
1515
|
+
if (update) fixtures.update('hookshot-github-secret-ref', template);
|
|
1516
|
+
expect(normalizeDeployment(noUndefined(template))).toEqual(normalizeDeployment(fixtures.get('hookshot-github-secret-ref')));
|
|
1517
|
+
});
|
|
1769
1518
|
});
|