Skip to content

Commit b7e811b

Browse files
committed
conditionally enable hotreloading
1 parent 618c435 commit b7e811b

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ logs:
6363
setup-challenge:
6464
yarn install
6565
make build
66-
make bootstrap
67-
make deploy
66+
IS_LOCAL_DEV=true make bootstrap
67+
IS_LOCAL_DEV=true make deploy
6868
make prepare-frontend-local
6969
make hotreload
7070

packages/infra/cdk/notes-api.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,19 @@ export class NotesApi extends Construct {
2121

2222
const { table, grantActions } = props;
2323

24+
const isLocalDev = process.env.IS_LOCAL_DEV;
25+
26+
const codeConfig = isLocalDev
27+
? lambda.Code.fromBucket(
28+
s3.Bucket.fromBucketName(this, "hot-reload", "hot-reload"),
29+
`${__dirname}/../../backend/dist/${id}`
30+
)
31+
: lambda.Code.fromAsset(`../backend/dist/${id}`);
32+
2433
this.handler = new lambda.Function(this, "handler", {
2534
runtime: lambda.Runtime.NODEJS_18_X,
2635
handler: "app.handler",
27-
// ToDo: find a better way to pass lambda code
28-
code: lambda.Code.fromBucket(
29-
s3.Bucket.fromBucketName(this, "hot-reload", "hot-reload"),
30-
`${__dirname}/../../backend/dist/${id}`
31-
),
36+
code: codeConfig,
3237
environment: {
3338
NOTES_TABLE_NAME: table.tableName,
3439
},

0 commit comments

Comments
 (0)