Skip to content

Commit e2f53e9

Browse files
committed
feat: add EventBridge importer
1 parent 74bc0f9 commit e2f53e9

File tree

17 files changed

+1430
-11
lines changed

17 files changed

+1430
-11
lines changed

packages/@aws-cdk/aws-service-spec/build/full-database.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import * as path from 'node:path';
2-
import { SpecDatabase } from '@aws-cdk/service-spec-types';
32
import { DatabaseBuilder, DatabaseBuilderOptions, ReportAudience } from '@aws-cdk/service-spec-importers';
3+
import { patchOobRelationships } from '@aws-cdk/service-spec-importers/src/patches/oob-relationship-patches';
4+
import { SpecDatabase } from '@aws-cdk/service-spec-types';
45
import { Augmentations } from './augmentations';
5-
import { Scrutinies } from './scrutinies';
6-
import { patchSamTemplateSpec } from './patches/sam-patches';
76
import { patchCloudFormationRegistry } from './patches/registry-patches';
8-
import { patchOobRelationships } from '@aws-cdk/service-spec-importers/src/patches/oob-relationship-patches';
7+
import { patchSamTemplateSpec } from './patches/sam-patches';
8+
import { Scrutinies } from './scrutinies';
99

1010
const SOURCES = path.join(__dirname, '../../../../sources');
1111

@@ -29,7 +29,8 @@ export class FullDatabase extends DatabaseBuilder {
2929
)
3030
.importLogSources(path.join(SOURCES, 'LogSources/log-source-resource.json'))
3131
.importScrutinies()
32-
.importAugmentations();
32+
.importAugmentations()
33+
.importEventBridgeSchema(path.join(SOURCES, 'EventBridgeSchema'));
3334
}
3435

3536
/**
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{
2+
"$ref": "#/definitions/EventBridgeSchema",
3+
"$schema": "http://json-schema.org/draft-07/schema#",
4+
"definitions": {
5+
"EventBridgeSchema": {
6+
"additionalProperties": false,
7+
"description": "Root class of an EventBridge Schema",
8+
"properties": {
9+
"SchemaName": {
10+
"type": "string"
11+
},
12+
"Content": {
13+
"$ref": "#/definitions/EventBridgeContent"
14+
},
15+
"Description": {
16+
"type": "string"
17+
}
18+
},
19+
"required": [
20+
"SchemaName",
21+
"Content",
22+
"Description"
23+
],
24+
"type": "object"
25+
},
26+
"EventBridgeContent": {
27+
"additionalProperties": false,
28+
"properties": {
29+
"components": {
30+
"$ref": "#/definitions/EventBridgeComponents"
31+
}
32+
},
33+
"required": [
34+
"components"
35+
],
36+
"type": "object"
37+
},
38+
"EventBridgeComponents": {
39+
"additionalProperties": false,
40+
"properties": {
41+
"schemas": {
42+
"$ref": "#/definitions/EventBridgeSchemas"
43+
}
44+
},
45+
"required": [
46+
"schemas"
47+
],
48+
"type": "object"
49+
},
50+
"EventBridgeSchemas": {
51+
"additionalProperties": false,
52+
"properties": {
53+
"AWSEvent": {
54+
"$ref": "#/definitions/AWSEvent"
55+
}
56+
},
57+
"required": [
58+
"AWSEvent"
59+
],
60+
"type": "object"
61+
},
62+
"AWSEvent": {
63+
"additionalProperties": false,
64+
"properties": {
65+
"x-amazon-events-detail-type": {
66+
"type": "string"
67+
},
68+
"x-amazon-events-source": {
69+
"type": "string"
70+
},
71+
"properties": {
72+
"$ref": "#/definitions/AWSEventProperties"
73+
}
74+
},
75+
"required": [
76+
"x-amazon-events-detail-type",
77+
"x-amazon-events-source",
78+
"properties"
79+
],
80+
"type": "object"
81+
},
82+
"AWSEventProperties": {
83+
"additionalProperties": false,
84+
"properties": {
85+
"detail": {
86+
"type": "object"
87+
}
88+
},
89+
"required": [
90+
"detail"
91+
],
92+
"type": "object"
93+
}
94+
}
95+
}

packages/@aws-cdk/service-spec-importers/src/cli/import-db.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const AVAILABLE_SOURCES: Record<string, keyof DatabaseBuilder> = {
1717
arnTemplates: 'importArnTemplates',
1818
oobRelationships: 'importOobRelationships',
1919
logSources: 'importLogSources',
20+
eventbridgeschema: 'importEventBridgeSchema',
2021
};
2122

2223
async function main() {

packages/@aws-cdk/service-spec-importers/src/db-builder.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { importArnTemplates } from './importers/import-arn-templates';
55
import { importCannedMetrics } from './importers/import-canned-metrics';
66
import { importCloudFormationDocumentation } from './importers/import-cloudformation-docs';
77
import { importCloudFormationRegistryResource } from './importers/import-cloudformation-registry';
8+
import { importEventBridgeSchema } from './importers/import-eventbridge-schema';
89
import { importGetAttAllowList } from './importers/import-getatt-allowlist';
910
import { importLogSources } from './importers/import-log-source';
1011
import { importOobRelationships } from './importers/import-oob-relationships';
@@ -23,6 +24,7 @@ import {
2324
loadSamSpec,
2425
loadOobRelationships,
2526
} from './loaders';
27+
import { loadDefaultEventBridgeSchema } from './loaders/load-eventbridge-schema';
2628
import { JsonLensPatcher } from './patching';
2729
import { ProblemReport, ReportAudience } from './report';
2830

@@ -56,7 +58,7 @@ export class DatabaseBuilder {
5658
constructor(
5759
protected readonly db: SpecDatabase = emptyDatabase(),
5860
private readonly options: DatabaseBuilderOptions,
59-
) {}
61+
) { }
6062

6163
/**
6264
* Add a SourceImporter to the database builder
@@ -217,6 +219,29 @@ export class DatabaseBuilder {
217219
});
218220
}
219221

222+
/**
223+
* Import the EvnetBridge schema
224+
*/
225+
public importEventBridgeSchema(schemaDirectory: string) {
226+
return this.addSourceImporter(async (db, report) => {
227+
const regions = await loadDefaultEventBridgeSchema(schemaDirectory, {
228+
...this.options,
229+
report,
230+
failureAudience: this.defaultProblemGrouping,
231+
});
232+
for (const region of regions) {
233+
for (const event of region.events) {
234+
importEventBridgeSchema({
235+
db,
236+
event,
237+
report,
238+
region: region.regionName,
239+
});
240+
}
241+
}
242+
});
243+
}
244+
220245
/**
221246
* Look at a load result and report problems
222247
*/

packages/@aws-cdk/service-spec-importers/src/diff-fmt.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export class DiffFormatter {
3434
constructor(db1: SpecDatabase, db2: SpecDatabase) {
3535
this.dbs = [db1, db2];
3636
}
37+
// TODO: I'm pretty sure i need to add something here to make my changes to show in the diff thingy
3738

3839
public format(diff: SpecDatabaseDiff): string {
3940
const tree = new PrintableTree();

0 commit comments

Comments
 (0)