AWS VPC对等连接的路由表创建限流可能会导致创建失败或延迟, 解决方案是使用AWS CLI或SDK中提供的waiters。waiters是检查资源创建状态的函数的一种。例如,使用CLI的wait vpc-peering-connection-exists命令,可以检查对等连接是否已创建并可用。下面是使用AWS CLI等待对等连接状态为available的示例代码:
aws ec2 create-vpc-peering-connection --vpc-id vpc-123456 --peer-vpc-id vpc-7890abcdef --peer-owner-id 111122223333 --query "VpcPeeringConnection.{VpcPeeringConnectionId:VpcPeeringConnectionId}" --output text
aws ec2 wait vpc-peering-connection-exists --vpc-peering-connection-ids pcx-01234567890abcdef
该代码将在对等连接状态为“available”时继续执行。