【问题标题】:How can I get the CIDR block of the VPC selected by the user in CloudFormation?如何获取用户在 CloudFormation 中选择的 VPC 的 CIDR 块?
【发布时间】:2018-08-28 08:31:35
【问题描述】:

我要求用户选择现有的 VPC:

Parameters:
  MyVPC:
    Type: AWS::EC2::VPC::Id

然后在我的“资源”块中,我试图获取该 VPC 的 CIDR 块。
当我尝试这个时:

      - Fn::GetAtt:
        - MyVPC
        - CidrBlock

我明白了:

Template error: instance of Fn::GetAtt references undefined resource MyVPC

我想这是因为从技术上讲 MyVPC 是一个参数而不是资源。

那么如何获取用户选择的 VPC 的 CIDR 块呢?

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation amazon-vpc


    【解决方案1】:

    我认为这是不可能的。

    Parameter 只是一个 VPC ID,而不是 VPC 本身。

    GetAtt 命令在模板中需要一个 Resource,但它不存在。

    您需要将 CIDR 块添加为另一个参数,或者创建一个由 Lambda 支持的 Custom Resource 来获取信息并使其可用于模板。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-11-09
      • 2019-11-27
      • 2019-07-16
      • 2018-03-16
      • 1970-01-01
      • 2021-01-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多