- https://aws.amazon.com/documentation/gettingstarted/
- https://aws.amazon.com/cli/
- https://www.terraform.io/
- https://blog.gruntwork.io/a-comprehensive-guide-to-terraform-b3d32832baca
- Read about ELB, VPC, subnets, EC2 instances on the AWS site e.g. https://aws.amazon.com/documentation/elastic-load-balancing/
- Create the infra manually through the console and get it working as per the tests.
- Create the infra through the aws cli (https://aws.amazon.com/cli/) tool and get it working as per the tests.
- Create the infra through terraform and get it working as per the tests.
-
Create 1 VPC:
- name: test-vpc-1 -
1 internet gateway:
- name: test-vpc-igw-1 -
2 Subnets associated with above vpc:
- name: test-public-subnet-1 (associated with the above internet gateway) - name: test-private-subnet-1 -
2 EC2 instances in the above VPC
- name: test-instance-1 - subnet: test-private-subnet-1 - name: test-instance-2 - subnet: test-private-subnet-1 - name: test-bastion-host - subnet: test-public-subnet-1 - requirement: test-bastion-host should be able to ssh into test-instance-1 and test-instance-2 as they are not exposed to the internet -
The above 2 instances (test-instance-1 and test-instance-2) should be running a REST API server (django, flask, tomcat, etc. - your choice)
- description: Create a REST API for adding, viewing, deleting users- endpoint: /api/v1/health - method: POST - headers: - username: admin - password: complex_password_your_choice - payload: {"status": "good"} or {"status": "bad"} - returns: - body: empty - http status: 200- endpoint: /api/v1/health - method: GET - payload: empty - returns: - body: {"health": "good"} or {"health": "bad"} depending on the value set by the above call - http status: 200 or 500 depending on good or bad- endpoint: /api/v1/user - method: POST - headers: - username: admin - password: complex_password_your_choice - payload: {"username": "user1"} - returns: - body: {"status": "added"} - http status: 200- endpoint: /api/v1/user - method: GET - payload: empty - returns: - body: {"users": ["user1", "user2"] } - http status: 200- endpoint: /api/v1/user - method: DELETE - headers: - username: admin - password: complex_password_your_choice - payload: {"username": "user1"} - returns: - body: empty - http status: 200 on success - http status: 404 if username is invalid -
1 ELB associated with the above 2 instances
- test-elb - The ELB should check the health api endpoint: - if the instance is healthy - send it the api request (AWS does this on your behalf if you setup the health check properly) - if the instance is unhealthy - mark it as unhealthy (same condition as above) -
Testing (let me know if the curl commands are invalid):
-
Test the health endpoint:
$ curl -X GET http://your-elb-endpoint/api/v1/health -
Set health as good and verify:
$ curl -X POST \ -d '{"status": "good"}' \ -H 'Content-Type: application/json' \ -H 'username: admin' \ -H 'password: complex_password_your_choice' \ http://your-elb-endpoint/api/v1/health $ curl -X GET http://your-elb-endpoint/api/v1/health -
Set health as bad and verify:
$ curl -X POST \ -d '{"status": "bad"}' \ -H 'Content-Type: application/json' \ -H 'username: admin' \ -H 'password: complex_password_your_choice' \ http://your-elb-endpoint/api/v1/health $ curl -X GET http://your-elb-endpoint/api/v1/health -
Create user1:
$ curl -X POST \ -d '{"username": "user1"}' \ -H 'Content-Type: application/json' \ -H 'username: admin' \ -H 'password: complex_password_your_choice' \ http://your-elb-endpoint/api/v1/user $ curl -X GET http://your-elb-endpoint/api/v1/user -
Create user2:
$ curl -X POST \ -d '{"username": "user2"}' \ -H 'Content-Type: application/json' \ -H 'username: admin' \ -H 'password: complex_password_your_choice' \ http://your-elb-endpoint/api/v1/user $ curl -X GET http://your-elb-endpoint/api/v1/user -
Delete user1:
$ curl -X DELETE \ -d '{"username": "user1"}' \ -H 'Content-Type: application/json' \ -H 'username: admin' \ -H 'password: complex_password_your_choice' \ http://your-elb-endpoint/api/v1/user $ curl -X GET http://your-elb-endpoint/api/v1/user -
Any more interesting test cases you can come up with
-