Skip to content

Commit ab2fce2

Browse files
committed
SAM: normalize to 'MyFunction' and comment on HTTP invocation
1 parent d43f51e commit ab2fce2

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ sam-http-run: # SAM: Run lambda locally as an HTTP server
7070
sam local start-api --template tests/sam/template.yaml --env-vars tests/sam/env.json
7171

7272
sam-http-ping: # SAM: Send curl command to SAM HTTP server
73-
curl --location 'http://localhost:3000/myapp' \
73+
curl --location 'http://localhost:3000/myfunction' \
7474
--header 'Content-Type: application/json' \
7575
--data '{"msg":"in a bottle"}'
7676

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Useful when the Lambda will sit behind an ALB, Function URL, or API Gateway. Th
6363
make sam-http-run
6464
```
6565

66-
This starts a server at `http://localhost:3000`. Requests must include a path, e.g. `/myapp`, but are arbitrary insofar as the lambda does not utilize them in the request payload.
66+
This starts a server at `http://localhost:3000`. Requests must include a path, e.g. `/myfunction`, but are arbitrary insofar as the lambda does not utilize them in the request payload.
6767

6868
3- In another terminal, perform an HTTP request via another `Makefile` command:
6969
```shell

tests/sam/env.json.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"MyApp": {}
2+
"MyFunction": {}
33
}

tests/sam/template.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
AWSTemplateFormatVersion: "2010-09-09"
22
Transform: AWS::Serverless-2016-10-31
33
Resources:
4-
MyApp:
4+
MyFunction:
55
Type: AWS::Serverless::Function
66
Properties:
77
PackageType: Image
88
Timeout: 900
99
MemorySize: 1024
10+
ImageUri: myfunction:latest
1011
Events:
11-
BagitApi:
12+
# NOTE: this Event handler is needed for HTTP invocations of the lambda, not direct invocations
13+
HTTPRequest:
1214
Type: HttpApi
1315
Properties:
1416
Path: /{proxy+}
1517
Method: ANY
16-
ImageUri: myapp:latest
1718
Environment:
1819
# While tests/sam/env.json is required for sensitive env vars, ALL env vars
1920
# used in the lambda must exist here as well, even just as "..." placeholders.
@@ -25,4 +26,4 @@ Resources:
2526
DockerContext: ../../. # Build Lambda Dockerfile
2627
DockerTag: latest
2728
Dockerfile: Dockerfile
28-
SamResourceId: MyApp
29+
SamResourceId: MyFunction

0 commit comments

Comments
 (0)