@friggframework/devtools 2.0.0--canary.701.32f702a.0 → 2.0.0--canary.662.6d3931c.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/frigg-cli/README.md +31 -123
- package/frigg-cli/__tests__/unit/commands/build.test.js +0 -3
- package/frigg-cli/__tests__/unit/commands/deploy.test.js +24 -33
- package/frigg-cli/__tests__/unit/commands/doctor.test.js +6 -10
- package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
- package/frigg-cli/__tests__/unit/commands/install.test.js +341 -601
- package/frigg-cli/__tests__/unit/commands/ui.test.js +30 -31
- package/frigg-cli/__tests__/unit/dependencies.test.js +2 -6
- package/frigg-cli/build-command/index.js +0 -6
- package/frigg-cli/deploy-command/index.js +0 -6
- package/frigg-cli/generate-command/index.js +0 -1
- package/frigg-cli/generate-iam-command.js +0 -1
- package/frigg-cli/index.js +5 -28
- package/frigg-cli/index.test.js +158 -0
- package/frigg-cli/init-command/backend-first-handler.js +551 -395
- package/frigg-cli/init-command/index.js +35 -82
- package/frigg-cli/install-command/commit-changes.js +8 -40
- package/frigg-cli/install-command/environment-variables.js +0 -15
- package/frigg-cli/install-command/index.js +21 -96
- package/frigg-cli/install-command/install-package.js +4 -77
- package/frigg-cli/install-command/integration-file.js +11 -20
- package/frigg-cli/install-command/template.js +75 -102
- package/frigg-cli/install-command/validate-package.js +4 -36
- package/frigg-cli/package.json +1 -1
- package/frigg-cli/start-command/index.js +0 -4
- package/frigg-cli/start-command/start-command.test.js +0 -3
- package/frigg-cli/test/init-command.test.js +2 -9
- package/infrastructure/__tests__/postgres-config.test.js +835 -241
- package/infrastructure/__tests__/template-generation.test.js +8 -36
- package/infrastructure/create-frigg-infrastructure.js +1 -4
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +98 -80
- package/infrastructure/domains/admin-scripts/admin-script-builder.js +2 -6
- package/infrastructure/domains/admin-scripts/admin-script-builder.test.js +0 -30
- package/infrastructure/domains/database/aurora-builder.js +2 -13
- package/infrastructure/domains/database/aurora-builder.test.js +0 -22
- package/infrastructure/domains/health/application/use-cases/__tests__/mismatch-analyzer-method-name.test.js +8 -12
- package/infrastructure/domains/health/application/use-cases/__tests__/repair-via-import-use-case.test.js +7 -19
- package/infrastructure/domains/health/application/use-cases/run-health-check-use-case.test.js +8 -12
- package/infrastructure/domains/health/domain/services/__tests__/import-progress-monitor.test.js +18 -17
- package/infrastructure/domains/health/domain/services/__tests__/update-progress-monitor.test.js +2 -12
- package/infrastructure/domains/health/infrastructure/adapters/__tests__/orphan-detection-relationship-analysis.test.js +1 -8
- package/infrastructure/domains/health/infrastructure/adapters/aws-property-reconciler.test.js +2 -4
- package/infrastructure/domains/health/infrastructure/adapters/aws-resource-detector.test.js +0 -10
- package/infrastructure/domains/networking/vpc-builder.js +8 -18
- package/infrastructure/domains/networking/vpc-builder.test.js +12 -26
- package/infrastructure/domains/security/iam-generator.js +5 -112
- package/infrastructure/domains/security/iam-generator.test.js +0 -94
- package/infrastructure/domains/shared/cloudformation-discovery.test.js +6 -36
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +2 -26
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +1 -34
- package/infrastructure/infrastructure-composer.test.js +794 -268
- package/infrastructure/integration.test.js +381 -0
- package/infrastructure/scripts/build-prisma-layer.test.js +7 -28
- package/infrastructure/scripts/build-time-discovery.test.js +3 -18
- package/package.json +8 -10
- package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
- package/frigg-cli/__tests__/unit/commands/validate-wiring.test.js +0 -92
- package/frigg-cli/init-command/deployment-modes.js +0 -7
- package/frigg-cli/init-command/safe-path.js +0 -58
- package/frigg-cli/init-command/scaffold-dependencies.js +0 -202
- package/frigg-cli/install-command/app-definition.js +0 -174
- package/frigg-cli/install-command/resolve-module.js +0 -69
- package/frigg-cli/templates/backend/README.md +0 -267
- package/frigg-cli/templates/backend/env.example +0 -20
- package/frigg-cli/templates/backend/gitignore +0 -10
- package/frigg-cli/templates/backend/index.js +0 -114
- package/frigg-cli/templates/backend/infrastructure.js +0 -20
- package/frigg-cli/validate-command/__tests__/init-validation.test.js +0 -63
- package/frigg-cli/validate-command/__tests__/integrations-checks.test.js +0 -133
- package/frigg-cli/validate-command/__tests__/validate-app-definition.test.js +0 -443
- package/frigg-cli/validate-command/__tests__/validate-command.test.js +0 -262
- package/frigg-cli/validate-command/__tests__/validate-module-command.test.js +0 -119
- package/frigg-cli/validate-command/checks/config.js +0 -504
- package/frigg-cli/validate-command/checks/integrations.js +0 -274
- package/frigg-cli/validate-command/fixtures/bad-module/index.js +0 -18
- package/frigg-cli/validate-command/fixtures/fathom-module/definition.js +0 -76
- package/frigg-cli/validate-command/fixtures/fathom-module/index.js +0 -6
- package/frigg-cli/validate-command/format-report.js +0 -60
- package/frigg-cli/validate-command/index.js +0 -151
- package/frigg-cli/validate-command/load-app-definition.js +0 -105
- package/frigg-cli/validate-command/load-module-definition.js +0 -64
- package/frigg-cli/validate-command/schema-issues.js +0 -154
- package/frigg-cli/validate-command/validate-app-definition.js +0 -60
- package/frigg-cli/validate-command/validate-module-definition.js +0 -46
- package/infrastructure/__tests__/management-api-gateway-routes.test.js +0 -281
- package/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -148
- package/infrastructure/app-definition-schema-contract.test.js +0 -629
- package/infrastructure/create-frigg-infrastructure.test.js +0 -51
|
@@ -313,98 +313,4 @@ describe('IAM Generator', () => {
|
|
|
313
313
|
expect(yaml).toContain('CredentialsSecretArn:');
|
|
314
314
|
});
|
|
315
315
|
});
|
|
316
|
-
|
|
317
|
-
describe("scoping to the app's own resources", () => {
|
|
318
|
-
const yaml = require('js-yaml');
|
|
319
|
-
const policyResources = (template, policy) =>
|
|
320
|
-
template.Resources[
|
|
321
|
-
policy
|
|
322
|
-
].Properties.PolicyDocument.Statement.flatMap((statement) =>
|
|
323
|
-
[].concat(statement.Resource)
|
|
324
|
-
).map((r) => (typeof r === 'string' ? r : r['Fn::Sub']));
|
|
325
|
-
|
|
326
|
-
// `frigg deploy` names everything after the service (Definition.name):
|
|
327
|
-
// stack my-app-prod, functions my-app-prod-auth, role
|
|
328
|
-
// my-app-prod-us-east-1-lambdaRole, queues my-app-internal-error-queue-prod
|
|
329
|
-
// and my-app-prod-DbMigrationQueue, layer my-app-prisma-prod, and
|
|
330
|
-
// CloudFormation-named topics, alarms and buckets prefixed my-app-prod.
|
|
331
|
-
const generate = (appDefinition) => {
|
|
332
|
-
const summary = getFeatureSummary(appDefinition);
|
|
333
|
-
return yaml.load(
|
|
334
|
-
generateIAMCloudFormation({
|
|
335
|
-
appName: summary.appName,
|
|
336
|
-
serviceName: summary.serviceName,
|
|
337
|
-
features: summary.features,
|
|
338
|
-
})
|
|
339
|
-
);
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
it('reports the service name osls deploys under', () => {
|
|
343
|
-
expect(getFeatureSummary({ name: 'my-app' }).serviceName).toBe(
|
|
344
|
-
'my-app'
|
|
345
|
-
);
|
|
346
|
-
expect(getFeatureSummary({}).serviceName).toBe('create-frigg-app');
|
|
347
|
-
});
|
|
348
|
-
|
|
349
|
-
it('lets an app whose name does not contain "frigg" deploy its stack and resources', () => {
|
|
350
|
-
const resources = policyResources(
|
|
351
|
-
generate({ name: 'my-app' }),
|
|
352
|
-
'FriggCoreDeploymentPolicy'
|
|
353
|
-
);
|
|
354
|
-
|
|
355
|
-
for (const expected of [
|
|
356
|
-
'arn:aws:cloudformation:*:${AWS::AccountId}:stack/*my-app*/*',
|
|
357
|
-
'arn:aws:lambda:*:${AWS::AccountId}:function:*my-app*',
|
|
358
|
-
'arn:aws:iam::${AWS::AccountId}:role/*my-app*',
|
|
359
|
-
'arn:aws:sqs:*:${AWS::AccountId}:*my-app*',
|
|
360
|
-
'arn:aws:sns:*:${AWS::AccountId}:*my-app*',
|
|
361
|
-
'arn:aws:logs:*:${AWS::AccountId}:log-group:/aws/lambda/*my-app*',
|
|
362
|
-
'arn:aws:logs:*:${AWS::AccountId}:log-group:/aws/lambda/*my-app*:*',
|
|
363
|
-
'arn:aws:cloudwatch:*:${AWS::AccountId}:alarm:*my-app*',
|
|
364
|
-
'arn:aws:lambda:*:${AWS::AccountId}:layer:*my-app*',
|
|
365
|
-
'arn:aws:lambda:*:${AWS::AccountId}:layer:*my-app*:*',
|
|
366
|
-
'arn:aws:s3:::*my-app*',
|
|
367
|
-
'arn:aws:s3:::*my-app*/*',
|
|
368
|
-
]) {
|
|
369
|
-
expect(resources).toContain(expected);
|
|
370
|
-
}
|
|
371
|
-
// Existing grants for frigg-named resources are kept.
|
|
372
|
-
expect(resources).toContain(
|
|
373
|
-
'arn:aws:lambda:*:${AWS::AccountId}:function:*frigg*'
|
|
374
|
-
);
|
|
375
|
-
});
|
|
376
|
-
|
|
377
|
-
it('matches S3 bucket names in lower case', () => {
|
|
378
|
-
const resources = policyResources(
|
|
379
|
-
generate({ name: 'MyApp' }),
|
|
380
|
-
'FriggCoreDeploymentPolicy'
|
|
381
|
-
);
|
|
382
|
-
expect(resources).toContain('arn:aws:s3:::*myapp*');
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
it('scopes the SSM parameter grant to the app too', () => {
|
|
386
|
-
const template = generate({
|
|
387
|
-
name: 'my-app',
|
|
388
|
-
ssm: { enable: true },
|
|
389
|
-
});
|
|
390
|
-
const resources = policyResources(template, 'FriggSSMPolicy');
|
|
391
|
-
expect(resources).toContain(
|
|
392
|
-
'arn:aws:ssm:*:${AWS::AccountId}:parameter/*my-app*'
|
|
393
|
-
);
|
|
394
|
-
});
|
|
395
|
-
|
|
396
|
-
it('does not duplicate grants for an app named frigg', () => {
|
|
397
|
-
const resources = policyResources(
|
|
398
|
-
generate({ name: 'frigg' }),
|
|
399
|
-
'FriggCoreDeploymentPolicy'
|
|
400
|
-
);
|
|
401
|
-
expect(
|
|
402
|
-
resources.filter(
|
|
403
|
-
(r) =>
|
|
404
|
-
r ===
|
|
405
|
-
'arn:aws:lambda:*:${AWS::AccountId}:function:*frigg*'
|
|
406
|
-
)
|
|
407
|
-
).toHaveLength(1);
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
316
|
});
|
|
@@ -164,7 +164,7 @@ describe('CloudFormationDiscovery', () => {
|
|
|
164
164
|
expect(result.routeTableId).toBe('rtb-123');
|
|
165
165
|
expect(result.vpcEndpointSecurityGroupId).toBe('sg-vpce-123');
|
|
166
166
|
expect(result.s3VpcEndpointId).toBe('vpce-s3-123');
|
|
167
|
-
expect(result.
|
|
167
|
+
expect(result.dynamoDbVpcEndpointId).toBe('vpce-ddb-123');
|
|
168
168
|
expect(result.kmsVpcEndpointId).toBe('vpce-kms-123');
|
|
169
169
|
expect(result.secretsManagerVpcEndpointId).toBe('vpce-sm-123');
|
|
170
170
|
});
|
|
@@ -190,9 +190,6 @@ describe('CloudFormationDiscovery', () => {
|
|
|
190
190
|
|
|
191
191
|
expect(result).toEqual({
|
|
192
192
|
fromCloudFormationStack: true,
|
|
193
|
-
// _extractFromResources() initialises the structured endpoint map whenever
|
|
194
|
-
// the stack has resources (37a354e8)
|
|
195
|
-
vpcEndpoints: {},
|
|
196
193
|
stackName: 'test-stack',
|
|
197
194
|
auroraClusterId: 'test-cluster',
|
|
198
195
|
existingLogicalIds: ['FriggAuroraCluster'],
|
|
@@ -260,9 +257,6 @@ describe('CloudFormationDiscovery', () => {
|
|
|
260
257
|
|
|
261
258
|
expect(result).toEqual({
|
|
262
259
|
fromCloudFormationStack: true,
|
|
263
|
-
// _extractFromResources() initialises the structured endpoint map whenever
|
|
264
|
-
// the stack has resources (37a354e8)
|
|
265
|
-
vpcEndpoints: {},
|
|
266
260
|
stackName: 'test-stack',
|
|
267
261
|
migrationStatusBucket: 'test-migration-bucket',
|
|
268
262
|
existingLogicalIds: ['FriggMigrationStatusBucket'],
|
|
@@ -291,9 +285,6 @@ describe('CloudFormationDiscovery', () => {
|
|
|
291
285
|
|
|
292
286
|
expect(result).toEqual({
|
|
293
287
|
fromCloudFormationStack: true,
|
|
294
|
-
// _extractFromResources() initialises the structured endpoint map whenever
|
|
295
|
-
// the stack has resources (37a354e8)
|
|
296
|
-
vpcEndpoints: {},
|
|
297
288
|
stackName: 'test-stack',
|
|
298
289
|
migrationQueueUrl:
|
|
299
290
|
'https://sqs.us-east-1.amazonaws.com/123456789/test-queue',
|
|
@@ -322,9 +313,6 @@ describe('CloudFormationDiscovery', () => {
|
|
|
322
313
|
|
|
323
314
|
expect(result).toEqual({
|
|
324
315
|
fromCloudFormationStack: true,
|
|
325
|
-
// _extractFromResources() initialises the structured endpoint map whenever
|
|
326
|
-
// the stack has resources (37a354e8)
|
|
327
|
-
vpcEndpoints: {},
|
|
328
316
|
stackName: 'test-stack',
|
|
329
317
|
natGatewayId: 'nat-0123456789',
|
|
330
318
|
existingLogicalIds: ['FriggNatGateway'],
|
|
@@ -352,9 +340,6 @@ describe('CloudFormationDiscovery', () => {
|
|
|
352
340
|
|
|
353
341
|
expect(result).toEqual({
|
|
354
342
|
fromCloudFormationStack: true,
|
|
355
|
-
// _extractFromResources() initialises the structured endpoint map whenever
|
|
356
|
-
// the stack has resources (37a354e8)
|
|
357
|
-
vpcEndpoints: {},
|
|
358
343
|
stackName: 'test-stack',
|
|
359
344
|
defaultVpcId: 'vpc-037ec55fe87aec1e7',
|
|
360
345
|
existingLogicalIds: ['FriggVPC'],
|
|
@@ -393,9 +378,6 @@ describe('CloudFormationDiscovery', () => {
|
|
|
393
378
|
|
|
394
379
|
expect(result).toEqual({
|
|
395
380
|
fromCloudFormationStack: true,
|
|
396
|
-
// _extractFromResources() initialises the structured endpoint map whenever
|
|
397
|
-
// the stack has resources (37a354e8)
|
|
398
|
-
vpcEndpoints: {},
|
|
399
381
|
stackName: 'test-stack',
|
|
400
382
|
defaultVpcId: 'vpc-123', // VpcBuilder expects 'defaultVpcId'
|
|
401
383
|
defaultKmsKeyId: 'arn:aws:kms:us-east-1:123456789:key/abc',
|
|
@@ -424,9 +406,6 @@ describe('CloudFormationDiscovery', () => {
|
|
|
424
406
|
|
|
425
407
|
expect(result).toEqual({
|
|
426
408
|
fromCloudFormationStack: true,
|
|
427
|
-
// _extractFromResources() initialises the structured endpoint map whenever
|
|
428
|
-
// the stack has resources (37a354e8)
|
|
429
|
-
vpcEndpoints: {},
|
|
430
409
|
stackName: 'test-stack',
|
|
431
410
|
});
|
|
432
411
|
});
|
|
@@ -460,11 +439,6 @@ describe('CloudFormationDiscovery', () => {
|
|
|
460
439
|
SecurityGroups: [{ VpcId: 'vpc-123' }],
|
|
461
440
|
});
|
|
462
441
|
|
|
463
|
-
// Mock the VPC's default security group lookup (added in 37a354e8)
|
|
464
|
-
mockEC2Client.send.mockResolvedValueOnce({
|
|
465
|
-
SecurityGroups: [{ GroupId: 'sg-default-123' }],
|
|
466
|
-
});
|
|
467
|
-
|
|
468
442
|
// Mock subnet query
|
|
469
443
|
mockEC2Client.send.mockResolvedValueOnce({
|
|
470
444
|
Subnets: [
|
|
@@ -495,11 +469,9 @@ describe('CloudFormationDiscovery', () => {
|
|
|
495
469
|
|
|
496
470
|
const result = await cfDiscovery.discoverFromStack('test-stack');
|
|
497
471
|
|
|
498
|
-
expect(result.defaultVpcId).toBe('vpc-123');
|
|
499
|
-
expect(result.defaultSecurityGroupId).toBe('sg-default-123');
|
|
500
472
|
expect(result.privateSubnetId1).toBe('subnet-private-1');
|
|
501
473
|
expect(result.privateSubnetId2).toBe('subnet-private-2');
|
|
502
|
-
expect(mockEC2Client.send).toHaveBeenCalledTimes(
|
|
474
|
+
expect(mockEC2Client.send).toHaveBeenCalledTimes(2);
|
|
503
475
|
});
|
|
504
476
|
|
|
505
477
|
it('should handle EC2 subnet query errors gracefully', async () => {
|
|
@@ -767,7 +739,7 @@ describe('CloudFormationDiscovery', () => {
|
|
|
767
739
|
expect(result.vpcEndpoints.s3).toBe('vpce-0352ceac2124c14be');
|
|
768
740
|
expect(result.vpcEndpoints.dynamodb).toBe('vpce-0b06c4f631199ea68');
|
|
769
741
|
expect(result.s3VpcEndpointId).toBe('vpce-0352ceac2124c14be');
|
|
770
|
-
expect(result.
|
|
742
|
+
expect(result.dynamoDbVpcEndpointId).toBe('vpce-0b06c4f631199ea68');
|
|
771
743
|
|
|
772
744
|
// Verify NO VPC/KMS resources (they're external)
|
|
773
745
|
expect(result.defaultVpcId).toBeUndefined();
|
|
@@ -804,7 +776,7 @@ describe('CloudFormationDiscovery', () => {
|
|
|
804
776
|
expect(result.vpcEndpoints.s3).toBe('vpce-legacy-s3');
|
|
805
777
|
expect(result.vpcEndpoints.dynamodb).toBe('vpce-legacy-ddb');
|
|
806
778
|
expect(result.s3VpcEndpointId).toBe('vpce-legacy-s3');
|
|
807
|
-
expect(result.
|
|
779
|
+
expect(result.dynamoDbVpcEndpointId).toBe('vpce-legacy-ddb');
|
|
808
780
|
});
|
|
809
781
|
|
|
810
782
|
it('should extract FriggLambdaSecurityGroup from stack', async () => {
|
|
@@ -835,9 +807,7 @@ describe('CloudFormationDiscovery', () => {
|
|
|
835
807
|
|
|
836
808
|
// Lambda security group should be extracted
|
|
837
809
|
expect(result.lambdaSecurityGroupId).toBe('sg-01002240c6a446202');
|
|
838
|
-
|
|
839
|
-
// (defaultSecurityGroupId is only ever the VPC default; see 37a354e8).
|
|
840
|
-
expect(result.defaultSecurityGroupId).toBeUndefined();
|
|
810
|
+
expect(result.defaultSecurityGroupId).toBe('sg-01002240c6a446202');
|
|
841
811
|
expect(result.existingLogicalIds).toContain(
|
|
842
812
|
'FriggLambdaSecurityGroup'
|
|
843
813
|
);
|
|
@@ -929,7 +899,7 @@ describe('CloudFormationDiscovery', () => {
|
|
|
929
899
|
|
|
930
900
|
describe('existingLogicalIds tracking', () => {
|
|
931
901
|
it('should track OLD VPC endpoint logical IDs (VPCEndpointS3 pattern) for backwards compatibility', async () => {
|
|
932
|
-
// CRITICAL:
|
|
902
|
+
// CRITICAL: Frontify production uses OLD naming convention
|
|
933
903
|
const mockStack = {
|
|
934
904
|
StackName: 'create-frigg-app-production',
|
|
935
905
|
Outputs: [],
|
|
@@ -286,11 +286,6 @@ function createBaseDefinition(
|
|
|
286
286
|
...(usePrismaLayer && { layers: [{ Ref: 'PrismaLambdaLayer' }] }),
|
|
287
287
|
skipEsbuild: true, // Handlers in node_modules don't need bundling
|
|
288
288
|
package: skipEsbuildPackageConfig,
|
|
289
|
-
// Every path prefix the core integration router
|
|
290
|
-
// (createIntegrationRouter) registers must be routed here;
|
|
291
|
-
// HTTP API has no implicit catch-all, so an unlisted prefix
|
|
292
|
-
// 404s at the gateway before Express sees it. Guarded by
|
|
293
|
-
// __tests__/management-api-gateway-routes.test.js.
|
|
294
289
|
events: [
|
|
295
290
|
{ httpApi: { path: '/api/integrations', method: 'ANY' } },
|
|
296
291
|
{
|
|
@@ -300,20 +295,6 @@ function createBaseDefinition(
|
|
|
300
295
|
},
|
|
301
296
|
},
|
|
302
297
|
{ httpApi: { path: '/api/authorize', method: 'ANY' } },
|
|
303
|
-
{ httpApi: { path: '/api/entity', method: 'ANY' } },
|
|
304
|
-
{
|
|
305
|
-
httpApi: {
|
|
306
|
-
path: '/api/entity/{proxy+}',
|
|
307
|
-
method: 'ANY',
|
|
308
|
-
},
|
|
309
|
-
},
|
|
310
|
-
{ httpApi: { path: '/api/entities', method: 'ANY' } },
|
|
311
|
-
{
|
|
312
|
-
httpApi: {
|
|
313
|
-
path: '/api/entities/{proxy+}',
|
|
314
|
-
method: 'ANY',
|
|
315
|
-
},
|
|
316
|
-
},
|
|
317
298
|
],
|
|
318
299
|
},
|
|
319
300
|
user: {
|
|
@@ -402,18 +383,12 @@ function createBaseDefinition(
|
|
|
402
383
|
},
|
|
403
384
|
},
|
|
404
385
|
},
|
|
405
|
-
// The functions above use `httpApi` events, so osls creates
|
|
406
|
-
// an HTTP API (API Gateway v2, logical ID HttpApi) with only
|
|
407
|
-
// the `$default` stage. HTTP APIs publish `5xx`, not the REST
|
|
408
|
-
// API metric `5XXError`, and the ApiId dimension identifies
|
|
409
|
-
// this API (a Stage dimension would have to be `$default`).
|
|
410
|
-
// https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-metrics.html
|
|
411
386
|
ApiGatewayAlarm5xx: {
|
|
412
387
|
Type: 'AWS::CloudWatch::Alarm',
|
|
413
388
|
Properties: {
|
|
414
389
|
AlarmDescription: 'API Gateway 5xx Errors',
|
|
415
390
|
Namespace: 'AWS/ApiGateway',
|
|
416
|
-
MetricName: '
|
|
391
|
+
MetricName: '5XXError',
|
|
417
392
|
Statistic: 'Sum',
|
|
418
393
|
Threshold: 0,
|
|
419
394
|
ComparisonOperator: 'GreaterThanThreshold',
|
|
@@ -422,6 +397,7 @@ function createBaseDefinition(
|
|
|
422
397
|
AlarmActions: [{ Ref: 'InternalErrorBridgeTopic' }],
|
|
423
398
|
Dimensions: [
|
|
424
399
|
{ Name: 'ApiId', Value: { Ref: 'HttpApi' } },
|
|
400
|
+
{ Name: 'Stage', Value: '${self:provider.stage}' },
|
|
425
401
|
],
|
|
426
402
|
},
|
|
427
403
|
},
|
|
@@ -94,19 +94,7 @@ describe('Base Definition Factory', () => {
|
|
|
94
94
|
|
|
95
95
|
expect(result.functions.auth.handler).toBe('node_modules/@friggframework/core/handlers/routers/auth.handler');
|
|
96
96
|
expect(result.functions.auth.layers).toEqual([{ Ref: 'PrismaLambdaLayer' }]);
|
|
97
|
-
expect(
|
|
98
|
-
result.functions.auth.events.map(
|
|
99
|
-
(e) => `${e.httpApi.method} ${e.httpApi.path}`
|
|
100
|
-
)
|
|
101
|
-
).toEqual([
|
|
102
|
-
'ANY /api/integrations',
|
|
103
|
-
'ANY /api/integrations/{proxy+}',
|
|
104
|
-
'ANY /api/authorize',
|
|
105
|
-
'ANY /api/entity',
|
|
106
|
-
'ANY /api/entity/{proxy+}',
|
|
107
|
-
'ANY /api/entities',
|
|
108
|
-
'ANY /api/entities/{proxy+}',
|
|
109
|
-
]);
|
|
97
|
+
expect(result.functions.auth.events).toHaveLength(3);
|
|
110
98
|
});
|
|
111
99
|
|
|
112
100
|
it('should NOT include legacy dbMigrate function', () => {
|
|
@@ -133,27 +121,6 @@ describe('Base Definition Factory', () => {
|
|
|
133
121
|
expect(result.resources.Resources.ApiGatewayAlarm5xx).toBeDefined();
|
|
134
122
|
});
|
|
135
123
|
|
|
136
|
-
it('alarms on the HTTP API 5xx metric of the API osls creates', () => {
|
|
137
|
-
// The Frigg functions use `httpApi` events, so osls creates an
|
|
138
|
-
// API Gateway v2 HTTP API (logical ID HttpApi) with only the
|
|
139
|
-
// `$default` stage. HTTP APIs publish `5xx` (REST APIs publish
|
|
140
|
-
// `5XXError`) with the ApiId dimension; a Stage dimension set to
|
|
141
|
-
// the deploy stage name would never match `$default`.
|
|
142
|
-
const result = createBaseDefinition({}, {}, {});
|
|
143
|
-
const usesHttpApi = Object.values(result.functions).some((fn) =>
|
|
144
|
-
(fn.events || []).some((event) => event.httpApi)
|
|
145
|
-
);
|
|
146
|
-
expect(usesHttpApi).toBe(true);
|
|
147
|
-
|
|
148
|
-
const alarm = result.resources.Resources.ApiGatewayAlarm5xx;
|
|
149
|
-
expect(alarm.Properties).toMatchObject({
|
|
150
|
-
Namespace: 'AWS/ApiGateway',
|
|
151
|
-
MetricName: '5xx',
|
|
152
|
-
Dimensions: [{ Name: 'ApiId', Value: { Ref: 'HttpApi' } }],
|
|
153
|
-
AlarmActions: [{ Ref: 'InternalErrorBridgeTopic' }],
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
124
|
it('should include base IAM permissions', () => {
|
|
158
125
|
const result = createBaseDefinition({}, {}, {});
|
|
159
126
|
|