Initiating a Team Project Creating Domains for Seneca Student
Tags: route53, dns, starchart, osd700
Published: 2023-01-20 19:16:19

The team in Seneca OSD700 course has started a project called `Starchart`. This web app will create the number of custom domains for each student with a SSL certificate. More exciting part is that this web app will go live for all of Seneca students which is very rewarding. It will be a huge open-source experience to make something real from scratch. All of team members are very inspiring and I'm looking forward to working altogether. 

We will use a bunch of new technologies for `Starchart`. One of the tech stacks that we will use is `AWS Route 53`. 


![Route 53 diagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7axonls52njp98pnua05.png)

`Route 53` is a DNS service that sends client's request to the right resources. Basically `Route 53` can provide 3 main services. 

- Register a name for the website
- Connect the browser with the website or web application
- Check health of resources by sending automated request to a resource

Like other AWS services, `Route 53` is highly reliable and scalable, easy to use and cost effective, and secure. There are many `Route 53` features. Some people are interested in configuring various routing policies and continuously monitoring resources to send requests to alternate routing. But in our use case, we need to automate the domain creation and find some ways to monitor these domains. More details can be found on this [page](https://aws.amazon.com/route53/features/).

We can use `Route 53` in Management Console with graphical UI, also via API or SDK. Although we will use SDK, I would like to show how to create hosting zone in Management Console for someone who needs it and have an idea what SDK does. (Photos are taken from the passionate team member, `Alex Romanova`. Thank you!).


1. First, go to `Route 53` dashboard and click `Create hosted zone`. 
![Create hosted zone](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o38cvonbn6ic9oeltehx.png)

2. Add a domain name to create a hosted zone on `Create hosted zone` page. Then click `Create hosted zone` button on the bottom. (A `hosted zone` is a term for AWS that represents a collection of records that can be managed together, belonging to single parent domain name. All records within hosted zone must have the hosted zone's domain name as a suffix. In this case, `www.subdomain.bytechlabs.com`, but not `www.subdomain.bytechlabs.ca`.)
![Add a domain in create hosted zone](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cv9nz4qn308c0jbg0xt4.png)

3. You will see your hosted zone detail page with a list of records and nameservers, etc. 
![Hosted zone detail page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x4d9lv1shu57jcqbkr7e.png)

However, this is not what we need for `Starchart`. We have to automate this process using JavaScript SDK. To do this, I need to install `AWS SDK` package. 

```sh
npm install aws-sdk
```

And this is the code snippet to create hosted zone with SDK. 

```javascript
var params = {
  CallerReference: 'STRING_VALUE', /* required */
  Name: 'STRING_VALUE', /* required */
  DelegationSetId: 'STRING_VALUE',
  HostedZoneConfig: {
    Comment: 'STRING_VALUE',
    PrivateZone: true || false
  },
  VPC: {
    VPCId: 'STRING_VALUE',
    VPCRegion: us-east-1 | us-east-2 | us-west-1 | us-west-2 | eu-west-1 | eu-west-2 | eu-west-3 | eu-central-1 | eu-central-2 | ap-east-1 | me-south-1 | us-gov-west-1 | us-gov-east-1 | us-iso-east-1 | us-iso-west-1 | us-isob-east-1 | me-central-1 | ap-southeast-1 | ap-southeast-2 | ap-southeast-3 | ap-south-1 | ap-south-2 | ap-northeast-1 | ap-northeast-2 | ap-northeast-3 | eu-north-1 | sa-east-1 | ca-central-1 | cn-north-1 | af-south-1 | eu-south-1 | eu-south-2
  }
};
route53.createHostedZone(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});
```

As you can see, `CallerReference` and `Name` are required parameters. `Name` is domain name as shown above graphical UI example. But what is `CallerReference`? `CallerReference` must be a unique string every time when running `CreateHostedZone` to avoid executing the operation twice. It's recommended to use something like `date/time` stamp. 

There are much more methods and guidance on this [page](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-route-53/index.html). We are not trying to provide full DNS services. I will write functions with methods that will create, update, and delete domain. And some of available domain monitoring methods. From next week we will be creating many issues and writing codes. 

I've never done a team project from scratch. Everyone has a different interest and role. But we will have to help each other. So it's going to be very interesting and a lot of learning how we start building and coordinate the work together.