Just to add to the discussion -- 'whats happening in the background' -- more specifically is your operating system's stub resolver.
So when you ask for www.amazon.com it ends up making multiple DNS lookups, as www.amazon.com is a CNAME record.
Nothing about this CNAME lookup gets passed back up the stack to your application; you just get that end-result: the IP address.
host www.amazon.com www.amazon.com is an alias for tp.47cf2c8c9-frontier.amazon.com. tp.47cf2c8c9-frontier.amazon.com is an alias for www.amazon.com.edgekey.net. www.amazon.com.edgekey.net is an alias for e15316.e22.akamaiedge.net. e15316.e22.akamaiedge.net has address 23.204.68.114