amazon-web-services - 模板获取 AWS::EC2::EIP(弹性 IP)的 AllocationID 时出现 AWS CloudFormation 错误
问题描述
我已经创建了一个包含 EIP 资源的堆栈,我正在尝试获取分配 ID,而 CloudFormation 验证器一直对我大喊大叫。我将 EIP 提取到一个非常简单的堆栈中,它是唯一的资源,但我仍然无法获得有效的模板。我是疯了还是 AWS 惹我了??下面是验证失败的简单堆栈模板,如果我将它用作嵌套堆栈,它会在创建时失败。
AWSTemplateFormatVersion: 2010-09-09
Description: Create an EIP to be used by Alliance web proxy EC2 instance.
Resources:
EIPForProxy:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
Outputs:
EIPAllocationID:
Value: !GetAtt EIPForProxy.AllocationID
EIPPublicIP:
Value: !Ref EIPForProxy
解决方案
作为 VPC 弹性 IP 地址,您只能将其导出为值并将此模板用作父堆栈的子堆栈。您不能使用 GetAtt 函数将其作为值输出。
---
AWSTemplateFormatVersion: '2010-09-09'
Description: Create an EIP to be used by Alliance web proxy EC2 instance.
Resources:
EIPForProxy:
Type: AWS::EC2::EIP
Properties:
Domain: vpc
Outputs:
EIPAllocationID:
Value: 'null'
Export:
Name: MyEIP::AllocationId
EIPPublicIP:
Value:
Ref: EIPForProxy
推荐阅读
- jpype - python.exe中发生未处理的win32异常
- java - 通过 NetBeans 8.2 运行索引文件时,如何解决 PHP 中的“调用未定义函数 mysql_pconnect()”错误?
- sql - 如何将表单向导 POST 请求保存到数据库
- javascript - 如何向 JSON 对象添加新的键/值对?
- wordpress - Facebook 的应用内浏览器返回错误“net::ERR_FAILED”,但没有其他浏览器
- asp.net-mvc - 使用 include 方法急切加载不会从集合中返回数据
- google-apps-script - 当我将函数 2 与函数 1 结合使用时,为什么我的函数 2 的列号会发生偏移?
- javascript - 如何使用 spyOn 测试异步功能?
- python - 如何在 PySpark 中获取布尔列的平均值?
- java - 执行 try/catch 中的所有语句