-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapi.ts
129 lines (123 loc) · 5.05 KB
/
api.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import { Construct } from "constructs";
import { SharedProps } from "./constructs/sharedFunctionProps";
import { InstrumentedApiLambdaFunction } from "./constructs/lambdaFunction";
import { IEventBus } from "aws-cdk-lib/aws-events";
import { ITable } from "aws-cdk-lib/aws-dynamodb";
import { IStringParameter, StringParameter } from "aws-cdk-lib/aws-ssm";
import { Tags } from "aws-cdk-lib";
export interface ApiProps {
sharedProps: SharedProps;
bus: IEventBus;
table: ITable;
jwtKey: IStringParameter
}
export class Api extends Construct {
constructor(scope: Construct, id: string, props: ApiProps) {
super(scope, id);
const getNewFunction = new InstrumentedApiLambdaFunction(this, "GetNewFunction", {
sharedProps: props.sharedProps,
handler: "index.handler",
buildDef: './src/lambda/buildGetNew.js',
outDir: './out/getNew',
functionName: "GetNewFunction",
path: "/kitchen/new",
methods: ["GET"],
priority: 36,
jwtKey: props.jwtKey
});
const getPrepCompleteFunction = new InstrumentedApiLambdaFunction(this, "GetPrepCompleteFunction", {
sharedProps: props.sharedProps,
handler: "index.handler",
buildDef: './src/lambda/buildGetPreparing.js',
outDir: './out/getPreparing',
functionName: "GetPrepCompleteFunction",
path: "/kitchen/prep",
methods: ["GET"],
priority: 33,
jwtKey: props.jwtKey
});
const getBakingFunction = new InstrumentedApiLambdaFunction(this, "GetBakingFunction", {
sharedProps: props.sharedProps,
handler: "index.handler",
buildDef: './src/lambda/buildGetBaking.js',
outDir: './out/getBaking',
functionName: "GetBakingFunction",
path: "/kitchen/baking",
methods: ["GET"],
priority: 34,
jwtKey: props.jwtKey
});
const getAwaitingQualityCheckFunction = new InstrumentedApiLambdaFunction(this, "GetAwaitingQualityCheckFunction", {
sharedProps: props.sharedProps,
handler: "index.handler",
buildDef: './src/lambda/buildGetAwaitingQualityCheck.js',
outDir: './out/getAwaitingQualityCheck',
functionName: "GetAwaitingQualityCheckFunction",
path: "/kitchen/quality-check",
methods: ["GET"],
priority: 35,
jwtKey: props.jwtKey
});
const setPreparingFunction = new InstrumentedApiLambdaFunction(this, "SetPreparingFunction", {
sharedProps: props.sharedProps,
handler: "index.handler",
buildDef: './src/lambda/buildSetPreparing.js',
outDir: './out/setPreparing',
functionName: "SetPreparingFunction",
path: "/kitchen/preparing",
methods: ["POST"],
priority: 30,
jwtKey: props.jwtKey
});
const setBakingFunction = new InstrumentedApiLambdaFunction(this, "SetBakingFunction", {
sharedProps: props.sharedProps,
handler: "index.handler",
buildDef: './src/lambda/buildSetBaking.js',
outDir: './out/setBaking',
functionName: "SetBakingFunction",
path: "/kitchen/prep-complete",
methods: ["POST"],
priority: 31,
jwtKey: props.jwtKey
});
const setQualityCheckingFunction = new InstrumentedApiLambdaFunction(this, "SetQualityCheckingFunction", {
sharedProps: props.sharedProps,
handler: "index.handler",
buildDef: './src/lambda/buildSetQualityCheck.js',
outDir: './out/setQualityChecking',
functionName: "SetQualityCheckingFunction",
path: "/kitchen/bake-complete",
methods: ["POST"],
priority: 32,
jwtKey: props.jwtKey
});
const setDoneFunction = new InstrumentedApiLambdaFunction(this, "SetCompleteFunction", {
sharedProps: props.sharedProps,
handler: "index.handler",
buildDef: './src/lambda/buildSetComplete.js',
outDir: './out/setComplete',
functionName: "SetCompleteFunction",
path: "/kitchen/quality-check",
methods: ["POST"],
priority: 37,
jwtKey: props.jwtKey
});
setPreparingFunction.function.addEnvironment("BUS_NAME", props.bus.eventBusName);
props.bus.grantPutEventsTo(setPreparingFunction.function);
setBakingFunction.function.addEnvironment("BUS_NAME", props.bus.eventBusName);
props.bus.grantPutEventsTo(setBakingFunction.function);
setQualityCheckingFunction.function.addEnvironment("BUS_NAME", props.bus.eventBusName);
props.bus.grantPutEventsTo(setQualityCheckingFunction.function);
setDoneFunction.function.addEnvironment("BUS_NAME", props.bus.eventBusName);
props.bus.grantPutEventsTo(setDoneFunction.function);
props.table.grantReadWriteData(setPreparingFunction.function);
props.table.grantReadWriteData(setBakingFunction.function);
props.table.grantReadWriteData(setQualityCheckingFunction.function);
props.table.grantReadWriteData(setDoneFunction.function);
props.table.grantReadData(getAwaitingQualityCheckFunction.function);
props.table.grantReadData(getBakingFunction.function);
props.table.grantReadData(getPrepCompleteFunction.function);
props.table.grantReadData(getNewFunction.function);
Tags.of(this).add("plantbasedpizza:application", "KitchenApi");
}
}