It depends on what you mean by "calculation". If you mean finding out yourself, you cannot. The public DNS name has nothing to do with the ec2 instance name. A common DNS name consists of a public IP address, region / availability zone, type of service, aws domain name, etc. For example, ec2-xx-xxx-x-xx.us-west-2.compute.amazonaws.com, since the public IP address changes every time you stop and start your instance, if you do not use an elastic IP address, your public DNS name will be changed.
If you mean finding out using the AWS API or the CLI tool, you can. Using the EC2 CLI, you must use the ec2-describe-instances of instance_id command. Again, the instance must be started, and the public DNS changes after it stops / starts.
Lan
source share