|
| 1 | +import { LambdaSource } from '@bifravst/aws-cdk-lambda-helpers/cdk' |
| 2 | +import { type PackedLayer } from '@bifravst/aws-cdk-lambda-helpers/layer' |
1 | 3 | import { |
2 | | - App, |
3 | | - CfnOutput, |
4 | | - Stack, |
5 | | - aws_lambda as Lambda, |
6 | | - aws_s3 as S3, |
7 | | -} from "aws-cdk-lib"; |
8 | | -import { ConfirmEmail } from "./ConfirmEmail.ts"; |
9 | | -import type { BackendLambdas } from "./lambdas/packBackendLambdas.ts"; |
10 | | -import { Registrations } from "./Registrations.ts"; |
11 | | -import { LambdaSource } from "@bifravst/aws-cdk-lambda-helpers/cdk"; |
12 | | -import { Register } from "./Register.ts"; |
13 | | -import { type PackedLayer } from "@bifravst/aws-cdk-lambda-helpers/layer"; |
14 | | -import { PublicProfiles } from "./PublicProfiles.ts"; |
15 | | -import { ParticipantsList } from "./ParticipantsList.ts"; |
| 4 | + App, |
| 5 | + CfnOutput, |
| 6 | + aws_lambda as Lambda, |
| 7 | + aws_s3 as S3, |
| 8 | + Stack, |
| 9 | +} from 'aws-cdk-lib' |
| 10 | +import { ConfirmEmail } from './ConfirmEmail.ts' |
| 11 | +import type { BackendLambdas } from './lambdas/packBackendLambdas.ts' |
| 12 | +import { ParticipantsList } from './ParticipantsList.ts' |
| 13 | +import { PublicProfiles } from './PublicProfiles.ts' |
| 14 | +import { Register } from './Register.ts' |
| 15 | +import { Registrations } from './Registrations.ts' |
16 | 16 |
|
17 | 17 | export class BackendStack extends Stack { |
18 | | - public constructor( |
19 | | - parent: App, |
20 | | - stackName: string, |
21 | | - { |
22 | | - lambdas, |
23 | | - packedLayer, |
24 | | - }: { lambdas: BackendLambdas; packedLayer: PackedLayer } |
25 | | - ) { |
26 | | - super(parent, stackName); |
| 18 | + public constructor( |
| 19 | + parent: App, |
| 20 | + stackName: string, |
| 21 | + { |
| 22 | + lambdas, |
| 23 | + packedLayer, |
| 24 | + }: { lambdas: BackendLambdas; packedLayer: PackedLayer }, |
| 25 | + ) { |
| 26 | + super(parent, stackName) |
27 | 27 |
|
28 | | - const registrations = new Registrations(this); |
| 28 | + const registrations = new Registrations(this) |
29 | 29 |
|
30 | | - const layer = new Lambda.LayerVersion(this, "layer", { |
31 | | - layerVersionName: `${Stack.of(this).stackName}-layer`, |
32 | | - code: new LambdaSource(this, { |
33 | | - id: "layer", |
34 | | - zipFilePath: packedLayer.layerZipFilePath, |
35 | | - hash: packedLayer.hash, |
36 | | - }).code, |
37 | | - compatibleArchitectures: [Lambda.Architecture.ARM_64], |
38 | | - compatibleRuntimes: [Lambda.Runtime.NODEJS_22_X], |
39 | | - }); |
| 30 | + const layer = new Lambda.LayerVersion(this, 'layer', { |
| 31 | + layerVersionName: `${Stack.of(this).stackName}-layer`, |
| 32 | + code: new LambdaSource(this, { |
| 33 | + id: 'layer', |
| 34 | + zipFilePath: packedLayer.layerZipFilePath, |
| 35 | + hash: packedLayer.hash, |
| 36 | + }).code, |
| 37 | + compatibleArchitectures: [Lambda.Architecture.ARM_64], |
| 38 | + compatibleRuntimes: [Lambda.Runtime.NODEJS_22_X], |
| 39 | + }) |
40 | 40 |
|
41 | | - const confirmEmail = new ConfirmEmail(this, { |
42 | | - lambdas, |
43 | | - registrations, |
44 | | - layer, |
45 | | - }); |
| 41 | + const confirmEmail = new ConfirmEmail(this, { |
| 42 | + lambdas, |
| 43 | + registrations, |
| 44 | + layer, |
| 45 | + }) |
46 | 46 |
|
47 | | - const register = new Register(this, { |
48 | | - lambdas, |
49 | | - registrations, |
50 | | - layer, |
51 | | - }); |
| 47 | + const register = new Register(this, { |
| 48 | + lambdas, |
| 49 | + registrations, |
| 50 | + layer, |
| 51 | + }) |
52 | 52 |
|
53 | | - const imageMagickLayer = new Lambda.LayerVersion( |
54 | | - this, |
55 | | - "imagemagick-layer", |
56 | | - { |
57 | | - code: Lambda.Code.fromBucket( |
58 | | - S3.Bucket.fromBucketName( |
59 | | - this, |
60 | | - "imagemagickLayerBucket", |
61 | | - // Must be in same region as the stack |
62 | | - "imagemagick-layer" |
63 | | - ), |
64 | | - // This is created using https://github.com/CyprusCodes/imagemagick-aws-lambda-2 |
65 | | - "layer.zip" |
66 | | - ), |
67 | | - } |
68 | | - ); |
| 53 | + const imageMagickLayer = new Lambda.LayerVersion( |
| 54 | + this, |
| 55 | + 'imagemagick-layer', |
| 56 | + { |
| 57 | + code: Lambda.Code.fromBucket( |
| 58 | + S3.Bucket.fromBucketName( |
| 59 | + this, |
| 60 | + 'imagemagickLayerBucket', |
| 61 | + // Must be in same region as the stack |
| 62 | + 'imagemagick-layer', |
| 63 | + ), |
| 64 | + // This is created using https://github.com/CyprusCodes/imagemagick-aws-lambda-2 |
| 65 | + 'layer.zip', |
| 66 | + ), |
| 67 | + }, |
| 68 | + ) |
69 | 69 |
|
70 | | - const publicProfiles = new PublicProfiles(this, { |
71 | | - imageMagickLayer, |
72 | | - lambdas, |
73 | | - layer, |
74 | | - registrations, |
75 | | - }); |
| 70 | + const publicProfiles = new PublicProfiles(this, { |
| 71 | + imageMagickLayer, |
| 72 | + lambdas, |
| 73 | + layer, |
| 74 | + registrations, |
| 75 | + }) |
76 | 76 |
|
77 | | - const participantsList = new ParticipantsList(this, { |
78 | | - lambdas, |
79 | | - layer, |
80 | | - registrations, |
81 | | - }); |
| 77 | + const participantsList = new ParticipantsList(this, { |
| 78 | + lambdas, |
| 79 | + layer, |
| 80 | + registrations, |
| 81 | + }) |
82 | 82 |
|
83 | | - new CfnOutput(this, "requestTokenAPI", { |
84 | | - value: confirmEmail.requestTokenURL.url, |
85 | | - exportName: `${this.stackName}:requestTokenAPI`, |
86 | | - }); |
| 83 | + new CfnOutput(this, 'requestTokenAPI', { |
| 84 | + value: confirmEmail.requestTokenURL.url, |
| 85 | + exportName: `${this.stackName}:requestTokenAPI`, |
| 86 | + }) |
87 | 87 |
|
88 | | - new CfnOutput(this, "confirmEmailURL", { |
89 | | - value: confirmEmail.confirmEmailURL.url, |
90 | | - exportName: `${this.stackName}:confirmEmailURL`, |
91 | | - }); |
| 88 | + new CfnOutput(this, 'confirmEmailURL', { |
| 89 | + value: confirmEmail.confirmEmailURL.url, |
| 90 | + exportName: `${this.stackName}:confirmEmailURL`, |
| 91 | + }) |
92 | 92 |
|
93 | | - new CfnOutput(this, "registerURL", { |
94 | | - value: register.registerURL.url, |
95 | | - exportName: `${this.stackName}:registerURL`, |
96 | | - }); |
| 93 | + new CfnOutput(this, 'registerURL', { |
| 94 | + value: register.registerURL.url, |
| 95 | + exportName: `${this.stackName}:registerURL`, |
| 96 | + }) |
97 | 97 |
|
98 | | - new CfnOutput(this, "publicProfilesURL", { |
99 | | - value: publicProfiles.listPublicProfilesURL.url, |
100 | | - exportName: `${this.stackName}:publicProfilesURL`, |
101 | | - }); |
| 98 | + new CfnOutput(this, 'publicProfilesURL', { |
| 99 | + value: publicProfiles.listPublicProfilesURL.url, |
| 100 | + exportName: `${this.stackName}:publicProfilesURL`, |
| 101 | + }) |
102 | 102 |
|
103 | | - new CfnOutput(this, "listParticipantEmailsURL", { |
104 | | - value: participantsList.listParticipantEmailsURL.url, |
105 | | - exportName: `${this.stackName}:listParticipantEmailsURL`, |
106 | | - }); |
107 | | - } |
| 103 | + new CfnOutput(this, 'listParticipantEmailsURL', { |
| 104 | + value: participantsList.listParticipantEmailsURL.url, |
| 105 | + exportName: `${this.stackName}:listParticipantEmailsURL`, |
| 106 | + }) |
| 107 | + } |
108 | 108 | } |
109 | 109 |
|
110 | 110 | export type StackOutputs = { |
111 | | - requestTokenAPI: string; |
112 | | - confirmEmailURL: string; |
113 | | -}; |
| 111 | + requestTokenAPI: string |
| 112 | + confirmEmailURL: string |
| 113 | +} |
0 commit comments