go
#use brew
brew install go
brew upgrade go
go to
Download
mkdir ~/go
echo "export GOPATH=\$HOME/go" >> ~/.bash_profile
source ~/.bash_profile
mkdir ~/go/helloworld
cd ~/go/helloworld
touch helloworld.go
go get github.com/aws/aws-lambda-go/lambda
package main
import (
"fmt"
"github.com/aws/aws-lambda-go/lambda"
)
func main() {
lambda.Start(Hello)
}
func Hello() {
fmt.Println("Hello lambda")
}
go build helloworld.go
zip helloworld.zip helloworld
{
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
}
aws configure
aws ecr get-login --no-include-email --region "region_name"
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 iam get-role --role-name lambda-basic-execution
#or
aws lambda create-function \
--function-name helloworld_go \
--zip-file fileb://helloworld.zip \
--handler helloworld \
--runtime go1.x \
--role "arn:aws:iam::<YOUR_ACCOUNT_ID>:role/lambda-basic-execution"
aws lambda invoke \
--function-name helloworld_go \
--invocation-type "RequestResponse" \
response.txt