How to get ip public AWS in Cloudify

我的未来我决定 提交于 2019-12-13 07:11:34

问题


Using in my script file .sh:

ctx logger info $(ctx instance host_ip)

I get the private IP of my instance on AWS. How do I get the public IP?


回答1:


Short answer is that as of right now you cannot, but the feature is planned.

More complete answer -

ctx.instance.host_ip maps to a compute node instance's runtime property ctx.instance.runtime_properties[ip]. By convention this is a private ip address.

This property is set if the current node is of, or is derived from, the type cloudify.nodes.Compute, or if the current node has a relationship of, or is derived from, the type cloudify.relationships.contained_in that has a target of node type, or derived from, cloudify.nodes.Compute.

AWS plugin sets the runtime property on node type cloudify.aws.nodes.Instance ctx.instance.runtime_properties['public_ip_address'].

In the meantime, the best solution is to us a script in a lifecycle operation to set a runtime property on the needed node that need's the public IP such as you will find here.




回答2:


You can get public IP address in the following way:

public_address=$(ctx instance public_ip_address)

ctx logger info "Public IP address is ${public_address}"


来源:https://stackoverflow.com/questions/33791696/how-to-get-ip-public-aws-in-cloudify

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!