-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #989 from guardian/mob/obligatron
Create "obligatron" lambda
- Loading branch information
Showing
17 changed files
with
710 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import type { GuStack } from '@guardian/cdk/lib/constructs/core'; | ||
import type { GuSecurityGroup } from '@guardian/cdk/lib/constructs/ec2'; | ||
import { GuLambdaFunction } from '@guardian/cdk/lib/constructs/lambda'; | ||
import { Duration } from 'aws-cdk-lib'; | ||
import type { IVpc } from 'aws-cdk-lib/aws-ec2'; | ||
import { Architecture, Runtime } from 'aws-cdk-lib/aws-lambda'; | ||
import type { DatabaseInstance } from 'aws-cdk-lib/aws-rds'; | ||
|
||
type ObligatronProps = { | ||
vpc: IVpc; | ||
dbAccess: GuSecurityGroup; | ||
db: DatabaseInstance; | ||
}; | ||
|
||
export class Obligatron { | ||
constructor(stack: GuStack, props: ObligatronProps) { | ||
const { vpc, dbAccess, db } = props; | ||
const app = 'obligatron'; | ||
|
||
const lambda = new GuLambdaFunction(stack, 'obligatron', { | ||
app, | ||
vpc, | ||
architecture: Architecture.ARM_64, | ||
runtime: Runtime.NODEJS_20_X, | ||
securityGroups: [dbAccess], | ||
fileName: `${app}.zip`, | ||
handler: 'index.main', | ||
environment: { | ||
DATABASE_HOSTNAME: db.dbInstanceEndpointAddress, | ||
QUERY_LOGGING: 'false', // Set this to 'true' to enable SQL query logging | ||
}, | ||
timeout: Duration.minutes(5), | ||
// Unfortunately Prisma doesn't support streaming data from Postgres at the moment https://github.com/prisma/prisma/issues/5055 | ||
// This means that all rows need to be loaded into memory at the same time whenever a query is ran hence the high memory requirement. | ||
memorySize: 4096, | ||
}); | ||
|
||
db.grantConnect(lambda, 'obligatron'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
index.js | ||
|
||
# Generated files | ||
dist |
Oops, something went wrong.