gpt4 book ai didi

aws-cloudformation - 获取通过LaunchConfiguration创建的EC2的属性

转载 作者:行者123 更新时间:2023-12-03 07:15:30 24 4
gpt4 key购买 nike

我想获取我通过 LaunchConfiguration 创建的 EC2 的 PrivateIP 属性。

我需要该属性,以便我可以将类型 A dns 记录分配给实例以用于其他目的。

这是我的代码:

Resources:
webLaunchConfig:
Type: 'AWS::AutoScaling::LaunchConfiguration'
Properties:
ImageId: !Ref webEc2AMI
InstanceType: !Ref ec2WebInstanceType
SecurityGroups: !Ref webEc2SG
UserData:
'Fn::Base64': !Sub >
#!/bin/bash -xe

apt update -y
dnsWebServerName:
Type: 'AWS::Route53::RecordSet'
Properties:
HostedZoneId: !Ref hostedZoneId
Comment: DNS name for my db server.
Name: !Ref dnsWebServerNamePar
Type: A
TTL: '900'
ResourceRecords:
- !GetAtt webLaunchConfig.PrivateIp

...当我尝试启动它时,出现此错误:

Template contains errors.: Template error: resource webLaunchConfigdoes not support attribute type PrivateIp in Fn::GetAtt

...表明我正在尝试做的事情不受支持。尽管必须有一种方法来实现这一目标。

你知道怎么做吗?或者解决这个问题的方法?

最佳答案

遗憾的是,您无法做到这一点AWS::AutoScaling::LaunchConfiguration 只是要启动的实例的蓝图。因此,它不提供有关实例 PrivateIp 的信息。获取 PrivateIp 您必须实际启动实例。

为此,您必须使用 AWS::EC2::Instance 。但是,AWS::EC2::Instance 不支持从“AWS::AutoScaling::LaunchConfiguration”启动。因此,您必须将 LaunchConfiguration 更改为 LaunchTemplate,或者直接使用 AWS::EC2::Instance` 而不是任何模板创建实例。

关于aws-cloudformation - 获取通过LaunchConfiguration创建的EC2的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64208583/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com