# 5.1.3 Deploy a RESTful API

이번 실습에서는 Amazon API Gateway를 사용하여 이전 모듈에서 빌드한 Lambda 함수를 RESTful API로 노출할 수 있도록 하는 실습을 진행하겠습니다. 이 과정을 통해 공용 인터넷에서 액세스할 수 있게 되며, 이전 실습에서 생성한 Amazon Cognito 사용자 풀을 사용하여 보호됩니다.

Amazon API Gateway는 개발자가 API를 손쉽게 생성, 게시, 유지 관리, 모니터링 및 보안 유지할 수 있도록 하는 완전관리형 서비스입니다. API Gateway는 트래픽 관리, CORS 지원, 권한 부여 및 액세스 제어, 제한 모니터링 및 API 버전 관리 등 최대 수십만 개의 동시 API 호출을 수신 및 처리하는 데 관계된 모든 작업을 처리합니다.

<figure><img src="/files/qLxKlP26VdqFrLOsrfKy" alt=""><figcaption></figcaption></figure>

1. AWS 콘솔에 접속하여 API Gateway로 이동합니다.
2. 우상단의 API 생성을 클릭한 후 API 유형은 REST API에 있는 **구축 버튼**을 클릭합니다.

<figure><img src="/files/PeFwQYMjOgvLyLUa9pLl" alt=""><figcaption></figcaption></figure>

3. 이후 프로토콜은 **REST**, **새 API**를 체크한 후 기억하기 쉬운 이름과 설명을 입력한 후 API를 생성합니다.

<figure><img src="/files/92KTrYGTfl5tpdJrECB7" alt=""><figcaption></figcaption></figure>

4. API Gateway가 생성되면 아래 순서로 **리소스 및 메서드 설정**을 진행합니다.&#x20;
5. 작업 - 메서드 생성

<figure><img src="/files/zsTcB4iDfhsqphudsbvG" alt=""><figcaption></figcaption></figure>

6. 작업 - 리소스 생성 - 프록시 리소스로 구성 체크 , API Gateway CORS 활성화 체크

<figure><img src="/files/N7N6FAnP1sKhAPEVbCjA" alt=""><figcaption></figcaption></figure>

7. 작업 - 리소스 생성 - 기본 설정에 Lambda 함수 이름 지정 후 저장

<figure><img src="/files/fsRj01kMMserBR0Ayqdw" alt=""><figcaption></figcaption></figure>

8. 작업 - API 배포 - 배포 스테이지 \[새 스테이지] - 이름 입력 후 배포를 진행하면 Invoke URL을 얻을 수 있습니다.

<figure><img src="/files/JGiSayZqEoOu4OMM31Wh" alt=""><figcaption></figcaption></figure>

9. 배포가 완료되면 스테이지 편집기에 URL이 표시됩니다. 표시된 URL에  접속하면 AWS Lambda에 배포한 백엔드에서 정적 페이지를 반환하여 표시하는 것을 확인할 수 있습니다.

<figure><img src="/files/xyl9ps7limCwsQKuPVts" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cheolmin-ki.gitbook.io/sagemaker-image-workshop/lab5.-build-application-with-your-model/5.1-build-web-application-with-custom-model-endpoint/5.1.3-deploy-a-restful-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
