how to forward godaddy domain to ec2 load balancer
You can't.
ELB provides one -- or more -- IP addresses, hiding behind the CNAME you are using with www record, and these addresses are not static, so you can't create an A record at the top ("apex") of your domain and point to the addresses... along with that, a CNAME at the apex of a domain is not a valid DNS configuration. So there isn't directly a way to do this.
You can either use Go Daddy's web site forwarding feature to redirect example.com requests to www.example.com, which will cause the browser to change its address bar value from example.com to www.example.com and then send traffic to the ELB (via the www CNAME)... or you can move the DNS from Go Daddy to Amazon's Route 53 service, which has another feature that operates similarly to a CNAME but is implemented differently, consistent with the rules established in RFC-1912. They call these ALIAS
records.
An Alias record in Route 53 is a pointer to internal configuration within Route 53 that allows that service to look up and return an appropriate A-record for the service to which the Alias record is pointing.
http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/CreatingAliasRRSets.html
In addition to the accepted answer, another option is to create an AWS hosted zone in AWS Route 53 following the steps below:
Sign in to the AWS Management Console and open the Amazon Route 53 console at https://console.aws.amazon.com/route53/.
Choose Create Hosted Zone.
- You'll need to ensure your hosted zone points to your loadbalancer. To do this, create an A record and select alias and from the dropdown list returned, select your load balancer
- Go ahead and create a CNAME record and point it to the record you created in step 3
More here on creating a hosted zone: http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/CreatingHostedZone.html
Each hosted zone creates nameservers for you so once created, get the provided name servers and update godaddy to use those nameservers.
Your GoDaddy domain will now be pointing to an AWS hosted zone which in turn points to your load balancer.
You can also remove the default(@) A record if there is one and most browsers will just try www instead. That worked for me.