while(1) work();
article thumbnail
반응형

serverless framework를 이용해 lambda function + API Gateway가 포함된 cloudformation을 관리하고 있다.

기본적으로 AWS가 제공하는 도메인이 엔드포인트로 지정되지만, serverless-domain-manager 플러그인을 이용해 커스텀 도메인을 연결할 수 있다.

 

하지만, 결론부터 말하자면 실패했다.

 

먼저 도메인 연결을 위해서는 Route53에 도메인이 등록되어 있어야 한다.

Route53은 kr도메인 신규 등록/이전을 지원하지 않으므로 타사에서 등록 후 네임서버를 AWS네임서버로 바꿔

Route53에 호스팅을 등록하였다.

 

그런 다음 Certification Manager를 이용하여 인증서를 생성하였다.

(SSL 퍼블릭 인증서는 무료이다.)

 

그리고, serverless-domain-manager를 설치하고(npm install --save-dev serverless-domain-manager)

serverless.yml에 아래와 같이 설정하였다.

 

plugins:
  - serverless-offline
  - serverless-domain-manager
  
custom:
  customDomain:
    domainName: api.oooooo.kr
    route53Region: ap-northeast-2
    stage: ${self:provider.stage}
    certificateName: '*.oooooo.kr'
    createRoute53Record: false
    certificateArn: 'arn:aws:acm:us-east-1:oooo:certificate/f5acoooo1f'
    endpointType: regional

 

그러고 나서 serverless create_domain 명령을 입력해

API Gateway에 사용자 도메인을 새로 생성했다.

 

이제, serverless deploy를 입력하면 API Gateway에 생성한 커스텀 도메인이, API Gateway의 스테이지에 연결되어야 한다.

 

하지만 아래와 같은 오류가 발생하였다.

 

Error: Unable to create domain 'api.ooooo.kr':
API Gateway V1 failed to create custom domain 'api.ooooo.kr':
Invalid certificate ARN: arn:aws:acm:ap-northeast-2:ooooo:certificate/bc3929a6-ooooo. Certificate must be in 'us-east-1'.

 

 

찾아보니 Certification Manager에서 인증서를 생성할 때 서울 리전에서 생성하면 안되고

us-east-1 리전에서 생성해야 한다고 한다....

특별한 이유는 없고 serverless-domain-manager가 us-east-1 리전만 지원하는듯.

 

어쩔 수 없이 인증서만 해당 리전에 생성하고 다시 deploy를 시도하였다.

 

Error: Unable to setup base domain mappings for 'api.ooooo.kr':
Failed to find CloudFormation resources for 'api.ooooo.kr':
Failed to find a stack ooooo-dev

 

 

하지만 여전히 실패..

serverless.yml에 endpointType을 대문자로 입력해야 한다고 한다...ㅎㅎ;;;

endpointType: REGIONAL

으로 해당 라인을 변경후 다시 시도하였다.

 

 

Error: Unable to setup base domain mappings for 'api.ooooo.kr':
Unable to create base path mapping for 'api.ooooo.kr':
Only REGIONAL domain names can be managed through the API Gateway V2 API. For EDGE domain names, please use the API Gateway V1 API. Also note that only REST APIs can be attached to EDGE domain names.

 

 

어림도 없지.

REGIONAL 도메인은 같은 지역의 인증서만 연결할 수 있다고 한다.

실제로 AWS 콘솔에서도 도메인을 지역으로 설정하면 타 리전의 인증서가 조회되지 않는다.

 

 

그렇다고 엣지 최적화 리전을 사용하려면..

API Gateway v2가 아닌 v1을 사용해야 하는 상황이라

결국 serverless-domain-manager 사용을 포기했다.

 

해당 플로그인이 인증서 지역을 설정할 수 있게 지원만 해주었더라면

다 해결될 문제인데.. 참 아쉽다.

반응형
profile

while(1) work();

@유호건

❤️댓글은 언제나 힘이 됩니다❤️ 궁금한 점이나 잘못된 내용이 있다면 댓글로 남겨주세요.

검색 태그