Skip to content

Commit e3f05af

Browse files
committed
Update README.md
1 parent e82a5dc commit e3f05af

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ Create `nodejs/src/index.ts`:
203203
import { Handler } from "aws-lambda";
204204

205205
export const handler: Handler = async (event, context) => {
206-
console.log("Hello world!");
207206
console.log({ event, context });
208207

209208
return {
@@ -404,7 +403,7 @@ docker compose up --abort-on-container-exit
404403
> [!NOTE]
405404
> On this execution you'll be able to confirm two of the values are working.
406405
> Find the Lambda `REPORT` log and you'll now see `Memory Size` and `Max Memory Used` are set to `128 MB` instead of the previous `3008 MB`.
407-
> Find the `Hello world!` log and you'll see it has now switched to a JSON structured log rather than just text.
406+
> Find the log for `event` and `context` and you'll see it has now switched to a JSON structured log rather than just broken text.
408407
409408
### Check the timeout
410409

@@ -497,6 +496,46 @@ LAMBDA_INPUT=@/events/api-gateway.json docker compose up --abort-on-container-ex
497496
> With each of these commands, you'll notice that the `curl` container receives a slightly different response where the event changes.
498497
> The first command we didn't include the `LAMBDA_INPUT` attribute, so you `docker-compose.yaml` default the input to `{}`.
499498
499+
### Add a new log
500+
501+
Update `nodejs/src/index.ts` to include a new log:
502+
503+
```typescript
504+
import { Handler } from "aws-lambda";
505+
506+
export const handler: Handler = async (event, context) => {
507+
console.log("Hello world!");
508+
console.log({ event, context });
509+
510+
return {
511+
statusCode: 200,
512+
body: { event, context },
513+
};
514+
};
515+
```
516+
517+
Run the following command:
518+
519+
```shell
520+
docker compose up --abort-on-container-exit
521+
```
522+
523+
> [!WARNING]
524+
> Where's the log? Nothing has actually updated.
525+
> As we're running the containers and stopping them each time, we need to let Docker know about any changes.
526+
527+
Run the following command:
528+
529+
```shell
530+
docker compose up --abort-on-container-exit --build
531+
```
532+
533+
> [!NOTE]
534+
> Now, each time we run the containers, Docker is re-building everything and picking up any new changes.
535+
536+
> [!TIP]
537+
> Even though Docker is technically re-building each and every time, if there are no new changes, Docker will use cached layers resulting in faster executions.
538+
500539
---
501540

502541
## 5. Optimisation

0 commit comments

Comments
 (0)