AWS

[AWS] SAM Deployment Guide

효진인데요 2024. 2. 2. 17:48

 

 

1. 설치 작업

 

 

2. private s3 버킷 생성

> 압축된 람다 함수와 압축된 템플릿을 넣기 위함

 

 

3. git clone 하기

git clone https://github.com/awslabs/aws-api-gateway-developer-portal.git
cd aws-api-gateway-developer-portal

 

 

4. 사용하는 IDE에서 디렉토리 열고 template.yaml 파일 찾기


5. 터미널 열어서 SAM CLI 명령어 실행

 


# macOS, Linux, and similar
sam package --template-file ./cloudformation/template.yaml \
    --output-template-file ./cloudformation/packaged.yaml \
    --s3-bucket "YOUR_LAMBDA_ARTIFACTS_BUCKET"

 


윈도우
rem Windows
sam package --template-file .\cloudformation\template.yaml ^
    --output-template-file .\cloudformation\packaged.yaml ^
    --s3-bucket "YOUR_LAMBDA_ARTIFACTS_BUCKET"

 

 

 

6. 배포하기 위해 이어서 다음 명령어 실행


# macOS, Linux, and similar
sam deploy --template-file ./cloudformation/packaged.yaml \
    --stack-name "dev-portal" \
    --s3-bucket "YOUR_LAMBDA_ARTIFACTS_BUCKET" \
    --capabilities CAPABILITY_NAMED_IAM \
    --parameter-overrides \
    DevPortalSiteS3BucketName="YOUR_CUSTOM_PREFIX-dev-portal-static-assets" \
    ArtifactsS3BucketName="YOUR_CUSTOM_PREFIX-dev-portal-artifacts" \
    CognitoDomainNameOrPrefix="YOUR_CUSTOM_PREFIX"

 

 

윈도우
rem Windows
sam deploy --template-file .\cloudformation\packaged.yaml ^
    --stack-name "dev-portal" ^
    --s3-bucket "YOUR_LAMBDA_ARTIFACTS_BUCKET" ^
    --capabilities CAPABILITY_NAMED_IAM ^
    --parameter-overrides ^
    DevPortalSiteS3BucketName="YOUR_CUSTOM_PREFIX-dev-portal-static-assets" ^
    ArtifactsS3BucketName="YOUR_CUSTOM_PREFIX-dev-portal-artifacts" ^
    CognitoDomainNameOrPrefix="YOUR_CUSTOM_PREFIX"

 

 

 

이때 CAPABILITY_NAMED_IAM  에도 값을 넣어야 함 placeholder 아님~

 

 



https://docs.aws.amazon.com/ko_kr/serverless-application-model/latest/developerguide/sam-cli-command-reference-sam-deploy.html

 

sam deploy - AWS Serverless Application Model

AWS SAM이 이 옵션을 사용하여 함수 또는 레이어에 대한 Amazon ECR 리포지토리를 자동으로 생성하고 나중에 AWS SAM 템플릿에서 해당 함수 또는 레이어를 삭제하면 해당 Amazon ECR 리포지토리가 자동으

docs.aws.amazon.com

 

 

 

 

7.  AWS CLI 설치했으면 명령어 실행

# macOS, Linux, and similar
aws cloudformation describe-stacks --query \
    "Stacks[?StackName=='dev-portal'][Outputs[?OutputKey=='WebsiteURL']][][].OutputValue"

 

 

윈도우

rem Windows
aws cloudformation describe-stacks --query ^
    "Stacks[?StackName=='dev-portal'][Outputs[?OutputKey=='WebsiteURL']][][].OutputValue"

 

 

 

설치 안되어있으면 CloudFormation 콘솔을 열고 개발자 포털의 스택을 열고 "출력" 탭으로 이동

"WebsiteURL"을 검색

URL이 클릭 가능한 링크로 표시됨

 

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>참고

https://github.com/awslabs/aws-api-gateway-developer-portal/blob/main/BUILDING_SAM.md

 

728x90

'AWS' 카테고리의 다른 글

[AWS] Lambda 모듈 사용법 (cannot find module error)  (0) 2024.01.29
[AWS] API Gateway란?  (0) 2024.01.24
[AWS] Lambda 함수란?  (0) 2024.01.19