Sevice for managing DNS with route53
This Go server was generated by the openapi-generator project.
This service manages DNS with route53 and can be expanded to handle other DNS provides.
- Design a service that will read-in the AWS tagging from a Load Balancer and create a Route53 DNS entry. This service exposes an enpoint
/route53/creatednsfromlbtags
which takes loabalancer name as input along with an tag key(default:r53_dns
) for DNS entry to be created for the loadbalancer.
Current implementation creates DNS record of tag value of tag key as record name, loadbalancer DNS as record value, CNAME
type with TTL of 300
seconds.
The service should be aware it’s not the only way DNS entries would be added to the system. Designed service endpoints which can be used for managing DNS entries. The function used for creating DNS entry is resued for creating DNS record from loadbalancer tags.
Current implementation has following apis in working -
- List all hosted zones
- List all records for a given hosted zone
- List one record for a given hosted zone, record name and record type
- Create a DNS record from given hosted zone, record name, record type and TTL
- Create a DNS record from tag value of loadbalancer as record name (record type
CNAME
, TTL300
and DNS of loadbalancer as value)
Also, think about how you would want to manage maintaining Route53 when these Load Balancers are deleted/removed.
I would listen to CloudTrail for loadbalancer management actions. Event name DeleteLoadBalancer
is registered in CloudTrail whenever a loadbalancer is deleted. We can create an api for deleting DNS record corresponding to tags on deleted load balancer and call it whenver we detect DeleteLoadBalancer
event.
- Develop your service using Go. We value good unit tests.
- Commit your work as you go in a git repository. This repository can be local or hosted, but we would like to see your commit history.
- Document your project in a README.md markdown file as part of your repository.
Important
Set up AWS credentials before running the server. You can set client credentials in environment or use a config file. Read more at https://docs.aws.amazon.com/sdkref/latest/guide/creds-config-files.html This server is tested using environment and config file client credentials.
To run the server on local machine, follow these simple steps:
go run main.go
To build the server in docker container
make build-docker
To run the server in a docker container (it builds the image too)
make run-docker
-
Tests
I should have added test cases but due to time constraints and my unfamilarity with mocking, I couldn't complete it. -
Strict Input validation
Although there are some type checks generated by openapi generator, we need to be more careful in sanitizing input. Example - dns record name validation. -
Correct http responses
Since we don't have strict validations for inputs, AWS api return400 Bad Request
status code, while I am sending500 Internal Server Error
. -
Make loadbalancer tag to DNS an upsert
Route53 api already supports upsert action for creating dns records, we should use it too -- so that tag update on a loadbalacner can result in DNS record value on calling the api. (It will not update currently if the dns record already exists)