0

I have created a bastion host in AWS EC2 using BastionHostLinux class. There I've specified the userData(custom software I want to install) using this.bastionHost.instance.addUserData("my custom software")

However, the problem I'm facing is that when I try to update the user data, although I'm updating the commands in addUserData() method, that is not getting reflected in my bastion host. What to do to seamlessly update the userData without having to delete the Cloudformation Stack or something else everytime I want to update the userData?

Rama Rahul
  • 93
  • 7

1 Answers1

0

What are your expectations exactly?

As stated in User data and the console section,

By default, user data scripts and cloud-init directives run only during the boot cycle when you first launch an instance. You can update your configuration to ensure that your user data scripts and cloud-init directives run every time you restart your instance. [emphasis mine]

Adding user data to the already running instance will not run any scripts in its shell. You should delete (or comment out) your bastion definition, apply the stack, then uncomment both bastion and user data definitions, and finally apply the result. That would cause the instance to recreate, and run your user data on launch.

esimonov
  • 546
  • 3
  • 8
  • My expectations were that instead of me doing the commenting and uncommenting, if there is a simple flag or Boolean property asking me to if I want to re-launch the instance that would be seamless. Don't you think so? – Rama Rahul Dec 20 '22 at 10:19