如何自动获取DNS ELB ELB AWS云组建
对于我的堆栈,我需要自动检索 AWS 上负载均衡器的 dns,因为我删除/创建以更新我的堆栈和服务器,名称一直在变化,或者我需要能够从我的 ELB 自动检索 dns在 AWS
感谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
对于我的堆栈,我需要自动检索 AWS 上负载均衡器的 dns,因为我删除/创建以更新我的堆栈和服务器,名称一直在变化,或者我需要能够从我的 ELB 自动检索 dns在 AWS
感谢
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(2)
目前尚不清楚您是否在同一堆栈中创建该负载均衡器,以及您正在谈论哪个负载均衡器。如果它是同一堆栈中的 ELB,则通过使用具有正确输出的
!GetAtt
函数非常容易。有关 cloudformation 中 ELB 输出的信息,请参阅 此处。如果您正在谈论已经存在的负载均衡器,那么有几个选项。如果它是在另一个堆栈中创建的,您始终可以使用 ImportValue功能。第二个选项是将其作为参数传递给堆栈。如果该值随后发生变化,您可以使用新值作为参数轻松更新模板。
最后一个选项是使用执行 lambda 函数的自定义资源,该函数检索所需的 DNS 值并将其作为输出值返回到 CloudFormation 资源。然后,您可以使用
!GetAtt
函数来引用返回值。但是,您必须小心,更新堆栈时该函数并不总是执行,因此您可以添加一个虚拟参数作为自定义资源的输入,您可以更改该参数以强制重新运行 lambda 以检索最新值。此选项的实现需要相当多的工作,并且仅比简单地使用堆栈参数传递值更容易使用。It is unclear whether or not you are creating that load balancer in the same stack or not, and which load balancer you're talking about. If it is an ELB within the same stack, this is very easy by using the
!GetAtt
function with the correct output. Information about the outputs of the ELB in cloudformation can be found here.If you are talking about an already existing load balancer, then there are a few options. If it is created in another stack, you can always cross-reference it by using the ImportValue function that comes with cloudformation. A second option is to pass it in as a parameter to the stack. If the value subsequently changes, you can easily update your template with the new value as a parameter.
The last option is to use a custom resource that executes a lambda function which retrieves the DNS value you want and returns it as an output value to the CloudFormation resource. You can then use the
!GetAtt
function to reference the return value. However, you must be wary that this function will not always execute when you update the stack, so you can add a dummy parameter as input to the custom resource which you can change to force a rerun of the lambda to retrieve the latest value. This option is quite some work to implement and will be only marginally easier to use than simply using a stack parameter to pass in the value.在 Cloudformation 模板的输出部分中,您可以获取 DNS url
In the Output section of your Cloudformation template you can get the DNS url