@mapbox/cloudfriend 9.2.0-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 +8 -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/lib/shortcuts/api.md +1 -0
- package/lib/shortcuts/lambda.js +4 -2
- 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 +3 -1
- package/test/fixtures/shortcuts/event-lambda-full.json +3 -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 +8 -4
- package/test/fixtures/shortcuts/hookshot-github-secret-string.json +8 -4
- package/test/fixtures/shortcuts/hookshot-github.json +8 -4
- package/test/fixtures/shortcuts/hookshot-passthrough-access-log-format.json +8 -4
- package/test/fixtures/shortcuts/hookshot-passthrough-alarms.json +8 -4
- package/test/fixtures/shortcuts/hookshot-passthrough-enhanced-logging.json +8 -4
- package/test/fixtures/shortcuts/hookshot-passthrough-full-blown-logging.json +8 -4
- package/test/fixtures/shortcuts/hookshot-passthrough-logging.json +8 -4
- package/test/fixtures/shortcuts/hookshot-passthrough.json +8 -4
- package/test/fixtures/shortcuts/lambda-defaults.json +3 -1
- package/test/fixtures/shortcuts/lambda-docker.json +3 -1
- package/test/fixtures/shortcuts/lambda-full.json +3 -1
- package/test/fixtures/shortcuts/lambda-provided-role.json +3 -1
- package/test/fixtures/shortcuts/lambda-zipfile.json +3 -1
- package/test/fixtures/shortcuts/log-subscription-lambda-defaults.json +3 -1
- package/test/fixtures/shortcuts/log-subscription-lambda-no-defaults.json +3 -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 +3 -1
- package/test/fixtures/shortcuts/queue-lambda.json +3 -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 +3 -1
- package/test/fixtures/shortcuts/scheduled-lambda-full.json +3 -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 +3 -1
- package/test/fixtures/shortcuts/stream-lambda-no-defaults.json +3 -1
- package/test/index.test.js +383 -235
- package/test/shortcuts.test.js +1227 -1462
- package/.nyc_output/0030e99c-2d96-4ac6-a2b2-bffd93da01bc.json +0 -1
- package/.nyc_output/e1868cff-0dd0-46eb-866d-70c3b666dae8.json +0 -1
- package/.nyc_output/processinfo/0030e99c-2d96-4ac6-a2b2-bffd93da01bc.json +0 -1
- package/.nyc_output/processinfo/e1868cff-0dd0-46eb-866d-70c3b666dae8.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,453 +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
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
noUndefined(template)
|
|
217
|
-
|
|
218
|
-
|
|
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
|
+
});
|
|
185
|
+
|
|
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'));
|
|
193
|
+
});
|
|
194
|
+
|
|
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
|
+
});
|
|
220
204
|
|
|
221
|
-
|
|
205
|
+
const template = cf.merge(lambda);
|
|
206
|
+
expect(template.Resources.MyLambdaLogPolicy.Properties.PolicyName).toBe('CustomLogPolicyName');
|
|
207
|
+
});
|
|
222
208
|
});
|
|
223
209
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
() => new cf.shortcuts.QueueLambda()
|
|
227
|
-
|
|
228
|
-
'throws without options'
|
|
229
|
-
);
|
|
230
|
-
assert.throws(
|
|
231
|
-
() => new cf.shortcuts.QueueLambda({}),
|
|
232
|
-
/You must provide a LogicalName, and Code/,
|
|
233
|
-
'throws without basic lambda required parameters'
|
|
234
|
-
);
|
|
210
|
+
describe('[shortcuts] queue-lambda', () => {
|
|
211
|
+
test('throws without options', () => {
|
|
212
|
+
expect(() => new cf.shortcuts.QueueLambda()).toThrow('Options required');
|
|
213
|
+
});
|
|
235
214
|
|
|
236
|
-
|
|
237
|
-
() =>
|
|
238
|
-
|
|
239
|
-
LogicalName: 'MyLambda',
|
|
240
|
-
Code: {
|
|
241
|
-
S3Bucket: 'my-code-bucket',
|
|
242
|
-
S3Key: 'path/to/code.zip'
|
|
243
|
-
}
|
|
244
|
-
}),
|
|
245
|
-
/You must provide an EventSourceArn and ReservedConcurrentExecutions/,
|
|
246
|
-
'throws without queue-lambda required parameters'
|
|
247
|
-
);
|
|
215
|
+
test('throws without basic lambda required parameters', () => {
|
|
216
|
+
expect(() => new cf.shortcuts.QueueLambda({})).toThrow(/You must provide a LogicalName, and Code/);
|
|
217
|
+
});
|
|
248
218
|
|
|
249
|
-
|
|
250
|
-
() =>
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
ReservedConcurrentExecutions: -1
|
|
259
|
-
}),
|
|
260
|
-
/ReservedConcurrentExecutions must be greater than or equal to 0/,
|
|
261
|
-
'throws when ReservedConcurrentExecutions is a negative number'
|
|
262
|
-
);
|
|
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
|
+
});
|
|
263
228
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
assert.deepEqual(
|
|
276
|
-
noUndefined(zeroTemplate),
|
|
277
|
-
fixtures.get('queue-lambda-zero'),
|
|
278
|
-
'expected resources generated'
|
|
279
|
-
);
|
|
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
|
+
});
|
|
280
240
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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
|
+
});
|
|
298
266
|
|
|
299
|
-
|
|
267
|
+
const template = cf.merge(lambda);
|
|
268
|
+
if (update) fixtures.update('queue-lambda', template);
|
|
269
|
+
expect(noUndefined(template)).toEqual(fixtures.get('queue-lambda'));
|
|
270
|
+
});
|
|
300
271
|
});
|
|
301
272
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
() => new cf.shortcuts.ScheduledLambda()
|
|
305
|
-
|
|
306
|
-
'throws without options'
|
|
307
|
-
);
|
|
308
|
-
assert.throws(
|
|
309
|
-
() => new cf.shortcuts.ScheduledLambda({}),
|
|
310
|
-
/You must provide a LogicalName, and Code/,
|
|
311
|
-
'throws without basic lambda required parameters'
|
|
312
|
-
);
|
|
273
|
+
describe('[shortcuts] scheduled-lambda', () => {
|
|
274
|
+
test('throws without options', () => {
|
|
275
|
+
expect(() => new cf.shortcuts.ScheduledLambda()).toThrow('Options required');
|
|
276
|
+
});
|
|
313
277
|
|
|
314
|
-
|
|
315
|
-
() =>
|
|
316
|
-
|
|
317
|
-
LogicalName: 'MyLambda',
|
|
318
|
-
Code: {
|
|
319
|
-
S3Bucket: 'my-code-bucket',
|
|
320
|
-
S3Key: 'path/to/code.zip'
|
|
321
|
-
}
|
|
322
|
-
}),
|
|
323
|
-
/You must provide a ScheduleExpression/,
|
|
324
|
-
'throws without scheduled-lambda required parameters'
|
|
325
|
-
);
|
|
278
|
+
test('throws without basic lambda required parameters', () => {
|
|
279
|
+
expect(() => new cf.shortcuts.ScheduledLambda({})).toThrow(/You must provide a LogicalName, and Code/);
|
|
280
|
+
});
|
|
326
281
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
let template = cf.merge(lambda);
|
|
337
|
-
if (update) fixtures.update('scheduled-lambda-defaults', template);
|
|
338
|
-
assert.deepEqual(
|
|
339
|
-
noUndefined(template),
|
|
340
|
-
fixtures.get('scheduled-lambda-defaults'),
|
|
341
|
-
'expected resources generated with defaults'
|
|
342
|
-
);
|
|
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
|
+
});
|
|
343
291
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
State: 'DISABLED'
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
template = cf.merge(lambda);
|
|
357
|
-
if (update) fixtures.update('scheduled-lambda-full', template);
|
|
358
|
-
assert.deepEqual(
|
|
359
|
-
noUndefined(template),
|
|
360
|
-
fixtures.get('scheduled-lambda-full'),
|
|
361
|
-
'expected resources generated without defaults'
|
|
362
|
-
);
|
|
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
|
+
});
|
|
363
301
|
|
|
364
|
-
|
|
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
|
+
});
|
|
365
324
|
});
|
|
366
325
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
() => new cf.shortcuts.EventLambda()
|
|
370
|
-
|
|
371
|
-
'throws without options'
|
|
372
|
-
);
|
|
373
|
-
assert.throws(
|
|
374
|
-
() => new cf.shortcuts.EventLambda({}),
|
|
375
|
-
/You must provide a LogicalName, and Code/,
|
|
376
|
-
'throws without basic lambda required parameters'
|
|
377
|
-
);
|
|
326
|
+
describe('[shortcuts] event-lambda', () => {
|
|
327
|
+
test('throws without options', () => {
|
|
328
|
+
expect(() => new cf.shortcuts.EventLambda()).toThrow('Options required');
|
|
329
|
+
});
|
|
378
330
|
|
|
379
|
-
|
|
380
|
-
() =>
|
|
381
|
-
|
|
382
|
-
LogicalName: 'MyLambda',
|
|
383
|
-
Code: {
|
|
384
|
-
S3Bucket: 'my-code-bucket',
|
|
385
|
-
S3Key: 'path/to/code.zip'
|
|
386
|
-
}
|
|
387
|
-
}),
|
|
388
|
-
/You must provide an EventPattern/,
|
|
389
|
-
'throws without event-lambda required parameters'
|
|
390
|
-
);
|
|
331
|
+
test('throws without basic lambda required parameters', () => {
|
|
332
|
+
expect(() => new cf.shortcuts.EventLambda({})).toThrow(/You must provide a LogicalName, and Code/);
|
|
333
|
+
});
|
|
391
334
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
EventPattern: {
|
|
399
|
-
source: ['aws.ec2'],
|
|
400
|
-
'detail-type': ['EC2 Instance State-change Notification'],
|
|
401
|
-
detail: {
|
|
402
|
-
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'
|
|
403
341
|
}
|
|
404
|
-
}
|
|
342
|
+
})).toThrow(/You must provide an EventPattern/);
|
|
405
343
|
});
|
|
406
344
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
},
|
|
421
|
-
EventPattern: {
|
|
422
|
-
source: ['aws.ec2'],
|
|
423
|
-
'detail-type': ['EC2 Instance State-change Notification'],
|
|
424
|
-
detail: {
|
|
425
|
-
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
|
+
}
|
|
426
358
|
}
|
|
427
|
-
}
|
|
428
|
-
|
|
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'));
|
|
429
364
|
});
|
|
430
365
|
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
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
|
+
});
|
|
438
382
|
|
|
439
|
-
|
|
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
|
+
});
|
|
440
387
|
});
|
|
441
388
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
() => new cf.shortcuts.StreamLambda()
|
|
445
|
-
|
|
446
|
-
'throws without options'
|
|
447
|
-
);
|
|
448
|
-
assert.throws(
|
|
449
|
-
() => new cf.shortcuts.StreamLambda({}),
|
|
450
|
-
/You must provide a LogicalName, and Code/,
|
|
451
|
-
'throws without basic lambda required parameters'
|
|
452
|
-
);
|
|
389
|
+
describe('[shortcuts] stream-lambda', () => {
|
|
390
|
+
test('throws without options', () => {
|
|
391
|
+
expect(() => new cf.shortcuts.StreamLambda()).toThrow('Options required');
|
|
392
|
+
});
|
|
453
393
|
|
|
454
|
-
|
|
455
|
-
() =>
|
|
456
|
-
|
|
457
|
-
LogicalName: 'MyLambda',
|
|
458
|
-
Code: {
|
|
459
|
-
S3Bucket: 'my-code-bucket',
|
|
460
|
-
S3Key: 'path/to/code.zip'
|
|
461
|
-
}
|
|
462
|
-
}),
|
|
463
|
-
/You must provide an EventSourceArn/,
|
|
464
|
-
'throws without stream-lambda required parameters'
|
|
465
|
-
);
|
|
394
|
+
test('throws without basic lambda required parameters', () => {
|
|
395
|
+
expect(() => new cf.shortcuts.StreamLambda({})).toThrow(/You must provide a LogicalName, and Code/);
|
|
396
|
+
});
|
|
466
397
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
let template = cf.merge(lambda);
|
|
477
|
-
if (update) fixtures.update('stream-lambda-defaults', template);
|
|
478
|
-
assert.deepEqual(
|
|
479
|
-
noUndefined(template),
|
|
480
|
-
fixtures.get('stream-lambda-defaults'),
|
|
481
|
-
'expected resources generated via defaults'
|
|
482
|
-
);
|
|
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
|
+
});
|
|
483
407
|
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
BatchSize: 10000,
|
|
499
|
-
MaximumBatchingWindowInSeconds: 300,
|
|
500
|
-
Enabled: false,
|
|
501
|
-
StartingPosition: 'TRIM_HORIZON'
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
template = cf.merge(lambda);
|
|
505
|
-
if (update) fixtures.update('stream-lambda-no-defaults', template);
|
|
506
|
-
assert.deepEqual(
|
|
507
|
-
noUndefined(template),
|
|
508
|
-
fixtures.get('stream-lambda-no-defaults'),
|
|
509
|
-
'expected resources generated without defaults'
|
|
510
|
-
);
|
|
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
|
+
});
|
|
511
422
|
|
|
512
|
-
|
|
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
|
+
});
|
|
513
448
|
});
|
|
514
449
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
() => new cf.shortcuts.StreamLambda({
|
|
450
|
+
describe('[shortcuts] StreamLambda FilterCriteria', () => {
|
|
451
|
+
test('FilterCriteria must be a JSON-like object', () => {
|
|
452
|
+
expect(() => new cf.shortcuts.StreamLambda({
|
|
518
453
|
LogicalName: 'MyLambda',
|
|
519
454
|
Code: {
|
|
520
455
|
S3Bucket: 'my-code-bucket',
|
|
@@ -522,11 +457,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
|
|
|
522
457
|
},
|
|
523
458
|
EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
|
|
524
459
|
FilterCriteria: ['test']
|
|
525
|
-
})
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
() => new cf.shortcuts.StreamLambda({
|
|
460
|
+
})).toThrow();
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
test('FilterCriteria must contain property Filter of type array', () => {
|
|
464
|
+
expect(() => new cf.shortcuts.StreamLambda({
|
|
530
465
|
LogicalName: 'MyLambda',
|
|
531
466
|
Code: {
|
|
532
467
|
S3Bucket: 'my-code-bucket',
|
|
@@ -534,11 +469,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
|
|
|
534
469
|
},
|
|
535
470
|
EventSourceArn: 'arn:aws:kinesis:us-east-1:123456789012:stream/fake',
|
|
536
471
|
FilterCriteria: {}
|
|
537
|
-
})
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
() => new cf.shortcuts.StreamLambda({
|
|
472
|
+
})).toThrow();
|
|
473
|
+
});
|
|
474
|
+
|
|
475
|
+
test('FilterCriteria.Filter must be an array', () => {
|
|
476
|
+
expect(() => new cf.shortcuts.StreamLambda({
|
|
542
477
|
LogicalName: 'MyLambda',
|
|
543
478
|
Code: {
|
|
544
479
|
S3Bucket: 'my-code-bucket',
|
|
@@ -548,11 +483,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
|
|
|
548
483
|
FilterCriteria: {
|
|
549
484
|
Filter: 613
|
|
550
485
|
}
|
|
551
|
-
})
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
() => new cf.shortcuts.StreamLambda({
|
|
486
|
+
})).toThrow();
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
test('FilterCriteria.Filter objects must have Pattern property', () => {
|
|
490
|
+
expect(() => new cf.shortcuts.StreamLambda({
|
|
556
491
|
LogicalName: 'MyLambda',
|
|
557
492
|
Code: {
|
|
558
493
|
S3Bucket: 'my-code-bucket',
|
|
@@ -569,11 +504,11 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
|
|
|
569
504
|
}
|
|
570
505
|
]
|
|
571
506
|
}
|
|
572
|
-
})
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
() => new cf.shortcuts.StreamLambda({
|
|
507
|
+
})).toThrow();
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
test('FilterCriteria.Filter Pattern must be JSON parseable string', () => {
|
|
511
|
+
expect(() => new cf.shortcuts.StreamLambda({
|
|
577
512
|
LogicalName: 'MyLambda',
|
|
578
513
|
Code: {
|
|
579
514
|
S3Bucket: 'my-code-bucket',
|
|
@@ -590,930 +525,798 @@ test('[shortcuts] StreamLambda FilterCriteria', (assert) => {
|
|
|
590
525
|
}
|
|
591
526
|
]
|
|
592
527
|
}
|
|
593
|
-
})
|
|
594
|
-
|
|
595
|
-
);
|
|
596
|
-
assert.end();
|
|
528
|
+
})).toThrow();
|
|
529
|
+
});
|
|
597
530
|
});
|
|
598
531
|
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
() => new cf.shortcuts.LogSubscriptionLambda()
|
|
602
|
-
|
|
603
|
-
'throws without options'
|
|
604
|
-
);
|
|
605
|
-
assert.throws(
|
|
606
|
-
() => new cf.shortcuts.LogSubscriptionLambda({}),
|
|
607
|
-
/You must provide a LogicalName, and Code/,
|
|
608
|
-
'throws without basic lambda required parameters'
|
|
609
|
-
);
|
|
532
|
+
describe('[shortcuts] log-subscription-lambda', () => {
|
|
533
|
+
test('throws without options', () => {
|
|
534
|
+
expect(() => new cf.shortcuts.LogSubscriptionLambda()).toThrow('Options required');
|
|
535
|
+
});
|
|
610
536
|
|
|
611
|
-
|
|
612
|
-
() =>
|
|
613
|
-
|
|
614
|
-
LogicalName: 'MyLambda',
|
|
615
|
-
Code: {
|
|
616
|
-
S3Bucket: 'my-code-bucket',
|
|
617
|
-
S3Key: 'path/to/code.zip'
|
|
618
|
-
}
|
|
619
|
-
}),
|
|
620
|
-
/You must provide a LogGroupName/,
|
|
621
|
-
'throws without log-subscription-lambda required parameters'
|
|
622
|
-
);
|
|
537
|
+
test('throws without basic lambda required parameters', () => {
|
|
538
|
+
expect(() => new cf.shortcuts.LogSubscriptionLambda({})).toThrow(/You must provide a LogicalName, and Code/);
|
|
539
|
+
});
|
|
623
540
|
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
let template = cf.merge(lambda);
|
|
634
|
-
if (update) fixtures.update('log-subscription-lambda-defaults', template);
|
|
635
|
-
assert.deepEqual(
|
|
636
|
-
noUndefined(template),
|
|
637
|
-
fixtures.get('log-subscription-lambda-defaults'),
|
|
638
|
-
'expected resources generated via defaults'
|
|
639
|
-
);
|
|
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
|
+
});
|
|
640
550
|
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
template = cf.merge(lambda);
|
|
652
|
-
if (update) fixtures.update('log-subscription-lambda-no-defaults', template);
|
|
653
|
-
assert.deepEqual(
|
|
654
|
-
noUndefined(template),
|
|
655
|
-
fixtures.get('log-subscription-lambda-no-defaults'),
|
|
656
|
-
'expected resources generated without defaults'
|
|
657
|
-
);
|
|
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
|
+
});
|
|
658
560
|
|
|
659
|
-
|
|
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
|
+
});
|
|
660
581
|
});
|
|
661
582
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
() => new cf.shortcuts.Queue()
|
|
665
|
-
|
|
666
|
-
'throws without options'
|
|
667
|
-
);
|
|
668
|
-
assert.throws(
|
|
669
|
-
() => new cf.shortcuts.Queue({}),
|
|
670
|
-
/You must provide a LogicalName/,
|
|
671
|
-
'throws without required parameters'
|
|
672
|
-
);
|
|
583
|
+
describe('[shortcuts] queue', () => {
|
|
584
|
+
test('throws without options', () => {
|
|
585
|
+
expect(() => new cf.shortcuts.Queue()).toThrow('Options required');
|
|
586
|
+
});
|
|
673
587
|
|
|
674
|
-
|
|
675
|
-
LogicalName
|
|
588
|
+
test('throws without required parameters', () => {
|
|
589
|
+
expect(() => new cf.shortcuts.Queue({})).toThrow(/You must provide a LogicalName/);
|
|
676
590
|
});
|
|
677
591
|
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
fixtures.get('queue-defaults'),
|
|
683
|
-
'expected resources generated for full defaults'
|
|
684
|
-
);
|
|
592
|
+
test('expected resources generated for full defaults', () => {
|
|
593
|
+
const queue = new cf.shortcuts.Queue({
|
|
594
|
+
LogicalName: 'MyQueue'
|
|
595
|
+
});
|
|
685
596
|
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
DelaySeconds: 60,
|
|
691
|
-
KmsMasterKeyId: 'alias/my-key',
|
|
692
|
-
KmsDataKeyReusePeriondSeconds: 86400,
|
|
693
|
-
MaximumMessageSize: 1024,
|
|
694
|
-
MessageRetentionPeriod: 60,
|
|
695
|
-
QueueName: 'my-queue',
|
|
696
|
-
ReceiveMessageWaitTimeSeconds: 20,
|
|
697
|
-
Condition: 'Always',
|
|
698
|
-
DependsOn: 'AnotherThing',
|
|
699
|
-
TopicName: 'my-topic',
|
|
700
|
-
DisplayName: 'topic-display-name',
|
|
701
|
-
DeadLetterVisibilityTimeout: 60
|
|
702
|
-
});
|
|
703
|
-
|
|
704
|
-
template = cf.merge(
|
|
705
|
-
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
706
|
-
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
707
|
-
queue
|
|
708
|
-
);
|
|
709
|
-
if (update) fixtures.update('queue-full', template);
|
|
710
|
-
assert.deepEqual(
|
|
711
|
-
noUndefined(template),
|
|
712
|
-
fixtures.get('queue-full'),
|
|
713
|
-
'expected resources generated no defaults'
|
|
714
|
-
);
|
|
597
|
+
const template = cf.merge(queue);
|
|
598
|
+
if (update) fixtures.update('queue-defaults', template);
|
|
599
|
+
expect(noUndefined(template)).toEqual(fixtures.get('queue-defaults'));
|
|
600
|
+
});
|
|
715
601
|
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
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'));
|
|
719
628
|
});
|
|
720
|
-
template = cf.merge(queue);
|
|
721
|
-
if (update) fixtures.update('queue-external-topic', template);
|
|
722
|
-
assert.deepEqual(
|
|
723
|
-
noUndefined(template),
|
|
724
|
-
fixtures.get('queue-external-topic'),
|
|
725
|
-
'expected resources generated for external topic'
|
|
726
|
-
);
|
|
727
629
|
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
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'));
|
|
731
638
|
});
|
|
732
|
-
template = cf.merge(
|
|
733
|
-
{ Resources: { TopicForOtherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
734
|
-
queue
|
|
735
|
-
);
|
|
736
|
-
if (update) fixtures.update('queue-external-topic-ref', template);
|
|
737
|
-
assert.deepEqual(
|
|
738
|
-
noUndefined(template),
|
|
739
|
-
fixtures.get('queue-external-topic-ref'),
|
|
740
|
-
'expected resources generated for external topic identified by ref'
|
|
741
|
-
);
|
|
742
639
|
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
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'));
|
|
746
651
|
});
|
|
747
|
-
template = cf.merge(queue);
|
|
748
|
-
if (update) fixtures.update('queue-fifo', template);
|
|
749
|
-
assert.deepEqual(
|
|
750
|
-
noUndefined(template),
|
|
751
|
-
fixtures.get('queue-fifo'),
|
|
752
|
-
'expected resources generated for FIFO queue'
|
|
753
|
-
);
|
|
754
652
|
|
|
755
|
-
queue
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
fixtures.get('queue-fifo-queuename'),
|
|
765
|
-
'expected resources generated for FIFO queue with specified QueueName'
|
|
766
|
-
);
|
|
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
|
+
});
|
|
767
662
|
|
|
768
|
-
queue
|
|
769
|
-
|
|
770
|
-
|
|
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'));
|
|
771
672
|
});
|
|
772
|
-
template = cf.merge(queue);
|
|
773
|
-
assert.equal(
|
|
774
|
-
template.Resources.MyFifoFalseQueue.Properties.FifoQueue,
|
|
775
|
-
undefined,
|
|
776
|
-
'the FifoQueue value false is converted to undefined, to pass CFN validation'
|
|
777
|
-
);
|
|
778
673
|
|
|
779
|
-
|
|
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
|
+
});
|
|
780
682
|
});
|
|
781
683
|
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
() => new cf.shortcuts.S3KinesisFirehose()
|
|
785
|
-
|
|
786
|
-
'throws without options'
|
|
787
|
-
);
|
|
788
|
-
assert.throws(
|
|
789
|
-
() => new cf.shortcuts.S3KinesisFirehose({}),
|
|
790
|
-
/You must provide a LogicalName/,
|
|
791
|
-
'throws without required LogicalName parameter'
|
|
792
|
-
);
|
|
684
|
+
describe('[shortcuts] s3 kinesis firehose', () => {
|
|
685
|
+
test('throws without options', () => {
|
|
686
|
+
expect(() => new cf.shortcuts.S3KinesisFirehose()).toThrow('Options required');
|
|
687
|
+
});
|
|
793
688
|
|
|
794
|
-
|
|
795
|
-
() => new cf.shortcuts.S3KinesisFirehose({
|
|
796
|
-
|
|
797
|
-
}),
|
|
798
|
-
/You must provide a DestinationBucket/,
|
|
799
|
-
'throws without required DestinationBucket parameter'
|
|
800
|
-
);
|
|
689
|
+
test('throws without required LogicalName parameter', () => {
|
|
690
|
+
expect(() => new cf.shortcuts.S3KinesisFirehose({})).toThrow(/You must provide a LogicalName/);
|
|
691
|
+
});
|
|
801
692
|
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
693
|
+
test('throws without required DestinationBucket parameter', () => {
|
|
694
|
+
expect(() => new cf.shortcuts.S3KinesisFirehose({
|
|
695
|
+
LogicalName: 'MyKinesisFirehose'
|
|
696
|
+
})).toThrow(/You must provide a DestinationBucket/);
|
|
805
697
|
});
|
|
806
698
|
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
'expected resources generated for full defaults'
|
|
813
|
-
);
|
|
699
|
+
test('expected resources generated for full defaults', () => {
|
|
700
|
+
const firehose = new cf.shortcuts.S3KinesisFirehose({
|
|
701
|
+
LogicalName: 'MyKinesisFirehose',
|
|
702
|
+
DestinationBucket: 'mah-bukkit'
|
|
703
|
+
});
|
|
814
704
|
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
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'));
|
|
819
708
|
});
|
|
820
709
|
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
assert.deepEqual(
|
|
828
|
-
noUndefined(template),
|
|
829
|
-
fixtures.get('firehose-with-stream'),
|
|
830
|
-
'expected resources generated with stream'
|
|
831
|
-
);
|
|
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
|
+
});
|
|
832
716
|
|
|
833
|
-
|
|
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
|
+
});
|
|
834
725
|
});
|
|
835
726
|
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
() => new cf.shortcuts.Role()
|
|
839
|
-
|
|
840
|
-
'throws without options'
|
|
841
|
-
);
|
|
842
|
-
assert.throws(
|
|
843
|
-
() => new cf.shortcuts.Role({}),
|
|
844
|
-
/You must provide a LogicalName and AssumeRolePrincipals/,
|
|
845
|
-
'throws without required parameters'
|
|
846
|
-
);
|
|
727
|
+
describe('[shortcuts] role', () => {
|
|
728
|
+
test('throws without options', () => {
|
|
729
|
+
expect(() => new cf.shortcuts.Role()).toThrow('Options required');
|
|
730
|
+
});
|
|
847
731
|
|
|
848
|
-
|
|
849
|
-
LogicalName
|
|
850
|
-
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/);
|
|
851
734
|
});
|
|
852
735
|
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
'expected resources generated with defaults'
|
|
859
|
-
);
|
|
736
|
+
test('expected resources generated with defaults', () => {
|
|
737
|
+
const role = new cf.shortcuts.Role({
|
|
738
|
+
LogicalName: 'MyRole',
|
|
739
|
+
AssumeRolePrincipals: [{ Service: 'ec2.amazonaws.com' }]
|
|
740
|
+
});
|
|
860
741
|
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
{
|
|
866
|
-
Effect: 'Allow',
|
|
867
|
-
Action: 's3:GetObject',
|
|
868
|
-
Resource: 'arn:aws:s3:::fake/data'
|
|
869
|
-
}
|
|
870
|
-
],
|
|
871
|
-
ManagedPolicyArns: ['arn:aws:iam::123456789012:policy/fake'],
|
|
872
|
-
MaxSessionDuration: 3600,
|
|
873
|
-
Path: '/fake/',
|
|
874
|
-
RoleName: 'my-role',
|
|
875
|
-
Tags: [{ Key: 'pipeline-name', Value: 'test' }],
|
|
876
|
-
Condition: 'Always',
|
|
877
|
-
DependsOn: 'AnotherThing'
|
|
878
|
-
});
|
|
879
|
-
|
|
880
|
-
template = cf.merge(
|
|
881
|
-
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
882
|
-
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
883
|
-
role
|
|
884
|
-
);
|
|
885
|
-
if (update) fixtures.update('role-no-defaults', template);
|
|
886
|
-
assert.deepEqual(
|
|
887
|
-
noUndefined(template),
|
|
888
|
-
fixtures.get('role-no-defaults'),
|
|
889
|
-
'expected resources generated without defaults'
|
|
890
|
-
);
|
|
742
|
+
const template = cf.merge(role);
|
|
743
|
+
if (update) fixtures.update('role-defaults', template);
|
|
744
|
+
expect(noUndefined(template)).toEqual(fixtures.get('role-defaults'));
|
|
745
|
+
});
|
|
891
746
|
|
|
892
|
-
|
|
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
|
+
});
|
|
893
775
|
});
|
|
894
776
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
() => new cf.shortcuts.CrossAccountRole()
|
|
898
|
-
|
|
899
|
-
'throws without options'
|
|
900
|
-
);
|
|
901
|
-
assert.throws(
|
|
902
|
-
() => new cf.shortcuts.CrossAccountRole({}),
|
|
903
|
-
/You must provide a LogicalName and Accounts/,
|
|
904
|
-
'throws without required parameters'
|
|
905
|
-
);
|
|
777
|
+
describe('[shortcuts] cross-account role', () => {
|
|
778
|
+
test('throws without options', () => {
|
|
779
|
+
expect(() => new cf.shortcuts.CrossAccountRole()).toThrow('Options required');
|
|
780
|
+
});
|
|
906
781
|
|
|
907
|
-
|
|
908
|
-
LogicalName
|
|
909
|
-
|
|
910
|
-
'123456789012',
|
|
911
|
-
'arn:aws:iam::123456789012:root',
|
|
912
|
-
{ 'Fn::Sub': 'arn:aws:iam::${AWS::AccountId}:root' }
|
|
913
|
-
]
|
|
914
|
-
});
|
|
915
|
-
|
|
916
|
-
let template = cf.merge(role);
|
|
917
|
-
if (update) fixtures.update('cross-account-role-defaults', template);
|
|
918
|
-
assert.deepEqual(
|
|
919
|
-
noUndefined(template),
|
|
920
|
-
fixtures.get('cross-account-role-defaults'),
|
|
921
|
-
'expected resources generated with defaults'
|
|
922
|
-
);
|
|
782
|
+
test('throws without required parameters', () => {
|
|
783
|
+
expect(() => new cf.shortcuts.CrossAccountRole({})).toThrow(/You must provide a LogicalName and Accounts/);
|
|
784
|
+
});
|
|
923
785
|
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
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
|
+
});
|
|
957
823
|
|
|
958
|
-
|
|
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
|
+
});
|
|
959
832
|
});
|
|
960
833
|
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
() => new cf.shortcuts.ServiceRole()
|
|
964
|
-
|
|
965
|
-
'throws without options'
|
|
966
|
-
);
|
|
967
|
-
assert.throws(
|
|
968
|
-
() => new cf.shortcuts.ServiceRole({}),
|
|
969
|
-
/You must provide a LogicalName and Service/,
|
|
970
|
-
'throws without required parameters'
|
|
971
|
-
);
|
|
834
|
+
describe('[shortcuts] service role', () => {
|
|
835
|
+
test('throws without options', () => {
|
|
836
|
+
expect(() => new cf.shortcuts.ServiceRole()).toThrow('Options required');
|
|
837
|
+
});
|
|
972
838
|
|
|
973
|
-
|
|
974
|
-
LogicalName
|
|
975
|
-
Service: 'lambda'
|
|
839
|
+
test('throws without required parameters', () => {
|
|
840
|
+
expect(() => new cf.shortcuts.ServiceRole({})).toThrow(/You must provide a LogicalName and Service/);
|
|
976
841
|
});
|
|
977
842
|
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
'expected resources generated with defaults'
|
|
984
|
-
);
|
|
843
|
+
test('expected resources generated with defaults', () => {
|
|
844
|
+
const role = new cf.shortcuts.ServiceRole({
|
|
845
|
+
LogicalName: 'MyRole',
|
|
846
|
+
Service: 'lambda'
|
|
847
|
+
});
|
|
985
848
|
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
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'));
|
|
989
852
|
});
|
|
990
853
|
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
'expected resources generated, service for which AWS::URLSuffix is invalid'
|
|
997
|
-
);
|
|
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
|
+
});
|
|
998
859
|
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
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'));
|
|
1002
863
|
});
|
|
1003
864
|
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
'expected resources generated, service for which AWS::URLSuffix is invalid'
|
|
1010
|
-
);
|
|
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
|
+
});
|
|
1011
870
|
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
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'));
|
|
1015
874
|
});
|
|
1016
875
|
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
fixtures.get('service-role-url-suffix-with-replacement'),
|
|
1023
|
-
'expected resources generated, service for which AWS::URLSuffix is invalid specified with a suffix'
|
|
1024
|
-
);
|
|
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
|
+
});
|
|
1025
881
|
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
if (update) fixtures.update('service-role-no-defaults', template);
|
|
1050
|
-
assert.deepEqual(
|
|
1051
|
-
noUndefined(template),
|
|
1052
|
-
fixtures.get('service-role-no-defaults'),
|
|
1053
|
-
'expected resources generated without defaults'
|
|
1054
|
-
);
|
|
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
|
+
});
|
|
1055
905
|
|
|
1056
|
-
|
|
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
|
+
});
|
|
1057
914
|
});
|
|
1058
915
|
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
() => new cf.shortcuts.GlueDatabase()
|
|
1062
|
-
|
|
1063
|
-
'throws without options'
|
|
1064
|
-
);
|
|
1065
|
-
assert.throws(
|
|
1066
|
-
() => new cf.shortcuts.GlueDatabase({}),
|
|
1067
|
-
/You must provide a LogicalName and Name/,
|
|
1068
|
-
'throws without required parameters'
|
|
1069
|
-
);
|
|
916
|
+
describe('[shortcuts] glue database', () => {
|
|
917
|
+
test('throws without options', () => {
|
|
918
|
+
expect(() => new cf.shortcuts.GlueDatabase()).toThrow('Options required');
|
|
919
|
+
});
|
|
1070
920
|
|
|
1071
|
-
|
|
1072
|
-
LogicalName
|
|
1073
|
-
Name: 'my_database'
|
|
921
|
+
test('throws without required parameters', () => {
|
|
922
|
+
expect(() => new cf.shortcuts.GlueDatabase({})).toThrow(/You must provide a LogicalName and Name/);
|
|
1074
923
|
});
|
|
1075
924
|
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
'expected resources generated with defaults'
|
|
1082
|
-
);
|
|
925
|
+
test('expected resources generated with defaults', () => {
|
|
926
|
+
const db = new cf.shortcuts.GlueDatabase({
|
|
927
|
+
LogicalName: 'MyDatabase',
|
|
928
|
+
Name: 'my_database'
|
|
929
|
+
});
|
|
1083
930
|
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
if (update) fixtures.update('glue-database-no-defaults', template);
|
|
1101
|
-
assert.deepEqual(
|
|
1102
|
-
noUndefined(template),
|
|
1103
|
-
fixtures.get('glue-database-no-defaults'),
|
|
1104
|
-
'expected resources generated without defaults'
|
|
1105
|
-
);
|
|
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
|
+
});
|
|
1106
947
|
|
|
1107
|
-
|
|
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
|
+
});
|
|
1108
956
|
});
|
|
1109
957
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
() => new cf.shortcuts.GlueTable()
|
|
1113
|
-
|
|
1114
|
-
'throws without options'
|
|
1115
|
-
);
|
|
1116
|
-
assert.throws(
|
|
1117
|
-
() => new cf.shortcuts.GlueTable({}),
|
|
1118
|
-
/You must provide a LogicalName, Name, DatabaseName, and Columns/,
|
|
1119
|
-
'throws without required parameters'
|
|
1120
|
-
);
|
|
958
|
+
describe('[shortcuts] glue table', () => {
|
|
959
|
+
test('throws without options', () => {
|
|
960
|
+
expect(() => new cf.shortcuts.GlueTable()).toThrow('Options required');
|
|
961
|
+
});
|
|
1121
962
|
|
|
1122
|
-
|
|
1123
|
-
LogicalName
|
|
1124
|
-
|
|
1125
|
-
Name: 'my_table',
|
|
1126
|
-
Columns: [
|
|
1127
|
-
{ Name: 'column', Type: 'string' }
|
|
1128
|
-
]
|
|
1129
|
-
});
|
|
1130
|
-
|
|
1131
|
-
let template = cf.merge(db);
|
|
1132
|
-
if (update) fixtures.update('glue-table-defaults', template);
|
|
1133
|
-
assert.deepEqual(
|
|
1134
|
-
noUndefined(template),
|
|
1135
|
-
fixtures.get('glue-table-defaults'),
|
|
1136
|
-
'expected resources generated with defaults'
|
|
1137
|
-
);
|
|
963
|
+
test('throws without required parameters', () => {
|
|
964
|
+
expect(() => new cf.shortcuts.GlueTable({})).toThrow(/You must provide a LogicalName, Name, DatabaseName, and Columns/);
|
|
965
|
+
});
|
|
1138
966
|
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
ViewOriginalText: '/* Presto View: abc123= */',
|
|
1154
|
-
BucketColumns: ['column'],
|
|
1155
|
-
Compressed: true,
|
|
1156
|
-
InputFormat: 'fake.input.format',
|
|
1157
|
-
Location: 's3://fake/location',
|
|
1158
|
-
OutputFormat: 'fake.output.format',
|
|
1159
|
-
StorageParameters: { storage: 'parameters' },
|
|
1160
|
-
SerdeInfo: {
|
|
1161
|
-
SerializationLibrary: 'fake.serde'
|
|
1162
|
-
},
|
|
1163
|
-
SkewedColumns: {
|
|
1164
|
-
SkewedColumnNames: ['column'],
|
|
1165
|
-
SkewedColumnValueLocationMap: { fake: 'map' },
|
|
1166
|
-
SkewedColumnValues: ['value']
|
|
1167
|
-
},
|
|
1168
|
-
SortColumns: [
|
|
1169
|
-
{ Column: 'column', SortOrder: 0 }
|
|
1170
|
-
],
|
|
1171
|
-
StoredAsSubdirectory: true,
|
|
1172
|
-
Condition: 'Always',
|
|
1173
|
-
DependsOn: 'AnotherThing'
|
|
1174
|
-
});
|
|
1175
|
-
|
|
1176
|
-
template = cf.merge(
|
|
1177
|
-
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
1178
|
-
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
1179
|
-
db
|
|
1180
|
-
);
|
|
1181
|
-
if (update) fixtures.update('glue-table-no-defaults', template);
|
|
1182
|
-
assert.deepEqual(
|
|
1183
|
-
noUndefined(template),
|
|
1184
|
-
fixtures.get('glue-table-no-defaults'),
|
|
1185
|
-
'expected resources generated without defaults'
|
|
1186
|
-
);
|
|
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
|
+
});
|
|
1187
981
|
|
|
1188
|
-
|
|
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
|
+
});
|
|
1189
1028
|
});
|
|
1190
1029
|
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
() => new cf.shortcuts.GlueJsonTable()
|
|
1194
|
-
|
|
1195
|
-
'throws without options'
|
|
1196
|
-
);
|
|
1197
|
-
assert.throws(
|
|
1198
|
-
() => new cf.shortcuts.GlueJsonTable({}),
|
|
1199
|
-
/You must provide a Location/,
|
|
1200
|
-
'throws without required parameters'
|
|
1201
|
-
);
|
|
1030
|
+
describe('[shortcuts] glue json table', () => {
|
|
1031
|
+
test('throws without options', () => {
|
|
1032
|
+
expect(() => new cf.shortcuts.GlueJsonTable()).toThrow('Options required');
|
|
1033
|
+
});
|
|
1202
1034
|
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
Name: 'my_table',
|
|
1207
|
-
Columns: [
|
|
1208
|
-
{ Name: 'column', Type: 'string' }
|
|
1209
|
-
],
|
|
1210
|
-
Location: 's3://fake/location'
|
|
1211
|
-
});
|
|
1212
|
-
|
|
1213
|
-
let template = cf.merge(db);
|
|
1214
|
-
if (update) fixtures.update('glue-json-table-defaults', template);
|
|
1215
|
-
assert.deepEqual(
|
|
1216
|
-
noUndefined(template),
|
|
1217
|
-
fixtures.get('glue-json-table-defaults'),
|
|
1218
|
-
'expected resources generated with defaults'
|
|
1219
|
-
);
|
|
1035
|
+
test('throws without required parameters', () => {
|
|
1036
|
+
expect(() => new cf.shortcuts.GlueJsonTable({})).toThrow(/You must provide a Location/);
|
|
1037
|
+
});
|
|
1220
1038
|
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
Description: 'my_table description',
|
|
1232
|
-
Retention: 12,
|
|
1233
|
-
TableType: 'EXTERNAL_TABLE',
|
|
1234
|
-
ViewExpandedText: '/* Presto View */',
|
|
1235
|
-
ViewOriginalText: '/* Presto View: abc123= */',
|
|
1236
|
-
BucketColumns: ['column'],
|
|
1237
|
-
Compressed: true,
|
|
1238
|
-
Location: 's3://fake/location',
|
|
1239
|
-
InputFormat: 'fake.input.format',
|
|
1240
|
-
OutputFormat: 'fake.output.format',
|
|
1241
|
-
StorageParameters: { storage: 'parameters' },
|
|
1242
|
-
SerdeInfo: {
|
|
1243
|
-
SerializationLibrary: 'fake.serde'
|
|
1244
|
-
},
|
|
1245
|
-
SkewedColumns: {
|
|
1246
|
-
SkewedColumnNames: ['column'],
|
|
1247
|
-
SkewedColumnValueLocationMap: { fake: 'map' },
|
|
1248
|
-
SkewedColumnValues: ['value']
|
|
1249
|
-
},
|
|
1250
|
-
SortColumns: [
|
|
1251
|
-
{ Column: 'column', SortOrder: 0 }
|
|
1252
|
-
],
|
|
1253
|
-
StoredAsSubdirectory: true,
|
|
1254
|
-
Condition: 'Always',
|
|
1255
|
-
DependsOn: 'AnotherThing'
|
|
1256
|
-
});
|
|
1257
|
-
|
|
1258
|
-
template = cf.merge(
|
|
1259
|
-
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
1260
|
-
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
1261
|
-
db
|
|
1262
|
-
);
|
|
1263
|
-
if (update) fixtures.update('glue-json-table-no-defaults', template);
|
|
1264
|
-
assert.deepEqual(
|
|
1265
|
-
noUndefined(template),
|
|
1266
|
-
fixtures.get('glue-json-table-no-defaults'),
|
|
1267
|
-
'expected resources generated without defaults'
|
|
1268
|
-
);
|
|
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
|
+
});
|
|
1269
1049
|
|
|
1270
|
-
|
|
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
|
+
});
|
|
1271
1101
|
});
|
|
1272
1102
|
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
() => new cf.shortcuts.GlueOrcTable()
|
|
1276
|
-
|
|
1277
|
-
'throws without options'
|
|
1278
|
-
);
|
|
1279
|
-
assert.throws(
|
|
1280
|
-
() => new cf.shortcuts.GlueOrcTable({}),
|
|
1281
|
-
/You must provide a Location/,
|
|
1282
|
-
'throws without required parameters'
|
|
1283
|
-
);
|
|
1103
|
+
describe('[shortcuts] glue orc table', () => {
|
|
1104
|
+
test('throws without options', () => {
|
|
1105
|
+
expect(() => new cf.shortcuts.GlueOrcTable()).toThrow('Options required');
|
|
1106
|
+
});
|
|
1284
1107
|
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
Name: 'my_table',
|
|
1289
|
-
Columns: [
|
|
1290
|
-
{ Name: 'column', Type: 'string' }
|
|
1291
|
-
],
|
|
1292
|
-
Location: 's3://fake/location'
|
|
1293
|
-
});
|
|
1294
|
-
|
|
1295
|
-
let template = cf.merge(db);
|
|
1296
|
-
if (update) fixtures.update('glue-orc-table-defaults', template);
|
|
1297
|
-
assert.deepEqual(
|
|
1298
|
-
noUndefined(template),
|
|
1299
|
-
fixtures.get('glue-orc-table-defaults'),
|
|
1300
|
-
'expected resources generated with defaults'
|
|
1301
|
-
);
|
|
1108
|
+
test('throws without required parameters', () => {
|
|
1109
|
+
expect(() => new cf.shortcuts.GlueOrcTable({})).toThrow(/You must provide a Location/);
|
|
1110
|
+
});
|
|
1302
1111
|
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
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
|
-
|
|
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
|
+
});
|
|
1351
1165
|
|
|
1352
|
-
|
|
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
|
+
});
|
|
1353
1174
|
});
|
|
1354
1175
|
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
() => new cf.shortcuts.GlueParquetTable()
|
|
1358
|
-
|
|
1359
|
-
'throws without options'
|
|
1360
|
-
);
|
|
1361
|
-
assert.throws(
|
|
1362
|
-
() => new cf.shortcuts.GlueParquetTable({}),
|
|
1363
|
-
/You must provide a Location/,
|
|
1364
|
-
'throws without required parameters'
|
|
1365
|
-
);
|
|
1176
|
+
describe('[shortcuts] glue parquet table', () => {
|
|
1177
|
+
test('throws without options', () => {
|
|
1178
|
+
expect(() => new cf.shortcuts.GlueParquetTable()).toThrow('Options required');
|
|
1179
|
+
});
|
|
1366
1180
|
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
Name: 'my_table',
|
|
1371
|
-
Columns: [
|
|
1372
|
-
{ Name: 'column', Type: 'string' }
|
|
1373
|
-
],
|
|
1374
|
-
Location: 's3://fake/location'
|
|
1375
|
-
});
|
|
1376
|
-
|
|
1377
|
-
let template = cf.merge(db);
|
|
1378
|
-
if (update) fixtures.update('glue-parquet-table-defaults', template);
|
|
1379
|
-
assert.deepEqual(
|
|
1380
|
-
noUndefined(template),
|
|
1381
|
-
fixtures.get('glue-parquet-table-defaults'),
|
|
1382
|
-
'expected resources generated with defaults'
|
|
1383
|
-
);
|
|
1181
|
+
test('throws without required parameters', () => {
|
|
1182
|
+
expect(() => new cf.shortcuts.GlueParquetTable({})).toThrow(/You must provide a Location/);
|
|
1183
|
+
});
|
|
1384
1184
|
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
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
|
-
|
|
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
|
+
});
|
|
1433
1238
|
|
|
1434
|
-
|
|
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
|
+
});
|
|
1435
1247
|
});
|
|
1436
1248
|
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
() => new cf.shortcuts.GluePrestoView()
|
|
1440
|
-
|
|
1441
|
-
'throws without options'
|
|
1442
|
-
);
|
|
1443
|
-
assert.throws(
|
|
1444
|
-
() => new cf.shortcuts.GluePrestoView({}),
|
|
1445
|
-
/You must provide a DatabaseName, Columns, and OriginalSql/,
|
|
1446
|
-
'throws without required parameters'
|
|
1447
|
-
);
|
|
1249
|
+
describe('[shortcuts] glue view', () => {
|
|
1250
|
+
test('throws without options', () => {
|
|
1251
|
+
expect(() => new cf.shortcuts.GluePrestoView()).toThrow('Options required');
|
|
1252
|
+
});
|
|
1448
1253
|
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
Name: 'my_view',
|
|
1453
|
-
Columns: [
|
|
1454
|
-
{ Name: 'column', Type: 'string' }
|
|
1455
|
-
],
|
|
1456
|
-
OriginalSql: 'SELECT * FROM another.table'
|
|
1457
|
-
});
|
|
1458
|
-
|
|
1459
|
-
let template = cf.merge(db);
|
|
1460
|
-
if (update) fixtures.update('glue-view-defaults', template);
|
|
1461
|
-
assert.deepEqual(
|
|
1462
|
-
noUndefined(template),
|
|
1463
|
-
fixtures.get('glue-view-defaults'),
|
|
1464
|
-
'expected resources generated with defaults'
|
|
1465
|
-
);
|
|
1254
|
+
test('throws without required parameters', () => {
|
|
1255
|
+
expect(() => new cf.shortcuts.GluePrestoView({})).toThrow(/You must provide a DatabaseName, Columns, and OriginalSql/);
|
|
1256
|
+
});
|
|
1466
1257
|
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
Parameters: { table: 'params' },
|
|
1478
|
-
Description: 'my_view description',
|
|
1479
|
-
Retention: 12,
|
|
1480
|
-
TableType: 'EXTERNAL_TABLE',
|
|
1481
|
-
BucketColumns: ['column'],
|
|
1482
|
-
Compressed: true,
|
|
1483
|
-
Location: 's3://fake/location',
|
|
1484
|
-
InputFormat: 'fake.input.format',
|
|
1485
|
-
OutputFormat: 'fake.output.format',
|
|
1486
|
-
StorageParameters: { storage: 'parameters' },
|
|
1487
|
-
SerdeInfo: {
|
|
1488
|
-
SerializationLibrary: 'fake.serde'
|
|
1489
|
-
},
|
|
1490
|
-
SkewedColumns: {
|
|
1491
|
-
SkewedColumnNames: ['column'],
|
|
1492
|
-
SkewedColumnValueLocationMap: { fake: 'map' },
|
|
1493
|
-
SkewedColumnValues: ['value']
|
|
1494
|
-
},
|
|
1495
|
-
SortColumns: [
|
|
1496
|
-
{ Column: 'column', SortOrder: 0 }
|
|
1497
|
-
],
|
|
1498
|
-
StoredAsSubdirectory: true,
|
|
1499
|
-
SqlVariables: { env: { Ref: 'AWS::StackName' } },
|
|
1500
|
-
Condition: 'Always',
|
|
1501
|
-
DependsOn: 'AnotherThing'
|
|
1502
|
-
});
|
|
1503
|
-
|
|
1504
|
-
template = cf.merge(
|
|
1505
|
-
{ Conditions: { Always: cf.equals('1', '1') } },
|
|
1506
|
-
{ Resources: { AnotherThing: { Type: 'AWS::SNS::Topic' } } },
|
|
1507
|
-
db
|
|
1508
|
-
);
|
|
1509
|
-
if (update) fixtures.update('glue-view-no-defaults', template);
|
|
1510
|
-
assert.deepEqual(
|
|
1511
|
-
noUndefined(template),
|
|
1512
|
-
fixtures.get('glue-view-no-defaults'),
|
|
1513
|
-
'expected resources generated without defaults'
|
|
1514
|
-
);
|
|
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
|
+
});
|
|
1515
1268
|
|
|
1516
|
-
|
|
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
|
+
});
|
|
1517
1320
|
});
|
|
1518
1321
|
|
|
1519
1322
|
const normalizeDeployment = (template) => {
|
|
@@ -1524,230 +1327,192 @@ const normalizeDeployment = (template) => {
|
|
|
1524
1327
|
return JSON.parse(str);
|
|
1525
1328
|
};
|
|
1526
1329
|
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
() => new cf.shortcuts.hookshot.Passthrough()
|
|
1530
|
-
|
|
1531
|
-
'throws without options'
|
|
1532
|
-
);
|
|
1533
|
-
assert.throws(
|
|
1534
|
-
() => new cf.shortcuts.hookshot.Passthrough({}),
|
|
1535
|
-
/You must provide a Prefix, and PassthroughTo/,
|
|
1536
|
-
'throws without required parameters'
|
|
1537
|
-
);
|
|
1330
|
+
describe('[shortcuts] hookshot passthrough', () => {
|
|
1331
|
+
test('throws without options', () => {
|
|
1332
|
+
expect(() => new cf.shortcuts.hookshot.Passthrough()).toThrow('Options required');
|
|
1333
|
+
});
|
|
1538
1334
|
|
|
1539
|
-
|
|
1540
|
-
() =>
|
|
1541
|
-
|
|
1542
|
-
Prefix: 'Pass',
|
|
1543
|
-
PassthroughTo: 'Destination',
|
|
1544
|
-
LoggingLevel: 'HAM'
|
|
1545
|
-
}),
|
|
1546
|
-
/LoggingLevel must be one of OFF, INFO, or ERROR/,
|
|
1547
|
-
'throws with invalid LoggingLevel'
|
|
1548
|
-
);
|
|
1335
|
+
test('throws without required parameters', () => {
|
|
1336
|
+
expect(() => new cf.shortcuts.hookshot.Passthrough({})).toThrow(/You must provide a Prefix, and PassthroughTo/);
|
|
1337
|
+
});
|
|
1549
1338
|
|
|
1550
|
-
|
|
1551
|
-
() =>
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
}),
|
|
1558
|
-
/Only valid nodejs runtimes are supported for hookshot lambdas, received: 'python3.7'/,
|
|
1559
|
-
'throws with invalid lambda Runtime python3.7'
|
|
1560
|
-
);
|
|
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
|
+
});
|
|
1561
1346
|
|
|
1562
|
-
|
|
1563
|
-
() =>
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
/Only nodejs runtimes >= 18 are supported for hookshot lambdas, received: 'nodejs16.x'/,
|
|
1571
|
-
'throws with invalid lambda Runtime nodejs16.x'
|
|
1572
|
-
);
|
|
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
|
+
});
|
|
1573
1355
|
|
|
1574
|
-
|
|
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({
|
|
1575
1366
|
LogicalName: 'Destination',
|
|
1576
1367
|
Code: {
|
|
1577
1368
|
ZipFile: 'module.exports.handler = (e, c, cb) => cb();'
|
|
1578
1369
|
}
|
|
1579
1370
|
});
|
|
1580
1371
|
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
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')));
|
|
1584
1382
|
});
|
|
1585
1383
|
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
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
|
+
});
|
|
1593
1391
|
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
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')));
|
|
1598
1395
|
});
|
|
1599
1396
|
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
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
|
+
});
|
|
1607
1404
|
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
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')));
|
|
1612
1408
|
});
|
|
1613
1409
|
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
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
|
+
});
|
|
1621
1418
|
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
DataTraceEnabled: true,
|
|
1626
|
-
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')));
|
|
1627
1422
|
});
|
|
1628
1423
|
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
passthrough = new cf.shortcuts.hookshot.Passthrough({
|
|
1639
|
-
Prefix: 'Pass',
|
|
1640
|
-
PassthroughTo: 'Destination',
|
|
1641
|
-
DataTraceEnabled: true,
|
|
1642
|
-
MetricsEnabled: true,
|
|
1643
|
-
LoggingLevel: 'INFO'
|
|
1644
|
-
});
|
|
1645
|
-
|
|
1646
|
-
template = cf.merge(passthrough, to);
|
|
1647
|
-
if (update)
|
|
1648
|
-
fixtures.update('hookshot-passthrough-full-blown-logging', template);
|
|
1649
|
-
assert.deepEqual(
|
|
1650
|
-
normalizeDeployment(noUndefined(template)),
|
|
1651
|
-
normalizeDeployment(
|
|
1652
|
-
fixtures.get('hookshot-passthrough-full-blown-logging')
|
|
1653
|
-
),
|
|
1654
|
-
'LoggingLevel respected with detailed logging and metrics'
|
|
1655
|
-
);
|
|
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
|
+
});
|
|
1656
1433
|
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
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')));
|
|
1661
1437
|
});
|
|
1662
1438
|
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
);
|
|
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
|
+
});
|
|
1671
1446
|
|
|
1672
|
-
|
|
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
|
+
});
|
|
1673
1451
|
});
|
|
1674
1452
|
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
() => new cf.shortcuts.hookshot.Github(),
|
|
1678
|
-
|
|
1679
|
-
'throws without required parameters'
|
|
1680
|
-
);
|
|
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
|
+
});
|
|
1681
1457
|
|
|
1682
|
-
|
|
1683
|
-
() =>
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
/Only valid nodejs runtimes are supported for hookshot lambdas, received: 'python3.7'/,
|
|
1690
|
-
'throws with invalid lambda Runtime python3.7'
|
|
1691
|
-
);
|
|
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
|
+
});
|
|
1692
1465
|
|
|
1693
|
-
|
|
1694
|
-
() =>
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
/Only nodejs runtimes >= 18 are supported for hookshot lambdas, received: 'nodejs16.x'/,
|
|
1701
|
-
'throws with invalid lambda Runtime nodejs16.x'
|
|
1702
|
-
);
|
|
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
|
+
});
|
|
1703
1473
|
|
|
1704
|
-
const
|
|
1474
|
+
const getDestinationLambda = () => new cf.shortcuts.Lambda({
|
|
1705
1475
|
LogicalName: 'Destination',
|
|
1706
1476
|
Code: {
|
|
1707
1477
|
ZipFile: 'module.exports.handler = (e, c, cb) => cb();'
|
|
1708
1478
|
}
|
|
1709
1479
|
});
|
|
1710
1480
|
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
if (update) fixtures.update('hookshot-github', template);
|
|
1718
|
-
assert.deepEqual(
|
|
1719
|
-
normalizeDeployment(noUndefined(template)),
|
|
1720
|
-
normalizeDeployment(fixtures.get('hookshot-github')),
|
|
1721
|
-
'expected resources generated with defaults'
|
|
1722
|
-
);
|
|
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
|
+
});
|
|
1723
1487
|
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
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')));
|
|
1728
1491
|
});
|
|
1729
1492
|
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
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
|
+
});
|
|
1737
1500
|
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
});
|
|
1743
|
-
const Parameters = { SomeParameter: { Type: 'String' } };
|
|
1744
|
-
template = cf.merge(github, to, { Parameters });
|
|
1745
|
-
if (update) fixtures.update('hookshot-github-secret-ref', template);
|
|
1746
|
-
assert.deepEqual(
|
|
1747
|
-
normalizeDeployment(noUndefined(template)),
|
|
1748
|
-
normalizeDeployment(fixtures.get('hookshot-github-secret-ref')),
|
|
1749
|
-
'expected resources generated when secret passed as ref'
|
|
1750
|
-
);
|
|
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
|
+
});
|
|
1751
1505
|
|
|
1752
|
-
|
|
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
|
+
});
|
|
1753
1518
|
});
|