Skip to content

ehok/GO-Sam-Example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting Started

Prerequisits

Building your function

For developers on Linux and macOS:

# Build handler executable for Linux
GOOS=linux GOARCH=amd64 go build

Local Test w/ SAM CLI

Run the serverless application locally for quick development and testing.

This command uses template.yml file as a reference.

sam local start-api

Create S3 Bucket & Set the variables

export REGION="<REGION>"
export S3_BUCKET="<BUCKET_NAME>"
export STACK_NAME="<STACK_NAME>"

# If you already have a S3 bucket skip below command
aws s3 mb --region $REGION s3://$S3_BUCKET

Package the SAM application

sam package \
    --template-file template.yml \
    --s3-bucket $S3_BUCKET \
    --region $REGION \
    --output-template-file packaged.yml

Deploy the SAM application

sam deploy \
    --template-file packaged.yml \
    --stack-name $STACK_NAME \
    --capabilities CAPABILITY_IAM \
    --region $REGION \
    --parameter-overrides AppId="test"

The --parameter-override option is not required, also can be specified on template.yml.

Clean Up

Delete the SAM application by deleting the AWS CloudFormation stack

sam delete \
    --stack-name $STACK_NAME \
    --region $REGION \
    --no-prompts

Remove all objects in S3 Bucket & Delete S3 Bucket

aws s3 rb s3://$S3_BUCKET --force

References:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages