Update Config files during EBS volumes swap

0

Hi, I set up new EC2 instance for one of our application. Database is restored from backup and I named as DB-copy. Snapshots of current EBS volumes are restored and then attached to the new EC2. This new instance gets copied like production data, call it clone. I then have to stop my application process immediately in new instance , modify the config file to change/point the db parameter to db-copy. Otherwise, my production application will fail saying there is another duplicate instance running.

I’m looking to modify the config file in the snapshot volume via console or CLI and while during volume swap that avoids me in doing manual update. Is there any guidance on achieving this?

Regards

2 Answers
0

Hello

You can use in this way:

  • Create AMI from the Ec2
  • Launch AMI and add user data to modify the config file
#!/bin/bash

/bin/sed -i 's/old-text/new-text/g'  configfile/path

please let me know if you have any questions

Thanks GK

profile picture
GK
answered 2 years ago
  • Thank you. I shall give a try and let you know.

  • Is it working do you have feedback?

0

Hi, Sorry about delayed response. I was on leave. What I’m trying to achieve is modify the file content from db1.AWS.com to db2.AWS.com while the volumes are swapped. In other words, can I modify the value within AWS console or CLI before I swap over the volumes ?

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions