amazon-web-services - 当模板获取 AWS::EC2::EIP(弹性 IP)的 AllocationID 时,AWS CloudFormation 出现错误

标签 amazon-web-services amazon-ec2 aws-cloudformation elastic-ip

我已经使用 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/

相关文章:

java - 使用 Amazon AWS Cognito `.well-known/jwks.json` 数据无法对某些字段进行 base64 解码

amazon-web-services - 如何检测Azure/Amazon VM

amazon-web-services - 如何将 EBS 支持的 AMI 从 AWS 下载到本地计算机?

aws-cloudformation - 在cloudformation模板中使用变量

json - 在cloudformation json模板中添加PublicSubnet/PrivateSubnet的正确方法?

amazon-web-services - 嵌套 cloudformation 在创建 vpc 时获取 vpcid

amazon-web-services - 如何快速有效地调试 CloudFormation 模板?

postgresql - Amazon Aurora PostgreSQL 选择进入 OUTFILE S3

amazon-ec2 - 我需要多少实例?

amazon-ec2 - AWS CLI 不使用通过环境变量设置的凭证