in AWS by

EC2 User Data provides a feature wherein I can do bootstrapping activities when the instance is created.

Which of the following statement regarding User Data is incorrect?

1 Answer

0 votes
by

Correct Answer: B.

Option A is incorrect because it is a true statement.

You can modify user data for an instance in the stopped state if the root volume is an EBS volume.

Option B is correct because it is a false statement.

If the instance is in the stopped state, user data can be modified, not in the running state.

Option C is incorrect because it is a true statement.

The script commands within User Data executes as root only.

So no need to use Sudo explicitly for running them.

Option D is incorrect because it is a true statement.

User Data script can be modified usingAWS CLI also.

References:

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-add-user-data.html

User data is a feature of Amazon Elastic Compute Cloud (EC2) instances that enables you to execute scripts or run commands when an instance boots up. This feature is used to perform various bootstrapping activities like installing software, configuring settings, and setting up custom security rules, among other things.

Answer B is incorrect. User data for an instance cannot be modified if it is in the running state, regardless of the root volume's type. Once an instance is running, its configuration is fixed, and the user data cannot be changed. If you need to make changes to the user data, you will need to stop the instance first.

Answer A is correct. If the instance is in the stopped state and the root volume is an EBS volume, you can modify the user data by creating a snapshot of the root volume, attaching the snapshot to a different instance, mounting the root volume, and then modifying the user data.

Answer C is correct. When you execute user data on an EC2 instance, it runs as the root user by default, so there is no need to use sudo in the user data script to run as the root user.

Answer D is correct. You can modify the user data script using both the AWS console and the AWS Command Line Interface (CLI). In the console, you can modify the user data in the advanced details section of the instance launch wizard. With the AWS CLI, you can use the aws ec2 modify-instance-attribute command to modify the user data of a running or stopped instance.

...