Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/develop' into develop
- Loading branch information
Showing
6 changed files
with
101 additions
and
4 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
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
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,33 @@ | ||
# AWS SAM Hello World Example # | ||
|
||
A simple AWS SAM template that specifies a single Lambda function. | ||
|
||
## Usage ## | ||
|
||
To create and deploy the SAM Hello World example, first ensure that you've met the requirements described in the [root README](../../README.md). Then follow the steps below. | ||
|
||
### Build your package ### | ||
|
||
GOOS=linux go build -o main | ||
|
||
### Test your application locally ### | ||
|
||
Use [SAM Local](https://github.com/awslabs/aws-sam-local) to run your Lambda function locally: | ||
|
||
sam local invoke "HelloWorld" -e event.json | ||
|
||
### Package artifacts ### | ||
|
||
Run the following command, replacing `BUCKET-NAME` with the name of your bucket: | ||
|
||
sam package --template-file template.yaml --s3-bucket BUCKET-NAME --output-template-file packaged-template.yaml | ||
|
||
This creates a new template file, packaged-template.yaml, that you will use to deploy your serverless application. | ||
|
||
### Deploy to AWS CloudFormation ### | ||
|
||
Run the following command, replacing `MY-NEW-STACK` with a name for your CloudFormation stack. | ||
|
||
sam deploy --template-file packaged-template.yaml --stack-name MY-NEW-STACK --capabilities CAPABILITY_IAM | ||
|
||
This uploads your template to an S3 bucket and deploys the specified resources using AWS CloudFormation. |
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 @@ | ||
{ | ||
"key1": "value1", | ||
"key2": "value2", | ||
"key3": "value3" | ||
} |
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,22 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"context" | ||
"github.com/aws/aws-lambda-go/lambda" | ||
) | ||
|
||
type Event map[string]interface{} | ||
|
||
func HandleRequest(ctx context.Context, event Event) (string, error) { | ||
log.Print("value1 = ", event["key1"] ) | ||
log.Print("value2 = ", event["key2"] ) | ||
log.Print("value3 = ", event["key3"] ) | ||
|
||
return fmt.Sprintf("Hello World"), nil | ||
} | ||
|
||
func main() { | ||
lambda.Start(HandleRequest) | ||
} |
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,11 @@ | ||
AWSTemplateFormatVersion : '2010-09-09' | ||
Transform: AWS::Serverless-2016-10-31 | ||
|
||
Description: A simple Hello World Serverless project | ||
Resources: | ||
HelloWorld: | ||
Type: AWS::Serverless::Function | ||
Properties: | ||
Runtime: go1.x | ||
Handler: main | ||
CodeUri: . |