如何在Cloudify中获得ip公共AWS



在我的脚本文件中使用.sh:

ctx logger info $(ctx instance host_ip)

我在AWS上获得了我的实例的私有IP。如何获取公共IP?

简单的回答是,到目前为止,您还不能,但该功能已经计划好了。

更完整的答案-

ctx.instance.host_ip映射到计算节点实例的运行时属性ctx.instance.runtime_properties[ip]。按照惯例,这是一个私有ip地址。

如果当前节点属于cloudify.nodes.Compute类型或派生自该类型,或者当前节点具有cloudify.relationships.contained_in类型的关系或派生自具有节点类型目标或派生自cloudify.nodes.Compute的类型,则设置此属性。

AWS插件在节点类型cloudify.AWS.nodes.Instance ctx.Instance.runtime_properties['public_ip_address']上设置运行时属性。

同时,对我们来说,最好的解决方案是在生命周期操作中使用一个脚本,在需要公共IP的所需节点上设置运行时属性,如您在此处所见。

您可以通过以下方式获取公共IP地址:

public_address=$(ctx instance public_ip_address)
ctx logger info "Public IP address is ${public_address}"

最新更新