When to Use Alias vs. CNAME?

When to Use Alias vs. CNAME :
  1. Use Alias Records :

    • When pointing a root domain (e.g., example.com) to AWS resources like:
      • Elastic Load Balancer (ELB)
      • CloudFront distribution
      • S3 bucket configured as a static website
    • For seamless AWS service integration and automatic updates to IP addresses.
  2. Use CNAME Records :

    • When pointing subdomains (e.g., www.example.com) to:
      • Another domain name
      • A third-party service (e.g., example.herokuapp.com)
    • If the record is not directly associated with AWS.
Example :
Alias Record :
  • Scenario: Pointing example.com (root domain) to an ELB.
  • Alias Record Configuration:
    • Name: example.com
    • Type: Alias
    • Value: ELB (e.g., my-elb-123456.us-east-1.elb.amazonaws.com)
CNAME Record :
  • Scenario: Redirecting www.example.com to external-service.example.com.
  • CNAME Record Configuration:
    • Name: www.example.com
    • Type: CNAME
    • Value: external-service.example.com