[英]How to get (Private) IP of EC2 instance in bash script launched by cron?
[英]Script to dynamically get Private IP of an EC2 instance
我正在編寫一個 ELK 部署腳本,我需要它做的一件事是編輯配置文件並插入一些行。 有沒有辦法讓它檢索正在運行腳本的任何 EC2 實例的私有 IP?
例如,假設我的實例的私有 ip 是10.0.10.154
並且我的腳本有以下幾行:
echo " host: 10.0.10.154:9200" | sudo tee -a /etc/elasticsearch/elasticsearch.yml
有沒有辦法讓我的腳本動態檢索10.0.10.154
並將其替換為正在運行腳本的任何實例的私有 IP?
Or, if each user creates a.profile file on their machine and and describe the private IP of the instance ELK_Private IP: 10.0.10.254
or whatever their iP is - how can I retrieve this value into my script and input into the yml config file ?
這應該為您提供本地 IP 地址:
curl -s http://169.254.169.254/latest/meta-data/local-ipv4
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.