Correct Answer: B
You can access the local IP address of your instance from instance metadata. The instance metadata is available from your running instance, so no need to use the Amazon EC2 console or the AWS CLI.
Option A is incorrect because OS signifies Windows, Linux, etc doesn`t tell anything about the IP address, and no need to follow difficult steps if you are getting the results easily.
Options C and D are incorrect because they require an AWS console to get the requested results.
Instance metadata is data about your instance that you can use to configure or manage the running instance.
You can also use instance metadata to access user data that you specified when launching your instance. For example, you can specify parameters for configuring your instance, or include a simple script.
Although you can only access instance metadata and user data from within the instance itself, the data is not protected by authentication or cryptographic methods. Anyone who has direct access to the instance, and potentially any software running on the instance, can view its metadata.
Therefore, you should not store sensitive data, such as passwords or long-lived encryption keys, as user data.
For more information on Instance metadata, please visit the below URL-
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html