Amazon API Gateway는 규모와 관계없이 REST 및 WebSocket API를 생성, 게시, 유지, 모니터링 및 보호하기 위한 AWS 서비스입니다. API 개발자는 AWS 또는 다른 웹 서비스를 비롯해 AWS 클라우드에 저장된 데이터에 액세스하는 API를 생성할 수 있습니다. API Gateway API 개발자는 자체 클라이언트 애플리케이션에서 사용할 API를 생성할 수 있습니다. 또는 타사 앱 개발자가 API를 사용하도록 제공도 가능합니다.
이제 이전에 작업으로 ECR에 Lambda를 배포 하였으니,
https://velog.io/@cjswo9207/AWS-ECR%EC%97%90%EC%84%9C-Lambda%EB%A1%9C-%EB%B0%B0%ED%8F%AC%ED%95%98%EA%B8%B0
이후 작업을 통해서 내/외부의 API작업을 등록하여 테스트를 할 수 있도록 하겠습니다.
APT Gateway생성(지역으로)
리소스에 POST로 생성한 Lambda를 넣어줌.
*. 리소스 정책 예시
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "execute-api:Invoke",
"Resource": "*"
}
]
}
import requests
import json
url = "https://{}.execute-api.ap-northeast-2.amazonaws.com/autogluon"
payload = json.dumps({})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
*. api key 설정
AWS Management Console에 로그인하고 https://console.aws.amazon.com/apigateway/에서 API Gateway 콘솔을 엽니다.
그런 이후
그렇게 하면 API GateWay의 적용 및 api-key 적용이 끝나게 됩니다.
성공적으로 테스트를 해보시면 되겠습니다.
감사합니다.
참고사이트
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-resource-policies-create-attach.html
https://docs.aws.amazon.com/ko_kr/apigateway/latest/developerguide/api-gateway-setup-api-key-with-console.html