我已经使用 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
关于amazon-web-services - 当模板获取 AWS::EC2::EIP(弹性 IP)的 AllocationID 时,AWS CloudFormation 出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54953351/