I trying to setup as part of a study a PaaS (Platform as a service) for Ruby on Rails applications. I have already played with Amazon EC2 and Chef creating EC2 instances based on Chef's recipes and roles.
Now I need to be able to give every "customer" account or every app a unique subdomain like app1.mydomain.com, app2.mydomain.com, etc. which points to my customer's app on an EC2 instance. I then need to allow the customer to point their domain to their customized subdomain (app1.mydomain.com, app2.mydomain.com).
Can someone explain to me how I can achieve that?
It's a Simple Matter Of Programming. You should have something that maps customers to instances, like a database (assuming you're not going to run everything through a single frontend proxy) and then a script or whatever to generate the DNS zone from that data.
We wrote a cookbook for dynamically setting DNS entries in DynDNS Inc's Dynect API.
You could also use one of our published cookbooks for djbdns, powerdns or unbound.