Skip to content
This repository has been archived by the owner on Jun 3, 2023. It is now read-only.

Commit

Permalink
Extract LAMBDA_DEFAULTS
Browse files Browse the repository at this point in the history
  • Loading branch information
mlafeldt committed Aug 31, 2021
1 parent f8b72d9 commit 805e12e
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ import * as ssm from '@aws-cdk/aws-ssm'
import * as targets from '@aws-cdk/aws-events-targets'
import * as tasks from '@aws-cdk/aws-stepfunctions-tasks'

const LAMBDA_DEFAULTS = {
handler: 'bootstrap',
runtime: lambda.Runtime.PROVIDED_AL2,
memorySize: 128,
timeout: cdk.Duration.seconds(10),
logRetention: logs.RetentionDays.ONE_MONTH,
}

export class DilbertFeedStack extends cdk.Stack {
constructor(scope: cdk.App, id: string, props: cdk.StackProps) {
super(scope, id, props)
Expand All @@ -27,13 +35,9 @@ export class DilbertFeedStack extends cdk.Stack {
})

const getStrip = new lambda.Function(this, 'GetStripFunc', {
...LAMBDA_DEFAULTS,
functionName: `${id}-get-strip`,
code: lambda.Code.fromAsset('bin/get-strip'),
handler: 'bootstrap',
runtime: lambda.Runtime.PROVIDED_AL2,
memorySize: 128,
timeout: cdk.Duration.seconds(10),
logRetention: logs.RetentionDays.ONE_MONTH,
environment: {
BUCKET_NAME: bucket.bucketName,
STRIPS_DIR: stripsDir,
Expand All @@ -43,13 +47,9 @@ export class DilbertFeedStack extends cdk.Stack {
bucket.grantPut(getStrip)

const genFeed = new lambda.Function(this, 'GenFeedFunc', {
...LAMBDA_DEFAULTS,
functionName: `${id}-gen-feed`,
code: lambda.Code.fromAsset('bin/gen-feed'),
handler: 'bootstrap',
runtime: lambda.Runtime.PROVIDED_AL2,
memorySize: 128,
timeout: cdk.Duration.seconds(10),
logRetention: logs.RetentionDays.ONE_MONTH,
environment: {
BUCKET_NAME: bucket.bucketName,
STRIPS_DIR: stripsDir,
Expand All @@ -61,13 +61,9 @@ export class DilbertFeedStack extends cdk.Stack {

const heartbeatEndpoint = ssm.StringParameter.valueForStringParameter(this, `/${id}/heartbeat-endpoint`)
const heartbeat = new lambda.Function(this, 'HeartbeatFunc', {
...LAMBDA_DEFAULTS,
functionName: `${id}-heartbeat`,
code: lambda.Code.fromAsset('bin/heartbeat'),
handler: 'bootstrap',
runtime: lambda.Runtime.PROVIDED_AL2,
memorySize: 128,
timeout: cdk.Duration.seconds(10),
logRetention: logs.RetentionDays.ONE_MONTH,
environment: {
HEARTBEAT_ENDPOINT: heartbeatEndpoint,
RUST_LOG: 'info',
Expand Down

0 comments on commit 805e12e

Please sign in to comment.