The eps63_order_app is a very small API (one endpoint) written with the Flask Framework (Python 3.7). The /order
endpoint receives an order´s payload and it publishes a message on a SNS topic, so that a consumer can process the request later on.
- AWS credentials.
- SNS topic already created.
- An email´s subscription to the topic.
- Epsagon Key.
pip install virtualenv
virtualenv env --python=python3.7
source env/bin/activate
pip install -r requirements.txt
AWS_ACCESS_KEY=<your_aws_access_key> AWS_SECRET_ACCESS_KEY=<your_aws_secret_key> APP_TOPIC=<sns_topic> EPSAGON_KEY=<your_epsagon_key> FLASK_APP=app.py flask run
POST http://localhost:5000/order
{ "order": "1", "product": "Nike", "amount": 400 }
pip install virtualenv
virtualenv env --python=python3.7
source env/bin/activate
pip install -r requirements.txt
AWS_ACCESS_KEY=<your_aws_access_key> AWS_SECRET_ACCESS_KEY=<your_aws_secret_key> APP_TOPIC=<sns_topic> EPSAGON_KEY=<your_epsagon_key> gunicorn --bind 0.0.0.0:8000 wsgi:app
POST http://localhost:8000/order
{ "order": "1", "product": "Nike", "amount": 400 }
docker build -t <your-repo>/order_app .
docker run -p 8000:8000 -e AWS_ACCESS_KEY=<your_aws_access_key> -e AWS_SECRET_ACCESS_KEY=<your_aws_secret_key> -e APP_TOPIC=<sns_topic> -e EPSAGON_KEY=<your_epsagon_key> --rm <your-repo>/order_app
POST http://<your_local_ip>:8000/order
{ "order": "1", "product": "Nike", "amount": 400 }
- Create a repository on AWS ECR (https://us-east-2.console.aws.amazon.com/ecr/get-started?region=us-east-2)
- Get authenticated against AWS $(aws ecr get-login --no-include-email --region us-east-2)
docker tag <your-repo>:order_app <owner_id>.dkr.ecr.us-east-2.amazonaws.com/<your_repo>:latest
docker push <owner_id>.dkr.ecr.us-east-2.amazonaws.com/<your_repo>:order_app
- Create a task definition and run it following https://epsagon.com/blog/deploying-java-spring-boot-on-aws-fargate/
- Hit the endpoint
POST http://<AWS_FARGATE_IP>:8000/order
{ "order": "1", "product": "Nike", "amount": 400 }
In all cases, you should see the payload sent to the endpoint on your email´s inbox.