Created
January 6, 2020 16:23
-
-
Save toddlers/f6a04b4a8f86efebe6e2a82e7bb49b88 to your computer and use it in GitHub Desktop.
golang-lambda
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
mkdir helloworld | |
cd !$ | |
go get github.com/aws/aws-lambda-go/lambda | |
GOOS=linux go build -o helloworld | |
aws iam create-role --role-name lambda-basic-execution | |
--assume-role-policy-document file://lambda-trust-policy.json | |
aws iam attach-role-policy --role-name lambda-basic-execution | |
--policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole | |
aws lambda create-function \ | |
--function-name helloworld_go \ | |
--zip-file fileb://helloworld.zip \ | |
--handler helloworld \ | |
--runtime go1.x \ | |
--role "<ROLE_ARN>" | |
aws lambda invoke \ | |
--function-name helloworld_go \ | |
--invocation-type "RequestResponse" \ | |
response.txt |
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
package main | |
import "github.com/aws/aws-lambda-go/lambda" | |
func HandleRequest() (string, error) { | |
return "Hello from Go !", 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
{ | |
"Version": "2012-10-17", | |
"Statement": { | |
"Effect": "Allow", | |
"Principal": { | |
"Service": "lambda.amazonaws.com" | |
}, | |
"Action": "sts:AssumeRole" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment