-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathkitchen-stack.ts
More file actions
95 lines (85 loc) · 2.89 KB
/
kitchen-stack.ts
File metadata and controls
95 lines (85 loc) · 2.89 KB
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
import { Stack, StackProps } from "aws-cdk-lib";
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
import { Construct } from "constructs";
import { DatadogLambda } from "datadog-cdk-constructs-v2";
import { ApplicationListener } from "aws-cdk-lib/aws-elasticloadbalancingv2";
import { EventBus } from "aws-cdk-lib/aws-events";
import { StringParameter } from "aws-cdk-lib/aws-ssm";
import { SharedProps } from "./constructs/sharedFunctionProps";
import { AttributeType, BillingMode, ProjectionType, Table, TableClass } from "aws-cdk-lib/aws-dynamodb";
import { Api } from "./api";
import { BackgroundWorker } from "./backgroundWorkers";
import { HttpApi } from "aws-cdk-lib/aws-apigatewayv2";
export class KitchenStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
const environment = process.env.ENV ?? "test";
const serviceName = "KitchenService";
const version = process.env.VERSION ?? "latest";
const ddApiKey = Secret.fromSecretNameV2(this, "DDApiKeySecret", "DdApiKeySecret-EAtKjZYFq40D");
const jwtKey = StringParameter.fromSecureStringParameterAttributes(
this,
"JwtKeyParam",
{
parameterName: "/shared/jwt-key",
},
);
const httpApiId = StringParameter.valueForStringParameter(this, "/shared/api-id");
const httpApi = HttpApi.fromHttpApiAttributes(this, "HttpApi", {
httpApiId: httpApiId,
});
const eventBridge = EventBus.fromEventBusName(this, "SharedEventBus", "PlantBasedPizzaEvents");
const datadogConfiguration = new DatadogLambda(this, "Datadog", {
nodeLayerVersion: 121,
extensionLayerVersion: 74,
site: "datadoghq.eu",
apiKeySecret: ddApiKey,
service: "KitchenService",
version: process.env["COMMIT_HASH"] ?? "latest",
env: environment,
enableColdStartTracing: true,
captureLambdaPayload: process.env.ENV == "prod" ? false : true
});
const table = new Table(this, "KitchenDataTable", {
tableClass: TableClass.STANDARD,
billingMode: BillingMode.PAY_PER_REQUEST,
partitionKey: {
name: 'PK',
type: AttributeType.STRING
},
});
table.addGlobalSecondaryIndex({
indexName: 'GSI1',
projectionType: ProjectionType.ALL,
partitionKey: {
name: "GSI1PK",
type: AttributeType.STRING
},
sortKey: {
name: "GSI1SK",
type: AttributeType.STRING
}
});
const sharedProps: SharedProps = {
serviceName,
environment,
version,
apiProps: {
apiGateway: httpApi
},
datadogConfiguration,
table
};
const api = new Api(this, "KitchenApi", {
sharedProps,
bus: eventBridge,
table,
jwtKey
});
const backgroundWorkers = new BackgroundWorker(this, "BackgroundWorker", {
sharedProps,
table,
bus: eventBridge
});
}
}