Coin market api-integration
- Public endpoint for ad-hoc request
- AWS CloudWatch to make a scheduler
- Postgres as data storage
Architecture Diagram
Run with Docker
- Build
make build
docker build . -t api-rest
- Run
- Test
- Scan
- To deploy (1)
1. GOOS=linux GOARCH=amd64 go build -o main main.go
2. zip -r ./main.zip *
3. Upload to labmda function
- To deploy (2) via aws-cli
1. Build Image: docker build -t coinmarket-[version] .
2. Create RCR Repo: aws ecr create-repository --repository-name coinmarket-[version] --image-scanning-configuration scanOnPush=true
3. Tag image to repo: docker tag coinmarket-[version]:latest [ecr_repo_id].dkr.ecr.ap-southeast-1.amazonaws.com/coinmarket-[version]:latest
4. Login to ECR: aws ecr get-login-password | docker login --username AWS --password-stdin [ecr_repo_id].dkr.ecr.ap-southeast-1.amazonaws.com
5. Push Image to ECR: docker push [ecr_repo_id].dkr.ecr.ap-southeast-1.amazonaws.com/coinmarket-[version]:latest
6. To invoke: aws lambda invoke --function-name coinmarket output.txt
- Add env variables
export COIN_MARKET_TOKEN=
export COIN_MARKET_URL=
export SEARCH_PATH=
export COINS=btc,eth,sol,xtz
Notes
- Create postgres database and user in your local env.
- Make sure you setup file watchers in your idea.
- Before make a git push , please make sure you run
make scan
and make test
Contributed by: Aspire Trust and Security Team