This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from hayd/sam-example
Add SAM example
- Loading branch information
Showing
4 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.deno_dir/gen/file | ||
node_modules | ||
package-lock.json | ||
template.yml | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SAM | ||
|
||
An example [Serverless Application Model](https://aws.amazon.com/serverless/sam/) template. | ||
|
||
### Deploy via | ||
|
||
```sh | ||
# Prior to deploy compile the application into .deno_dir. | ||
# (ensure you're using the same version of deno as deno-lambda.) | ||
DENO_DIR=.deno_dir deno fetch hello.ts | ||
cp -R .deno_dir/gen/file/$PWD/ .deno_dir/LAMBDA_TASK_ROOT | ||
sam deploy --stack-name YOUR_APP_NAME --s3-bucket YOUR_BUCKET_NAME --s3-prefix YOUR_PREFIX --capabilities CAPABILITY_IAM CAPABILITY_AUTO_EXPAND | ||
``` | ||
|
||
Note: The stack can only deploy to the same region as the s3 bucket. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { | ||
APIGatewayProxyEvent, | ||
APIGatewayProxyResult, | ||
Context | ||
} from "https://deno.land/x/lambda/mod.ts"; | ||
|
||
export async function handler( | ||
event: APIGatewayProxyEvent, | ||
context: Context | ||
): Promise<APIGatewayProxyResult> { | ||
return { | ||
statusCode: 200, | ||
headers: { "content-type": "text/html;charset=utf8" }, | ||
body: `Hello World! Sent from deno ${Deno.version.deno} 🦕` | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
AWSTemplateFormatVersion: '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
Description: > | ||
sam-hello | ||
Sample SAM Template for hello.ts | ||
Resources: | ||
Deno: | ||
Type: AWS::Serverless::Application | ||
Properties: | ||
Location: | ||
ApplicationId: arn:aws:serverlessrepo:us-east-1:390065572566:applications/deno | ||
SemanticVersion: 0.8.0 | ||
|
||
HelloWorldFunction: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
CodeUri: . | ||
MemorySize: 128 | ||
Handler: hello.handler | ||
Runtime: provided | ||
Layers: | ||
- !GetAtt Deno.Outputs.DenoArn | ||
Events: | ||
ApiEvent: | ||
Type: HttpApi |