- Docker installed in your system
- AWS account created
- Terraform installed in your system
- Access key and Secret key to create the infrastructure
- Clone the repository in local
- Go inside the folder RESTAPI
- Build the docker file using the command
docker build -t my-rest-api .
It would look something like this
- Run the application using docker by this command
docker run -d -p 5000:5000 my-rest-api
It would look something like this
- Open the browser and hit the url It would look like this
If you hit the same URL using GET call in Postman app, it will show the following results.
This Terraform configuration file provisions an AWS EC2 instance and runs a Dockerized REST API on it.
- Terraform installed on your machine
- AWS CLI configured with access key and secret key
- Clone the repository:
git clone https://github.com/your-repo.git
cd xalts_assignment
- Initialize Terraform
terraform init
- Review and apply the Terraform configuration:
terraform plan
terraform apply
- Access your REST API:Once the Terraform apply is successful, you can access your REST API at
http://<ec2-public-ip>:5000
- Replace your_access_key_id and your_secret_access_key with your AWS access key ID and secret access key respectively. Adjust the region (us-west-2), AMI ID (ami-XXXXXXXXXXX), and any other parameters as needed for your setup.
Once you run the terraform script in local, this is how the result is going to look like