CloudFormationで以下のようなエラーが出る場合があります。
Route did not stabilize in expected time
以下のtemplateでPNPrivateRoute
(AWS::EC2::Route
) を作成する際に発生しました。5分くらい処理が止まり、このエラーが出て終了してしまいます。
...
PNNatGateway:
Type: 'AWS::EC2::NatGateway'
Properties:
AllocationId: eipalloc-xxxxxx
SubnetId: !Ref PNPublicSubnet
PNPrivateRouteTable:
Type: 'AWS::EC2::RouteTable'
Properties:
VpcId: !Ref PrivateNet
PNPrivateRoute:
Type: 'AWS::EC2::Route'
Properties:
RouteTableId: !Ref PNPrivateRouteTable
DestinationCidrBlock: 0.0.0.0/0
GatewayId: !Ref PNNatGateway
...
対応
GatewayId
で指定している箇所をNatGatewayId
に変更する。
...
PNNatGateway:
Type: 'AWS::EC2::NatGateway'
Properties:
AllocationId: eipalloc-xxxxxx
SubnetId: !Ref PNPublicSubnet
PNPrivateRouteTable:
Type: 'AWS::EC2::RouteTable'
Properties:
VpcId: !Ref PrivateNet
PNPrivateRoute:
Type: 'AWS::EC2::Route'
Properties:
RouteTableId: !Ref PNPrivateRouteTable
DestinationCidrBlock: 0.0.0.0/0
NatGatewayId: !Ref PNNatGateway
...
原因
上記のとおり、GatewayId
はあくまでAWS::EC2::InternetGateway
のIDを指定するプロパティでありAWS::EC2::NatGateway
を指定したい場合はNatGatewayId
を利用しなければならないためです。
備考
あまりにも挙動とエラーメッセージがわかりにくい..。