VPC 서브넷의 RouteTable 간 전환
관리 콘솔에서 RouteTable 전환
VPC 서브넷에 연결된 RouteTable을 전환해야 하는 경우,
관리 콘솔에서 VPC => Subnets => 서브넷 선택 => RouteTable 탭의 Edit 버튼을 눌러 서브넷에 연결할 RouteTable을 선택할 수 있습니다.
간단합니다.
AWSCLI에서 RouteTable 전환
그러나 특정 트리거를 계기로 RouteTable을 자동으로 전환하고 싶은 경우에는 AWSCLI를 사용한 스크립트를 작성할 필요가 있습니다만, 한 번 버렸습니다.
먼저, 서브넷과 라우팅 테이블을 가장 먼저 연결하는 경우에는 "associate-route-table"명령으로 [route-table-id]와 [subnet-id]를 연결합니다. (기본적으로 생성된 VPC에서는 연결됨)
이 【route-table-id】와 【subnet-id】의 연결에 대해 【association-id】가 할당됩니다. 【association-id】는 「describe-subnets」명령으로 확인할 수 있습니다.
(현재에서는 관리 콘솔에서 [association-id]를 확인할 수 없습니다.)
aws ec2 describe-route-tables
-----------
{
"RouteTables": [
{
"Associations": [
{
"SubnetId": "subnet-xxxxxxxx",
"RouteTableAssociationId": "rtbassoc-xxxxxxxx",
"Main": false,
"RouteTableId": "rtb-xxxxxxx"
}
],
:
:
}
--------
위와 같이 서브넷 : subnet-xxxxxxxx와 라우팅 테이블 : rtb-xxxxxxx의 연결은 rtbassoc-xxxxxxxx라는 AssociationId로 관리됩니다.
그리고 본제의 벌써 라우트 테이블이 묶인 서브넷의 CLI에서의 RouteTable 전환에는 「replace-route-table-association」 커멘드를 사용합니다만, 전술의 「associate-route-table」와 같이【route -table-id]와 [subnet-id]를 연결하는 것이 아니라 [route-table-id]와 [association-id]를 연결해야합니다. 또한 【association-id】는 연결할 때마다 매번 값이 변화하므로 주의가 필요합니다.
aws ec2 replace-route-table-association --association-id rtbassoc-xxxxxxxx --route-table-id rtb-xxxxxxxx
-----------
{
"NewAssociationId": "rtbassoc-xxxxxxxxx"
}
-----------
이런 식으로 새로운 AssociationId가 결과로 돌아오면 전환이 성공합니다.
덧붙여서, 연결이 끝난 【subnet-id】와 【route-table-id】를 「associate-route-table」명령을 사용하면 이런 느낌으로 화가납니다.
aws ec2 associate-route-table --subnet-id subnet-xxxxxxxxx --route-table-id rtb-xxxxxxxx
-----------
A client error (Resource.AlreadyAssociated) occurred when calling the AssociateRouteTable operation: the specified association for route table rtb-xxxxxxx conflicts with an existing association
-----------
Reference
이 문제에 관하여(VPC 서브넷의 RouteTable 간 전환), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다
https://qiita.com/biatunky/items/cc9b58c430075b059c02
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)
그러나 특정 트리거를 계기로 RouteTable을 자동으로 전환하고 싶은 경우에는 AWSCLI를 사용한 스크립트를 작성할 필요가 있습니다만, 한 번 버렸습니다.
먼저, 서브넷과 라우팅 테이블을 가장 먼저 연결하는 경우에는 "associate-route-table"명령으로 [route-table-id]와 [subnet-id]를 연결합니다. (기본적으로 생성된 VPC에서는 연결됨)
이 【route-table-id】와 【subnet-id】의 연결에 대해 【association-id】가 할당됩니다. 【association-id】는 「describe-subnets」명령으로 확인할 수 있습니다.
(현재에서는 관리 콘솔에서 [association-id]를 확인할 수 없습니다.)
aws ec2 describe-route-tables
-----------
{
"RouteTables": [
{
"Associations": [
{
"SubnetId": "subnet-xxxxxxxx",
"RouteTableAssociationId": "rtbassoc-xxxxxxxx",
"Main": false,
"RouteTableId": "rtb-xxxxxxx"
}
],
:
:
}
--------
위와 같이 서브넷 : subnet-xxxxxxxx와 라우팅 테이블 : rtb-xxxxxxx의 연결은 rtbassoc-xxxxxxxx라는 AssociationId로 관리됩니다.
그리고 본제의 벌써 라우트 테이블이 묶인 서브넷의 CLI에서의 RouteTable 전환에는 「replace-route-table-association」 커멘드를 사용합니다만, 전술의 「associate-route-table」와 같이【route -table-id]와 [subnet-id]를 연결하는 것이 아니라 [route-table-id]와 [association-id]를 연결해야합니다. 또한 【association-id】는 연결할 때마다 매번 값이 변화하므로 주의가 필요합니다.
aws ec2 replace-route-table-association --association-id rtbassoc-xxxxxxxx --route-table-id rtb-xxxxxxxx
-----------
{
"NewAssociationId": "rtbassoc-xxxxxxxxx"
}
-----------
이런 식으로 새로운 AssociationId가 결과로 돌아오면 전환이 성공합니다.
덧붙여서, 연결이 끝난 【subnet-id】와 【route-table-id】를 「associate-route-table」명령을 사용하면 이런 느낌으로 화가납니다.
aws ec2 associate-route-table --subnet-id subnet-xxxxxxxxx --route-table-id rtb-xxxxxxxx
-----------
A client error (Resource.AlreadyAssociated) occurred when calling the AssociateRouteTable operation: the specified association for route table rtb-xxxxxxx conflicts with an existing association
-----------
Reference
이 문제에 관하여(VPC 서브넷의 RouteTable 간 전환), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/biatunky/items/cc9b58c430075b059c02텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)