Creating subdomain in amazon ec2 instance - amazon-web-services

I have the instance ec2-xx-xxx-xxx-xxx.ap-southeast-1.compute.amazonaws.com. It is running a bitnami lamp stack.
How do I create a subdomain for this like subDomain.ec2-xx-xxx-xxx-xxx.ap-southeast-1.compute.amazonaws.com?
Is it possible to do such this or should I purchase a domain first?
Thanks

You cannot manage AWS domains. You need to have your own domain first and use Route 53 or any other DNS provider to create an A record pointing to this specific EC2 instance.
Before creating the A record however you will need to provision an Elastic IP and assign it to your EC2. Please keep in mind that every account starts out with only 5 Elastic IPs and if you need more you will have to get in touch with Amazon for approval.

Related

Pointing EC2 instance to a custom DNS

I have been trying to follow this tutorial but it is more complex than it needs to be I hope because I can assign tag names manually and I can do the route53 stuff manually.
https://www.esentri.com/auto-register-ec2-instance-in-aws-route-53/
What I have so far is I have created a PUBLIC hosted zone. "myzoneabc.com" This was created indirectly after I created my registered domain in Route53.
I then launched an EC2 instance and took its AWS assigned DNS name and created a CNAME record as follows
server.myzoneabc.com CNAME ec2-35-177-xxx-xxx.eu-west-2.compute.amazonaws.com
I can RDP onto server with DNS = server.myzoneabc.com with no problem.
Problem with this is when I restart my EC2 then the DNS which I entered in my route53 record above is no longer valid because it will have been modified after a stop/start of my EC2 instance.
My EC2 instance is only created once and either in a running or stopped state, it is never terminated.
So question is , is there any way to have route53 point a DNS recore like server.myzoneabc.com at my EC2 instance without using the DNS that Amazon assigns it which is always different. Thats what I think these EC2 instance tags are doing in the tutorial link posted above.
You probably need to update your DNS provider to use the NS records of your hosted zone. Only creating the Hosted Zone, will not tell anyone on the internet to use it.
Follow the Developer Guide: https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/CreatingNewSubdomain.html

AWS duplicating EC2 instances makes it point to the same domain

I have created an EC2 instance that host a wordpress site.
Then I have created AMI image with it and created exact copy of the instance.
The instance that I have copied from is linked to a domain through Route 53.
A bizarre experience that I have right now is that (twice now), when I copy EC2 instances in a way described above, using HTTP to access either of the EC2 instances lead to re-routing to the domain that was routed by Route 53 for the first instance.
Shouldn't only the first instance be linked to the domain because that is how I have set the record in Route 53? Is it normal for duplicated EC2 instance to point to same domain when I copy it using AMI image? How do I make it so that the second copied instance does not get re-routed to the same domain as the first instance?
This really is unrelated to AWS, EC2, Route53, etc. You simply have the "Site Address" setting in your Wordpress configuration set as that specific domain name. Wordpress automatically redirects any incoming requests to the configured Site Address.

Linking subdomain on bigrock to Amazon EC2 instance

I have a domain name hosted on bigrock.in pointed to an Amazon EC2 instance using Route 53. The four nameservers generated are placed in bigrock and it is working fine.
Now I have created a subdomain of the domain in bigrock and I want it to point to my application in another EC2 instance in another AWS account. Is this possible?
Yes. The AWS account that is currently controlling your domain name with Route 53 must be used, but it can be pointed to anything on the Internet.
Steps:
In the AWS account with the "other" EC2 instance, create an Elastic IP Address and assign it to the EC2 instance. This will ensure that its IP address does not change when the instance is stopped and started.
In your existing Route 53 configuration (in the original account), create a Record Set for the sub-domain (eg images.example.com) of type A and enter the Elastic IP Address as the value.
Once you have set the nameserver for your domain to point to Route53, you no longer need to control the subdomains from bigrock services. Just add them to your Route53 dashboard, and they'll be reflected live.

Subdomain pointing to EC2 instance while domain is on S3

I have a root domain like example.com. It's now hosted on Amazon S3. For that I followed this tutorial:
http://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html
What would I have to do to have a subdomain like client.example.com to point to a EC2 instance?
client.example.com => ec2-XXX.us-west-2.compute.amazonaws.com
Is there like a tutorial out there explaining the steps?
Two simple steps:
You would just need to add a new 'A' record to assign the ec2 ip address to that subdomain in your amazon route 53 dns (or whatever dns provider you are using) - very simple to do. Step one will have requests for that sub-domain routed to the ec2 instance.
Step 2 is to tell the web server you are running, when it receives a requests for that sub-domaain, what website should it serve up to the user - you do this by 'binding' the name to the directory/location thast has the website on your ec2 instance.
You may also want to read over the following from AWS
http://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-ec2-instance.html
It would also be better practice to assign your EC2 instance an Elastic IP address then forward requests to that IP.
We recommend that you also create an Elastic IP address and associate
it with your Amazon EC2 instance. An Elastic IP address ensures that
the IP address of your Amazon EC2 instance will never change.

How redirect a domain to Amazon EC2 Machine?

I'm using EC2 of Amazon to host a website built in JSP :
http://ec2-50-17-144-64.compute-1.amazonaws.com:8080/p2p
And I bought this domain:
www.p2pbrasil.com
How can I redirect www.p2pbrasil.com to my website in Amazon EC2 ?
When someone type www.p2pbrasil.com it redirects to http://ec2-50-17-144-64.compute-1.amazonaws.com:8080/p2p ?
You need to do two things
In the Amazon Web Service admin panel, create an elastic IP in the same region as your instance and associate that IP with your that instance (IPs cost nothing while they are associated with an instance, but do cost if not).
Add a A record to the DNS record of your domain mapping the domain to the elastic IP address assigned in (1). Your domain provide should either give you some way to set the A record (the IP address), or it will give you a way to edit the nameservers of your domain.
If they do not allow you to set the A record directly, find a DNS management service like ZoneEdit, register your domain as a zone there and ZoneEdit will give you the nameservers to enter in the admin panel of your domain provider. You can then add the A record for the domain in ZoneEdit.
I only mention ZoneEdit because the basic service is free, you could also use Amazon route 53 or a similar pay-for service, if you preferred.
Create an Elastic IP on the AWS Panel, then associate it to your instance.
Then use a DNS management service to add your domain and Ip address (Elastic IP), then on the domain provider panel add the DNS provided from the DNS management service.
I recommend EntryDNS which is actually free.
As you have your server on AWS best option is to use Route53 hosted zone.By doing this you can manage all your DNS entries using AWS. In future if you plan to use ELB's for your application, you can various traffic routing options using Route53.
Create Hosted Zone and get the name servers.
Replace current name servers with AWS nameservers from your Domain registrars DNS entries.
Create an A record in AWS hosted zone and give your servers IP (Elastic IP) as value.
For detailed instruction, you can follow this blog post. Mapping Domain Name to EC2 Server
Assuming this is a hobby website and your domain registrar isn't AWS.
If your registrar (for example godaddy.com) provides a DNS manager you simply need to add a CNAME record for www that points to the aws public DNS record for your instance. For example ec2-50-17-144-64.compute-1.amazonaws.com
This will make http://www.p2pbrasil.com display the same content as http://ec2-50-17-144-64.compute-1.amazonaws.com
Doing it this way you don't have to pay for an elastic IP, which is a dedicated resource. Your IP on your ec2 instance shouldn't change but could if you restart your instance.
Put the public IP from your EC2 instance as an A name to your root domain in Route 53 hosted zone.
This change might take some time.