https://github.com/yagoluiz/exchange-rate-api
Exchange Rate API using .NET 5 and AWS infrastructure
https://github.com/yagoluiz/exchange-rate-api
aws aws-cloudformation docker docker-compose dotnet-5
Last synced: 3 months ago
JSON representation
Exchange Rate API using .NET 5 and AWS infrastructure
- Host: GitHub
- URL: https://github.com/yagoluiz/exchange-rate-api
- Owner: yagoluiz
- Created: 2021-03-13T14:45:32.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-01-25T21:23:18.000Z (over 4 years ago)
- Last Synced: 2025-03-17T07:44:57.687Z (over 1 year ago)
- Topics: aws, aws-cloudformation, docker, docker-compose, dotnet-5
- Language: C#
- Homepage:
- Size: 56.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Exchange Rate API

API responsible for making foreign currency quotes for BRL (Brazilian Real).
## Instructions for run project
Run project via Docker, via Visual Studio (F5 or CTRL + F5), Visual Studio Code (tasks project) or CLI.
### Docker
```bash
docker-compose up -d
```
### .NET CLI
- Run project
```bash
src/Exchange.Rate.API
dotnet watch run
```
- Run tests
```bash
dotnet test -t
```
## Endpoints
*GET /quote*
```bash
curl -X GET "http://localhost:5000/api/v1/exchange-rates/quote?amount=10¤cy=USD" -H "accept: application/json"
```
*GET /conversion*
```bash
curl -X GET "http://localhost:5000/api/v1/exchange-rates/conversion?amount=10¤cy=USD&customerSegment=PRIVATE" -H "accept: application/json"
```
For more information visit swagger: *http://localhost:5000/swagger/index.html*
## Deploy
### AWS arquitecture reference

*[https://github.com/thombergs/code-examples/blob/master/aws/cloudformation/ecs-in-two-public-subnets/ecs-in-two-public-subnets.svg](https://github.com/thombergs/code-examples/blob/master/aws/cloudformation/ecs-in-two-public-subnets/ecs-in-two-public-subnets.svg)*
Step by step to manual deploy using **AWS CloudFormation**:
1. Create Docker image repository
This project uses the AWS ECR (Docker Container Registry) as a Docker image repository. Other repositories can be used, such as the Docker Hub.
- Execute docker-compose file:
```bash
docker-compose up -d
```
Enter the folder *scripts/aws/ecr* and run the scripts:
- Run script to create AWS ECR:
```bash
sh ecr-deploy.sh
```
- Run script to deploy the AWS ECR image. Necessary to include AWS **AccountId** as a parameter:
```bash
sh image-deploy.sh 999999999999
```
2. Create networks
Enter the folder *scripts/aws/networks* and run the scripts:
- Run script to create and deploy networks
```bash
sh network-deploy.sh
```
3. Create services
Check the status of network creation on AWS CloudFormation. Run this step only when the status is completed: **CREATE_COMPLETE**.
Enter the folder *scripts/aws/services* and run the scripts:
- Run script to create and deploy services. Necessary to include AWS **AccountId** as a parameter:
```bash
sh service-deploy.sh 999999999999
```
The deployment of this project via AWS CloudFormation was based on the following references:
- *https://reflectoring.io/aws-cloudformation-deploy-docker-image/*
- *https://github.com/thombergs/code-examples/tree/master/aws/cloudformation/ecs-in-two-public-subnets*
### Delete deploy
```bash
aws cloudformation delete-stack \
--stack-name exchange-rate-api-service
```
Run delete stack service step only when the status is completed: **CREATE_COMPLETE**.
```bash
aws cloudformation delete-stack \
--stack-name exchange-rate-api-network
```