AWS lambda guide 확인하여 초기 파일과 로컬 테스트 및 컨테이너 이미지 배포

Local test

GOOS=linux GOARCH=amd64 go build -o main main.go
docker build -t docker-image:test .
docker run -p 9000:8080 docker-image:test
curl -XPOST "<http://localhost:9000/2015-03-31/functions/function/invocations>" -d '{}'

스크린샷 2023-07-01 오후 6.42.03.png

Deploy image

AWS IAM 권한 설정

aws configure
aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin 111122223333.dkr.ecr.ap-northeast-2.amazonaws.com

docker tag docker-image:test 111122223333.dkr.ecr.ap-northeast-2.amazonaws.com/mz-backend:latest
docker push 111122223333.dkr.ecr.ap-northeast-2.amazonaws.com/mz-backend:latest
aws lambda invoke --function-name mz-backend response.json

Deploy .zip

https://docs.aws.amazon.com/lambda/latest/dg/golang-package.html

https://rhuaridh.co.uk/blog/deploy-golang-lambda-example.html