logo hsb.horse
← 블로그 목록으로 돌아가기

블로그

AWS Cross-Region VPC Peering 失敗ログ

大阪と東京のVPCピアリング設定でハマった。--peer-region忘れでfailed状態になり、削除もできなくなった件。

게시일: 수정일:

VPC 피어링, 다른 리전 간 설정에서 오랜만에 삽질했다.

환경은 이렇다.

  • Requester: ap-northeast-3 (오사카) / profile-requester
  • Accepter: ap-northeast-1 (도쿄) / profile-accepter

다른 계정 × 다른 리전. 귀찮은 패턴.

망한 것

create-vpc-peering-connection 실행. 성공한 것처럼 보이고 pcx-xxxxx가 발급됐다. Accepter 쪽에서 승인하려고 하니 NotFound 에러.

An error occurred (InvalidVpcPeeringConnectionID.NotFound) when calling the AcceptVpcPeeringConnection operation

확인핬더니 그 ID는 failed 상태였다. 삭제하려고 핬더니 InvalidStateTransition.

An error occurred (InvalidStateTransition) when calling the DeleteVpcPeeringConnection operation

failed에서 deleting으로 전환 불가. 손을 쓸 수 없다.

원인

—peer-region 지정을 잊었다. 크로스 리전의 경우 필수. 이게 없으면 AWS는 동일 리전 내 피어링으로 처리하고, 대상 VPC를 찾지 못해 즉시 failed가 된다.

failed 상태의 리소스는 수동 삭제 불가. 잠시 후 AWS가 알아서 지워준다.

올바른 명령어

Requester 쪽 (오사카)에서 생성:

Terminal window
aws ec2 create-vpc-peering-connection \
--region ap-northeast-3 \
--profile profile-requester \
--vpc-id vpc-requester-id \
--peer-vpc-id vpc-accepter-id \
--peer-owner-id 123456789012 \
--peer-region ap-northeast-1

Accepter 쪽 (도쿄)에서 승인:

Terminal window
aws ec2 accept-vpc-peering-connection \
--region ap-northeast-1 \
--profile profile-accepter \
--vpc-peering-connection-id pcx-new-id

승인할 때도 Accepter 쪽 리전을 지정하는 것을 잊지 말자.

연결 후 작업

active가 되어도 통신은 아직 안 된다.

  • 양쪽 VPC의 라우트 테이블: 상대 CIDR을 pcx로 향하게 함
  • 양쪽 VPC의 보안 그룹: 상대 CIDR에서의 인바운드 허용

크로스 리전에서는 보안 그룹 ID로 참조 불가. CIDR 지정 필수.

교훈

—peer-region은 잊기 쉽다. failed가 되면 당황하지 말고 방치하면 OK.