Skip to content
Advertisement

How can I edit an xml line from user data in ec2 instance?

I am using Wowza streaming engines in multiple ec2 instances that are spinned up from backend. I need a way of linking the edge instances with the origin and for that I need to update the value of a particular line in an xml file. I have the ip loaded in the user-data by the time the edges spin up. What do I need to start a script that edits this the value in this tag from the user data? Thank you

Advertisement

Answer

Supposing origin_ip is defined:

script = "#!/bin/bash
          sed -i -e '/<Name>loadbalanceServerIP<\/Name>/,/<Value>/s/<Value>[^<]*/<Value>#{origin_ip}/' /home/wowza/conf/Server.xml
          sudo service WowzaStreamingEngine restart"
Advertisement