FEATURES OPEN SOURCE ABOUT DOCS LOGIN REGISTER

Assign domain names with Route53

You can give your VM or stack a domain name or URL ex: www.myappdomain.com for easier access using AWS Route53 service.

Preparation

Please complete the below steps first:

  1. Register a domain. If your domain is registered with another registrar you can still use the AWS Route53 by Migrating your DNS service to Amazon.
  2. Configure Amazon Route53 as your DNS service
  3. Create a Hosted Zone

You will need the Zone ID of your Hosted Zone, you can find it by following these steps

Full Stack

provider:
  aws:
    access_key: '${var.aws_access_key}'
    secret_key: '${var.aws_secret_key}'

resource:
  aws_instance:
    mars-webserver:
      instance_type: t2.nano
      user_data : |-
        apt-get -y update
        apt-get -y install nginx

  aws_eip:
    mars-webserver-eip:
      instance : "${aws_instance.mars-webserver.id}"

  aws_route53_record:
    web :
      zone_id : XXXXYYYYZZZZ
      name    : "${var.koding_user_username}.koding.team"
      type    : "A"
      ttl     : "60"
      records : ["${aws_eip.mars-webserver-eip.public_ip}"]

Explanation

resource:
  aws_instance:
    mars-webserver:
      instance_type: t2.nano
      user_data : |-
        apt-get -y update
        apt-get -y install nginx
aws_eip:
  mars-webserver-eip:
    instance : "${aws_instance.mars-webserver.id}"

If your VM is inside a VPC, you will need to set vpc: true in the aws_eip section

aws_route53_record:
  web :
    zone_id : XXXXYYYYZZZZ
    name    : "${var.koding_user_username}.koding.team"
    type    : "A"
    ttl     : "60"
    records : ["${aws_eip.mars-webserver-eip.public_ip}"]

Notes:

  1. web: the section name, you can choose any name - required
  2. zone_id : the Zone ID you fetched from Amazon - required
  3. name: the DNS record name, this will be your domain, or URL. We are using the user’s koding id followed by our domain, this will translate to logged-user.koding.team - required
  4. type: the DNS record type - required
  5. ttl : the time to live - required
  6. records: a string list of IP records. We are using our assigned Elastic IP - required

Once you set all your records you should be able to access your VM web service from the new domain. In our case, the user building the stack was Alison, her Koding username is “Alison40” and our registered domain is koding.team, therefore her VM url is alison40.koding.team

nginx_route53.png