@friggframework/devtools 2.0.0--canary.711.f8b6445.0 → 2.0.0--canary.667.f74cf3b.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/frigg-cli/README.md +30 -77
- package/frigg-cli/__tests__/unit/commands/generate-iam.test.js +0 -18
- package/frigg-cli/__tests__/unit/commands/install.test.js +341 -594
- package/frigg-cli/generate-command/index.js +0 -1
- package/frigg-cli/generate-iam-command.js +0 -1
- package/frigg-cli/index.js +4 -9
- package/frigg-cli/init-command/backend-first-handler.js +554 -397
- 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/test/init-command.test.js +2 -9
- package/infrastructure/__tests__/management-api-gateway-routes.test.js +281 -0
- package/infrastructure/docs/POSTGRES-CONFIGURATION.md +1 -21
- 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/security/iam-generator.js +5 -112
- package/infrastructure/domains/security/iam-generator.test.js +0 -94
- package/infrastructure/domains/shared/utilities/base-definition-factory.js +21 -7
- package/infrastructure/domains/shared/utilities/base-definition-factory.test.js +13 -22
- package/package.json +8 -10
- package/frigg-cli/__tests__/unit/commands/init.test.js +0 -688
- 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/infrastructure/__tests__/scaffold-default-infrastructure.test.js +0 -148
|
@@ -168,21 +168,6 @@ describe('AdminScriptBuilder', () => {
|
|
|
168
168
|
expect(result.resources.AdminScriptQueue.Properties.VisibilityTimeout).toBe(900); // 15 minutes
|
|
169
169
|
});
|
|
170
170
|
|
|
171
|
-
it('registers AdminScriptQueue under custom so frigg start creates it locally', async () => {
|
|
172
|
-
const appDefinition = {
|
|
173
|
-
adminScripts: [{ Definition: { name: 'test-script' } }],
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const result = await adminScriptBuilder.build(appDefinition, {});
|
|
177
|
-
|
|
178
|
-
expect(result.custom.AdminScriptQueue).toBe(
|
|
179
|
-
'${self:service}-${self:provider.stage}-AdminScriptQueue'
|
|
180
|
-
);
|
|
181
|
-
expect(result.resources.AdminScriptQueue.Properties.QueueName).toBe(
|
|
182
|
-
'${self:custom.AdminScriptQueue}'
|
|
183
|
-
);
|
|
184
|
-
});
|
|
185
|
-
|
|
186
171
|
it('should configure AdminScriptQueue redrive policy to InternalErrorQueue', async () => {
|
|
187
172
|
const appDefinition = {
|
|
188
173
|
adminScripts: [
|
|
@@ -636,21 +621,6 @@ describe('AdminScriptBuilder', () => {
|
|
|
636
621
|
});
|
|
637
622
|
|
|
638
623
|
describe('reports (ReportQueue + reportExecutor)', () => {
|
|
639
|
-
it('registers ReportQueue under custom so frigg start creates it locally', async () => {
|
|
640
|
-
const appDefinition = {
|
|
641
|
-
reports: [{ Definition: { name: 'my-report', version: '1.0.0' } }],
|
|
642
|
-
};
|
|
643
|
-
|
|
644
|
-
const result = await adminScriptBuilder.build(appDefinition, {});
|
|
645
|
-
|
|
646
|
-
expect(result.custom.ReportQueue).toBe(
|
|
647
|
-
'${self:service}-${self:provider.stage}-ReportQueue'
|
|
648
|
-
);
|
|
649
|
-
expect(result.resources.ReportQueue.Properties.QueueName).toBe(
|
|
650
|
-
'${self:custom.ReportQueue}'
|
|
651
|
-
);
|
|
652
|
-
});
|
|
653
|
-
|
|
654
624
|
it('creates ReportQueue + reportExecutor and wires REPORT_QUEUE_URL when reports are present', async () => {
|
|
655
625
|
const appDefinition = {
|
|
656
626
|
reports: [{ Definition: { name: 'my-report', version: '1.0.0' } }],
|
|
@@ -64,18 +64,7 @@ class AuroraBuilder extends InfrastructureBuilder {
|
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
// management='external': the app brings its own PostgreSQL (any
|
|
70
|
-
// provider) and connects through DATABASE_URL. Frigg creates and
|
|
71
|
-
// discovers no database resources and needs no VPC for it. This
|
|
72
|
-
// check precedes managementMode, which otherwise always manages
|
|
73
|
-
// Aurora. Migrations still run (MigrationBuilder) against DATABASE_URL.
|
|
74
|
-
if (postgres?.management === 'external') {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return postgres?.enable === true;
|
|
67
|
+
return appDefinition.database?.postgres?.enable === true;
|
|
79
68
|
}
|
|
80
69
|
|
|
81
70
|
getDependencies() {
|
|
@@ -93,7 +82,7 @@ class AuroraBuilder extends InfrastructureBuilder {
|
|
|
93
82
|
const dbConfig = appDefinition.database.postgres;
|
|
94
83
|
|
|
95
84
|
// Validate management mode
|
|
96
|
-
const validModes = ['discover', 'managed', 'use-existing'
|
|
85
|
+
const validModes = ['discover', 'managed', 'use-existing'];
|
|
97
86
|
const management = dbConfig.management || 'discover';
|
|
98
87
|
if (!validModes.includes(management)) {
|
|
99
88
|
result.addError(`Invalid database.postgres.management: "${management}"`);
|
|
@@ -42,28 +42,6 @@ describe('AuroraBuilder', () => {
|
|
|
42
42
|
expect(auroraBuilder.shouldExecute(appDefinition)).toBe(false);
|
|
43
43
|
});
|
|
44
44
|
|
|
45
|
-
it('should return false when Postgres is external (bring your own DATABASE_URL)', () => {
|
|
46
|
-
const appDefinition = {
|
|
47
|
-
database: {
|
|
48
|
-
postgres: { enable: true, management: 'external' },
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
expect(auroraBuilder.shouldExecute(appDefinition)).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it('should return false for external Postgres even with managementMode=managed', () => {
|
|
56
|
-
const appDefinition = {
|
|
57
|
-
managementMode: 'managed',
|
|
58
|
-
vpcIsolation: 'isolated',
|
|
59
|
-
database: {
|
|
60
|
-
postgres: { enable: true, management: 'external' },
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
expect(auroraBuilder.shouldExecute(appDefinition)).toBe(false);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
45
|
it('should return false when database is not defined', () => {
|
|
68
46
|
const appDefinition = {};
|
|
69
47
|
|
|
@@ -4,11 +4,6 @@ const path = require('path');
|
|
|
4
4
|
* Generate IAM CloudFormation template
|
|
5
5
|
* @param {Object} options - Generation options
|
|
6
6
|
* @param {string} [options.appName='Frigg'] - Application name
|
|
7
|
-
* @param {string} [options.serviceName] - The osls service name the app deploys
|
|
8
|
-
* under (Definition.name). Resource grants that match `*frigg*` are also
|
|
9
|
-
* granted for `*<serviceName>*`, because `frigg deploy` names the stack,
|
|
10
|
-
* functions, role, queues, topics, alarms, log groups, layer and buckets
|
|
11
|
-
* after the service, not after "frigg".
|
|
12
7
|
* @param {Object} [options.features={}] - Enabled features { vpc, kms, ssm, websockets }
|
|
13
8
|
* @param {string} [options.userPrefix='frigg-deployment-user'] - IAM user name prefix
|
|
14
9
|
* @param {string} [options.stackName='frigg-deployment-iam'] - CloudFormation stack name
|
|
@@ -21,8 +16,7 @@ function generateIAMCloudFormation(options = {}) {
|
|
|
21
16
|
features = {},
|
|
22
17
|
userPrefix = 'frigg-deployment-user',
|
|
23
18
|
stackName = 'frigg-deployment-iam',
|
|
24
|
-
ssmKmsKeyArn
|
|
25
|
-
serviceName,
|
|
19
|
+
ssmKmsKeyArn
|
|
26
20
|
} = options;
|
|
27
21
|
|
|
28
22
|
const deploymentUserName = userPrefix;
|
|
@@ -531,51 +525,6 @@ function generateIAMCloudFormation(options = {}) {
|
|
|
531
525
|
},
|
|
532
526
|
];
|
|
533
527
|
|
|
534
|
-
coreStatements.push(
|
|
535
|
-
{
|
|
536
|
-
Sid: 'FriggLambdaLayers',
|
|
537
|
-
Effect: 'Allow',
|
|
538
|
-
Action: [
|
|
539
|
-
'lambda:PublishLayerVersion',
|
|
540
|
-
'lambda:DeleteLayerVersion',
|
|
541
|
-
'lambda:GetLayerVersion',
|
|
542
|
-
],
|
|
543
|
-
Resource: [
|
|
544
|
-
{
|
|
545
|
-
'Fn::Sub':
|
|
546
|
-
'arn:aws:lambda:*:${AWS::AccountId}:layer:*frigg*',
|
|
547
|
-
},
|
|
548
|
-
{
|
|
549
|
-
'Fn::Sub':
|
|
550
|
-
'arn:aws:lambda:*:${AWS::AccountId}:layer:*frigg*:*',
|
|
551
|
-
},
|
|
552
|
-
],
|
|
553
|
-
},
|
|
554
|
-
{
|
|
555
|
-
// Buckets the app's stack creates (e.g. the migration-status
|
|
556
|
-
// bucket); CloudFormation names them after the stack, in lower case.
|
|
557
|
-
Sid: 'FriggAppBuckets',
|
|
558
|
-
Effect: 'Allow',
|
|
559
|
-
Action: [
|
|
560
|
-
's3:CreateBucket',
|
|
561
|
-
's3:DeleteBucket',
|
|
562
|
-
's3:PutBucketPolicy',
|
|
563
|
-
's3:DeleteBucketPolicy',
|
|
564
|
-
's3:PutBucketVersioning',
|
|
565
|
-
's3:PutBucketPublicAccessBlock',
|
|
566
|
-
's3:PutEncryptionConfiguration',
|
|
567
|
-
's3:PutLifecycleConfiguration',
|
|
568
|
-
's3:PutBucketTagging',
|
|
569
|
-
's3:GetBucketLocation',
|
|
570
|
-
's3:ListBucket',
|
|
571
|
-
's3:GetObject',
|
|
572
|
-
's3:PutObject',
|
|
573
|
-
's3:DeleteObject',
|
|
574
|
-
],
|
|
575
|
-
Resource: ['arn:aws:s3:::*frigg*', 'arn:aws:s3:::*frigg*/*'],
|
|
576
|
-
}
|
|
577
|
-
);
|
|
578
|
-
|
|
579
528
|
template.Resources.FriggCoreDeploymentPolicy = {
|
|
580
529
|
Type: 'AWS::IAM::ManagedPolicy',
|
|
581
530
|
Properties: {
|
|
@@ -819,59 +768,10 @@ function generateIAMCloudFormation(options = {}) {
|
|
|
819
768
|
},
|
|
820
769
|
};
|
|
821
770
|
|
|
822
|
-
expandResourceNamePatterns(template, serviceName);
|
|
823
|
-
|
|
824
771
|
// Convert to YAML
|
|
825
772
|
return convertToYAML(template);
|
|
826
773
|
}
|
|
827
774
|
|
|
828
|
-
const FRIGG_NAME_PATTERN = '*frigg*';
|
|
829
|
-
|
|
830
|
-
/**
|
|
831
|
-
* Next to every policy resource that matches `*frigg*`, add the same
|
|
832
|
-
* resource for `*<serviceName>*` (lower case for S3 bucket ARNs), so an app
|
|
833
|
-
* that is not named "frigg" can manage its own stack resources.
|
|
834
|
-
*
|
|
835
|
-
* @param {Object} template - CloudFormation template (mutated)
|
|
836
|
-
* @param {string} [serviceName]
|
|
837
|
-
*/
|
|
838
|
-
function expandResourceNamePatterns(template, serviceName) {
|
|
839
|
-
if (!serviceName || /frigg/i.test(serviceName)) {
|
|
840
|
-
return;
|
|
841
|
-
}
|
|
842
|
-
const servicePattern = `*${serviceName}*`;
|
|
843
|
-
const expand = (resource) => {
|
|
844
|
-
const value =
|
|
845
|
-
typeof resource === 'string'
|
|
846
|
-
? resource
|
|
847
|
-
: resource && resource['Fn::Sub'];
|
|
848
|
-
if (typeof value !== 'string' || !value.includes(FRIGG_NAME_PATTERN)) {
|
|
849
|
-
return [resource];
|
|
850
|
-
}
|
|
851
|
-
const pattern = value.startsWith('arn:aws:s3:::')
|
|
852
|
-
? servicePattern.toLowerCase()
|
|
853
|
-
: servicePattern;
|
|
854
|
-
const scoped = value.split(FRIGG_NAME_PATTERN).join(pattern);
|
|
855
|
-
return [
|
|
856
|
-
resource,
|
|
857
|
-
typeof resource === 'string' ? scoped : { 'Fn::Sub': scoped },
|
|
858
|
-
];
|
|
859
|
-
};
|
|
860
|
-
|
|
861
|
-
for (const resource of Object.values(template.Resources)) {
|
|
862
|
-
const statements = resource?.Properties?.PolicyDocument?.Statement;
|
|
863
|
-
if (!Array.isArray(statements)) continue;
|
|
864
|
-
for (const statement of statements) {
|
|
865
|
-
if (statement.Resource === undefined) continue;
|
|
866
|
-
const expanded = [].concat(statement.Resource).flatMap(expand);
|
|
867
|
-
statement.Resource =
|
|
868
|
-
Array.isArray(statement.Resource) || expanded.length > 1
|
|
869
|
-
? expanded
|
|
870
|
-
: expanded[0];
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
}
|
|
874
|
-
|
|
875
775
|
/**
|
|
876
776
|
* Convert JavaScript object to CloudFormation YAML
|
|
877
777
|
* @param {Object} obj - JavaScript object
|
|
@@ -896,7 +796,8 @@ function getFeatureSummary(appDefinition) {
|
|
|
896
796
|
const features = {
|
|
897
797
|
core: true, // Always enabled
|
|
898
798
|
vpc: appDefinition.vpc?.enable === true,
|
|
899
|
-
kms:
|
|
799
|
+
kms:
|
|
800
|
+
appDefinition.encryption?.fieldLevelEncryptionMethod === 'kms',
|
|
900
801
|
ssm: appDefinition.ssm?.enable === true,
|
|
901
802
|
websockets: appDefinition.websockets?.enable === true,
|
|
902
803
|
};
|
|
@@ -907,8 +808,6 @@ function getFeatureSummary(appDefinition) {
|
|
|
907
808
|
features,
|
|
908
809
|
integrationCount,
|
|
909
810
|
appName: appDefinition.name || 'Unnamed Frigg App',
|
|
910
|
-
// What createBaseDefinition uses as the osls service name.
|
|
911
|
-
serviceName: appDefinition.name || 'create-frigg-app',
|
|
912
811
|
ssmKmsKeyArn: appDefinition.ssm?.kmsKeyArn,
|
|
913
812
|
};
|
|
914
813
|
}
|
|
@@ -918,10 +817,7 @@ function getFeatureSummary(appDefinition) {
|
|
|
918
817
|
* @returns {Object} Basic IAM policy document
|
|
919
818
|
*/
|
|
920
819
|
function generateBasicIAMPolicy() {
|
|
921
|
-
const basicPolicyPath = path.join(
|
|
922
|
-
__dirname,
|
|
923
|
-
'templates/iam-policy-basic.json'
|
|
924
|
-
);
|
|
820
|
+
const basicPolicyPath = path.join(__dirname, 'templates/iam-policy-basic.json');
|
|
925
821
|
return require(basicPolicyPath);
|
|
926
822
|
}
|
|
927
823
|
|
|
@@ -930,10 +826,7 @@ function generateBasicIAMPolicy() {
|
|
|
930
826
|
* @returns {Object} Full IAM policy document
|
|
931
827
|
*/
|
|
932
828
|
function generateFullIAMPolicy() {
|
|
933
|
-
const fullPolicyPath = path.join(
|
|
934
|
-
__dirname,
|
|
935
|
-
'templates/iam-policy-full.json'
|
|
936
|
-
);
|
|
829
|
+
const fullPolicyPath = path.join(__dirname, 'templates/iam-policy-full.json');
|
|
937
830
|
return require(fullPolicyPath);
|
|
938
831
|
}
|
|
939
832
|
|
|
@@ -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
|
});
|
|
@@ -286,6 +286,11 @@ 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.
|
|
289
294
|
events: [
|
|
290
295
|
{ httpApi: { path: '/api/integrations', method: 'ANY' } },
|
|
291
296
|
{
|
|
@@ -295,6 +300,20 @@ function createBaseDefinition(
|
|
|
295
300
|
},
|
|
296
301
|
},
|
|
297
302
|
{ 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
|
+
},
|
|
298
317
|
],
|
|
299
318
|
},
|
|
300
319
|
user: {
|
|
@@ -383,18 +402,12 @@ function createBaseDefinition(
|
|
|
383
402
|
},
|
|
384
403
|
},
|
|
385
404
|
},
|
|
386
|
-
// The functions above use `httpApi` events, so osls creates
|
|
387
|
-
// an HTTP API (API Gateway v2, logical ID HttpApi) with only
|
|
388
|
-
// the `$default` stage. HTTP APIs publish `5xx`, not the REST
|
|
389
|
-
// API metric `5XXError`, and the ApiId dimension identifies
|
|
390
|
-
// this API (a Stage dimension would have to be `$default`).
|
|
391
|
-
// https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-metrics.html
|
|
392
405
|
ApiGatewayAlarm5xx: {
|
|
393
406
|
Type: 'AWS::CloudWatch::Alarm',
|
|
394
407
|
Properties: {
|
|
395
408
|
AlarmDescription: 'API Gateway 5xx Errors',
|
|
396
409
|
Namespace: 'AWS/ApiGateway',
|
|
397
|
-
MetricName: '
|
|
410
|
+
MetricName: '5XXError',
|
|
398
411
|
Statistic: 'Sum',
|
|
399
412
|
Threshold: 0,
|
|
400
413
|
ComparisonOperator: 'GreaterThanThreshold',
|
|
@@ -403,6 +416,7 @@ function createBaseDefinition(
|
|
|
403
416
|
AlarmActions: [{ Ref: 'InternalErrorBridgeTopic' }],
|
|
404
417
|
Dimensions: [
|
|
405
418
|
{ Name: 'ApiId', Value: { Ref: 'HttpApi' } },
|
|
419
|
+
{ Name: 'Stage', Value: '${self:provider.stage}' },
|
|
406
420
|
],
|
|
407
421
|
},
|
|
408
422
|
},
|
|
@@ -94,7 +94,19 @@ 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(
|
|
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
|
+
]);
|
|
98
110
|
});
|
|
99
111
|
|
|
100
112
|
it('should NOT include legacy dbMigrate function', () => {
|
|
@@ -121,27 +133,6 @@ describe('Base Definition Factory', () => {
|
|
|
121
133
|
expect(result.resources.Resources.ApiGatewayAlarm5xx).toBeDefined();
|
|
122
134
|
});
|
|
123
135
|
|
|
124
|
-
it('alarms on the HTTP API 5xx metric of the API osls creates', () => {
|
|
125
|
-
// The Frigg functions use `httpApi` events, so osls creates an
|
|
126
|
-
// API Gateway v2 HTTP API (logical ID HttpApi) with only the
|
|
127
|
-
// `$default` stage. HTTP APIs publish `5xx` (REST APIs publish
|
|
128
|
-
// `5XXError`) with the ApiId dimension; a Stage dimension set to
|
|
129
|
-
// the deploy stage name would never match `$default`.
|
|
130
|
-
const result = createBaseDefinition({}, {}, {});
|
|
131
|
-
const usesHttpApi = Object.values(result.functions).some((fn) =>
|
|
132
|
-
(fn.events || []).some((event) => event.httpApi)
|
|
133
|
-
);
|
|
134
|
-
expect(usesHttpApi).toBe(true);
|
|
135
|
-
|
|
136
|
-
const alarm = result.resources.Resources.ApiGatewayAlarm5xx;
|
|
137
|
-
expect(alarm.Properties).toMatchObject({
|
|
138
|
-
Namespace: 'AWS/ApiGateway',
|
|
139
|
-
MetricName: '5xx',
|
|
140
|
-
Dimensions: [{ Name: 'ApiId', Value: { Ref: 'HttpApi' } }],
|
|
141
|
-
AlarmActions: [{ Ref: 'InternalErrorBridgeTopic' }],
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
136
|
it('should include base IAM permissions', () => {
|
|
146
137
|
const result = createBaseDefinition({}, {}, {});
|
|
147
138
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/devtools",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.
|
|
4
|
+
"version": "2.0.0--canary.667.f74cf3b.0",
|
|
5
5
|
"bin": {
|
|
6
6
|
"frigg": "./frigg-cli/index.js"
|
|
7
7
|
},
|
|
8
8
|
"files": [
|
|
9
9
|
"frigg-cli/",
|
|
10
|
-
"frigg-cli/templates/",
|
|
11
10
|
"infrastructure/",
|
|
12
11
|
"migrations/",
|
|
13
12
|
"management-ui/dist/",
|
|
@@ -19,7 +18,6 @@
|
|
|
19
18
|
"@aws-sdk/client-cloudformation": "^3.705.0",
|
|
20
19
|
"@aws-sdk/client-ec2": "^3.835.0",
|
|
21
20
|
"@aws-sdk/client-kms": "^3.835.0",
|
|
22
|
-
"@aws-sdk/client-lambda": "^3.714.0",
|
|
23
21
|
"@aws-sdk/client-rds": "^3.906.0",
|
|
24
22
|
"@aws-sdk/client-s3": "^3.917.0",
|
|
25
23
|
"@aws-sdk/client-secrets-manager": "^3.906.0",
|
|
@@ -28,9 +26,9 @@
|
|
|
28
26
|
"@babel/eslint-parser": "^7.18.9",
|
|
29
27
|
"@babel/parser": "^7.25.3",
|
|
30
28
|
"@babel/traverse": "^7.25.3",
|
|
31
|
-
"@friggframework/core": "2.0.0--canary.
|
|
32
|
-
"@friggframework/schemas": "2.0.0--canary.
|
|
33
|
-
"@friggframework/test": "2.0.0--canary.
|
|
29
|
+
"@friggframework/core": "2.0.0--canary.667.f74cf3b.0",
|
|
30
|
+
"@friggframework/schemas": "2.0.0--canary.667.f74cf3b.0",
|
|
31
|
+
"@friggframework/test": "2.0.0--canary.667.f74cf3b.0",
|
|
34
32
|
"@hapi/boom": "^10.0.1",
|
|
35
33
|
"@inquirer/prompts": "^5.3.8",
|
|
36
34
|
"axios": "^1.18.0",
|
|
@@ -58,12 +56,12 @@
|
|
|
58
56
|
"validate-npm-package-name": "^5.0.0"
|
|
59
57
|
},
|
|
60
58
|
"devDependencies": {
|
|
61
|
-
"@friggframework/eslint-config": "2.0.0--canary.
|
|
62
|
-
"@friggframework/prettier-config": "2.0.0--canary.
|
|
59
|
+
"@friggframework/eslint-config": "2.0.0--canary.667.f74cf3b.0",
|
|
60
|
+
"@friggframework/prettier-config": "2.0.0--canary.667.f74cf3b.0",
|
|
63
61
|
"aws-sdk-client-mock": "^4.1.0",
|
|
64
62
|
"aws-sdk-client-mock-jest": "^4.1.0",
|
|
65
63
|
"jest": "^30.1.3",
|
|
66
|
-
"osls": "^3.
|
|
64
|
+
"osls": "^3.58.0",
|
|
67
65
|
"prettier": "^2.7.1",
|
|
68
66
|
"serverless-dotenv-plugin": "^6.0.0",
|
|
69
67
|
"serverless-esbuild": "^1.54.3",
|
|
@@ -91,5 +89,5 @@
|
|
|
91
89
|
"publishConfig": {
|
|
92
90
|
"access": "public"
|
|
93
91
|
},
|
|
94
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "f74cf3b1f04195508cb0ee6d4086b1cb2d70d913"
|
|
95
93
|
}
|