환경 셋팅
$ brew tap aws/tap
$ brew install aws-sam-cli
$ brew install esbuild
초기 설정
$ sam init
error > AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'
→ $ /opt/homebrew/Cellar/aws-sam-cli/1.67.0/libexec/bin/pip install --force-reinstall "cryptography==38.0.4"
빌드 (template.yaml 파일이 위치한곳) ← brew install esbuild 가 우선적으로 필요하다
$ sam build
로컬 테스트
$ sam local start-api -p 8080
배포
$ sam deploy -g
$ sam deploy --guide template.yaml 파일을 참고하여 배포함. 첫 배포 후 samconfig.toml 파일 생성사전에 생성된 `samconfig.toml` 파일을 기반으로 배포한다. error case 1
처음에 옵션 g 를 추가해서 배포하면 cloudformation에 stack이 쌓이는데, 다음에 deploy를 할때 samConfig.toml 파일을 기반으로 deploy를 하기 때문에, 동일 스택에 쌓인다.
→ 다음에 deploy를 할때 g 옵션을 달면, 동일 스택이 있다고 취급하고, 배포가 되지 않는다.
```
Error: Unable to upload artifact HelloWorldFunction referenced by CodeUri parameter of HelloWorldFunction resource.
S3 Bucket does not exist.
```
다음과 같은 에러가 발생하면 aws-cloudformation 에서 해당 스택을 지워준다.
error case 2
Error: Security Constraints Not Satisfied! 해당 에러가 나는 것은 y 가 아니라 그냥 무조건적으로 enter 를 눌러서 그렇다
https://stackoverflow.com/questions/61841136/what-is-the-cause-of-the-security-constraints-not-satisfied-error-when-using-sam
새로운 lambda 함수가 생긴다.

우리가 사용하는 MQ는 모두 private subnet 였기 때문에, lambda에서 vpc 설정을 안해주면 private MQ에 메세지를 보낼 수 없다.
vpc, subnet, 보안그룹 설정 필요

https://bobbyhadz.com/blog/aws-lambda-provided-execution-role-does-not-have-permissions
템플릿을 생성하여 AWS에서 필요한 리소스 및 속성을 관리
람다함수에서 필요한 기본 템플릿 제공, 빌드 및 배포, 각 람다함수에서 필요한 트리거 및 속성을 관리할 수 있는 서비스
sam 으로 deploy를 하면 메인 함수만 올리기 때문에 env 파일을 같이 올릴 수 없다.
→ 따로 env key 를 관리할 수 있는 서비스필요
aws secrets manager
How to use AWS secret manager and SES with AWS SAM
cloudformation
Deploying a Lambda with CloudFormation - Octopus Deploy
How to auto-scale an AWS lambda using auto-scaling service
람다는 자동적으로 auto scaling을 해준다.