Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #35 from hayd/sam-example
Browse files Browse the repository at this point in the history
Add SAM example
  • Loading branch information
hayd authored Jan 16, 2020
2 parents 14a2b56 + c198f9a commit a4c33c0
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 0 deletions.
5 changes: 5 additions & 0 deletions example-sam/.npmignore
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
15 changes: 15 additions & 0 deletions example-sam/README.md
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.
16 changes: 16 additions & 0 deletions example-sam/hello.ts
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} 🦕`
};
}
27 changes: 27 additions & 0 deletions example-sam/template.yml
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

0 comments on commit a4c33c0

Please sign in to comment.