https://github.com/kaungmyathan22/golang-lambda-serverless
Simple golang lambda for testing aws serverless function
https://github.com/kaungmyathan22/golang-lambda-serverless
golang lambda serverless
Last synced: 3 months ago
JSON representation
Simple golang lambda for testing aws serverless function
- Host: GitHub
- URL: https://github.com/kaungmyathan22/golang-lambda-serverless
- Owner: kaungmyathan22
- Created: 2024-02-24T04:54:52.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-24T07:03:14.000Z (about 2 years ago)
- Last Synced: 2024-12-30T00:27:31.398Z (over 1 year ago)
- Topics: golang, lambda, serverless
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Running go on aws lambda
### 1. Create iam role for the lambda function
```bash
aws iam create-role \
--role-name lambda-ex \
--assume-role-policy-document '{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}'
```
### 2. Build go code
```bash
GOOS=linux GOARCH=amd64 go build -o bootstrap main.go
```
### 3. Create go lambda function
```bash
aws lambda create-function \
--function-name gosimple\
--runtime go1.x \
--role arn-no:role/your-created-role \
--handler bootstrap \
--zip-file fileb://./bootstrap.zip
```
### 3. In case you updated code and want to redeploy
```bash
aws lambda update-function-code --function-name gosimple --zip-file fileb://./dist/bootstrap.zip
```
### 4. Function executing or invocation.
```bash
aws lambda invoke \
--function-name gosimple \
--payload file://testdata/event.json \
--cli-binary-format raw-in-base64-out \
output.txt
```