Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
feat: ✨ remove RNG kludge
Browse files Browse the repository at this point in the history
  • Loading branch information
ecxyzzy committed Feb 6, 2024
1 parent dfb6511 commit 7f1cc2e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 43 deletions.
42 changes: 19 additions & 23 deletions apps/api/bronya.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,31 +150,27 @@ export const esbuildOptions: BuildOptions = {
* Shared construct props.
*/
export const constructs: ApiConstructProps = {
functionProps: (scope, id) => ({
functionProps: (scope, id, route) => ({
runtime: Runtime.NODEJS_20_X,
role: new Role(
scope,
`${id}-${Number.parseInt(Math.random().toString().slice(2)).toString(16).padStart(14, "0")}-role`,
{
assumedBy: new ServicePrincipal("lambda.amazonaws.com"),
managedPolicies: [
ManagedPolicy.fromAwsManagedPolicyName("service-role/AWSLambdaBasicExecutionRole"),
],
inlinePolicies: {
lambdaInvokePolicy: new PolicyDocument({
statements: [
new PolicyStatement({
effect: Effect.ALLOW,
resources: [
`arn:aws:dynamodb:${process.env["AWS_REGION"]}:${process.env["ACCOUNT_ID"]}:table/${id}-cache`,
],
actions: ["dynamodb:GetItem", "dynamodb:PutItem"],
}),
],
}),
},
role: new Role(scope, `${id}-${route.endpoint}-role`, {
assumedBy: new ServicePrincipal("lambda.amazonaws.com"),
managedPolicies: [
ManagedPolicy.fromAwsManagedPolicyName("service-role/AWSLambdaBasicExecutionRole"),
],
inlinePolicies: {
lambdaInvokePolicy: new PolicyDocument({
statements: [
new PolicyStatement({
effect: Effect.ALLOW,
resources: [
`arn:aws:dynamodb:${process.env["AWS_REGION"]}:${process.env["ACCOUNT_ID"]}:table/${id}-cache`,
],
actions: ["dynamodb:GetItem", "dynamodb:PutItem"],
}),
],
}),
},
),
}),
}),
functionPlugin: ({ functionProps, handler }, scope) => {
const warmingTarget = new LambdaFunction(handler, {
Expand Down
35 changes: 15 additions & 20 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7f1cc2e

Please sign in to comment.