# Route53

## Essentials

* Key Features:
  * Domain Registration
    * Register domain names like nicacton.com
  * Domain Name System (DNS) Service
    * Translates friendly domains to IP addresses
    * Responds to DNS queries using a global network of authoritative DNS servers (almost no latency)
  * Health Checking
    * Sends automated requests over the Internet to your app to verify its reachable, available, and functional!
* Can manage external DNS for domain routing to proper AWS resources like: a Cloudfront distribution, ELB, EC2 instance or RDS server via Alias records
* Commonly used with ELB to direct traffic from the domain to the ELB (thus evenly distributing traffic among servers)
* Can be used to manage internal DNS for custom internal hostnames within a VPC as long as the VPC is configured for it.
* Latency, GEO, basic, and failover routing policies allow for region-to-region fault tolerant architecture design. GLOBAL propagation, usually in less than a minute!
* You can easily configure for failover to S3 (if website bucket hosting is enabled.)

#### Hosted Zones

* Stores DNS records for your domain
* Contains all the rules (record sets) that tells Route53 what to do with DNS requests.
* There are both public and private hosted zones:
  * Public - Holds information about how you want to route traffic on the Internet for a domain, such as nicacton.com, and it's sub-domains
  * Private - Holds information about how you want to route traffic for a domain and its subdomains within one or more AWS VPCs
* After you create a hosted zone for your domain, you create resource record sets to tell the Domain Name System (DNS) how you want traffic to be routed for that domain.
* Hosted zones come pre-populated with NS (name server) and SOA (start of authority) record sets.

#### Record Sets

* Record sets are instructions that actually match domain names to IP addresses
* Options:
  * Record type
  * Standard/alias
  * Routing policy
  * Evaluate target health
* Common Record Types
  * A: Point a domain to an IPv4 IP
  * AAAA: Point a domain to an IPv6 IP
  * CNAME: Point a host/name to another host/name
  * MX: Used to route email (mail exchange)
* Alias Record Sets
  * Instead of an IP Address (standard record sets), an alias record set contains a pointer to an AWS specific resource, such as:
    * An elastic load balancer
    * Cloudfront distributions
    * Elastic Beanstalk environments
    * Amazon S3 bucket configured as a static website
* Routing Policy
  * Simple - Route to one endpoint
  * Weighted - Divide traffic to multiple endpoints (manual load balancing)
    * Good for testing of new environments
  * Latency - Resolve to Load Balancer or resource that is closest to the client making the request
  * Failover - Disaster recovery, if first instance is not healthy/unavailable it should return a second endpoint
  * Geolocation - Want to send users to a particular endpoint based off IP Location (country regions, like .uk)
* Evaluate Health Check
  * Can monitor the health of your application and trigger an action.

#### S3 for DNS Failover

* By using a failover routing policy in a Route53 DNS record set, an S3 bucket can be used as a failover endpoint.
* This is an extremely reliable backup solution if your primary endpoint fails.
* Even though S3 should only be used for static web hosting, it can be used to provide information until the primary endpoint is working again.
* S3 can also be used as the primary endpoint if you just want to host a static site on it.
  * For a DNS record to use an S3 bucket as an endpoint, the bucket name must match the domain name
