-
Notifications
You must be signed in to change notification settings - Fork 0
/
stack.ts
70 lines (62 loc) · 2.18 KB
/
stack.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { Stack, StackProps } from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { Vpc, VpcLookupOptions } from 'aws-cdk-lib/aws-ec2';
import { EventBusConstruct, EventBusProps } from './constructs/event-bus';
import { ConfigurableDatabaseProps, DatabaseConstruct } from './constructs/database';
import { ComputeProps, ComputeConstruct } from './constructs/compute';
import { SchemaRegistryConstruct, SchemaRegistryProps } from './constructs/schema-registry';
import { EventSourceConstruct, EventSourceProps } from './constructs/event-source';
export interface SharedStackProps {
/**
* Any configuration related to the SchemaRegistryConstruct
*/
eventSchemaRegistryProps: SchemaRegistryProps;
dataSchemaRegistryProps: SchemaRegistryProps;
/**
* Any configuration related to the EventBusConstruct
*/
eventBusProps: EventBusProps;
/**
* Any configuration related to database
*/
databaseProps: ConfigurableDatabaseProps;
/**
* Any configuration related to shared compute resources
*/
computeProps: ComputeProps;
/**
* Any configuration related to event source
*/
eventSourceProps?: EventSourceProps;
/**
* VPC (lookup props) that will be used by resources
*/
vpcProps: VpcLookupOptions;
}
export class SharedStack extends Stack {
constructor(scope: Construct, id: string, props: StackProps & SharedStackProps) {
super(scope, id, props);
const mainVpc = Vpc.fromLookup(this, 'MainVpc', props.vpcProps);
const computeResources = new ComputeConstruct(
this,
'ComputeConstruct',
mainVpc,
props.computeProps
);
new EventBusConstruct(this, 'EventBusConstruct', props.eventBusProps);
new DatabaseConstruct(this, 'DatabaseConstruct', {
vpc: mainVpc,
allowedInboundSG: computeResources.securityGroup,
...props.databaseProps,
});
new SchemaRegistryConstruct(
this,
'EventSchemaRegistryConstruct',
props.eventSchemaRegistryProps
);
new SchemaRegistryConstruct(this, 'DataSchemaRegistryConstruct', props.dataSchemaRegistryProps);
if (props.eventSourceProps) {
new EventSourceConstruct(this, 'EventSourceConstruct', props.eventSourceProps);
}
}
}