You can use ec2 describe instances command in AWS CLI to display information about your running instances.
Run the following command in your AWS CLI to display the public IP address of your instance.
$ aws ec2 describe-instances --instance-ids i-0c9c9b44b --query 'Reservations[*].Instances[*].PublicIpAddress' --output text
You can also display Public IP address of the instance where you have currently SSH'ed, using the following command in your putty terminal:
curl http://169.254.169.254/latest/meta-data/ public-ipv4
You can also display other metadata of your running instance where you have SSH'ed.
Use the following command with the respective attribute(mentioned below) to display its respective value:
curl http://169.254.169.254/latest/meta-data/
ami-id
ami-launch-index
ami-manifest-path
block-device-mapping/
events/
hostname
iam/
instance-action
instance-id
instance-type
local-hostname
local-ipv4
mac
metrics/
network/
placement/
profile
public-hostname
public-ipv4
public-keys/
reservation-id
security-groups
services/