Amazon ec2 user-data, how does it work?

前端 未结 5 906
别那么骄傲
别那么骄傲 2020-12-23 13:11

We are starting instances, and accessing the user-data we place. But does anybody understand the internals of this operation (from Amazon\'s side)? When we pass in the user-

5条回答
  •  星月不相逢
    2020-12-23 13:55

    An easy example for everyone's understanding: If you want to create the file /tmp/testfile.txt when the machine gets started, you can simply add these two lines on the User data field.

    #!/bin/bash
    touch /tmp/testfile.txt
    

    Remember to put the #!/bin/bash at the top before your commands.

    When you run the instance (Linux AMI), you can see the User data field content at /var/lib/cloud/instance/user-data.txt

提交回复
热议问题