在不同区域的CloudFormation中添加VPC对等

时间:2019-08-22 20:42:19

标签: amazon-cloudformation amazon-vpc

我正在不同区域的2个VPC之间创建一个VPC对等连接。对于peeringconnection设置的VpcId,我试图从先前创建VPC的另一个堆栈中导入VPC ID。这是我的代码:

VpcPeeringConnection:
    Type: "AWS::EC2::VPCPeeringConnection"
    Properties:
      VpcId:
        - Fn::ImportValue: !Sub ${VpcStack}-vpcId
      PeerVpcId: !Ref PeerVPCId
      PeerRegion: !Ref PeerRegion

我收到以下错误

Template error: the attribute in Fn::ImportValue must not depend on any resources, imported values, or Fn::GetAZs

1 个答案:

答案 0 :(得分:0)

无法使用Fn::ImportValue从另一个区域的堆栈中检索值。

  

您不能跨区域创建跨堆栈引用。您可以使用内部函数Fn :: ImportValue仅导入在同一区域内已导出的值。   source

相关问题