## Deployment To execute a deployment excute the following commands
npm install
to install all dependencies required for cdk.cdk bootstrap
cdk deploy
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template
We have a Golang based API in the api directory of this repo. It is deployed to AWS with the Cloud Development Kit (CDK). The application itself is deployed to AWS ECS.
There is a swagger file in the repo with details of the request and the response.
There are some tests for the API in the app_test.go file. The scenarios set out in the test have been covered.
API is available on http://GSTec-Farga-1BLYX3MS2MBWI-878009822.eu-west-1.elb.amazonaws.com/products/e8864473-91a0-4f4b-9ce6-903d15acce4f/packs?quantity={X}
. The product itself is not persisted the only product we have is statically configured in code and has ID e8864473-91a0-4f4b-9ce6-903d15acce4f
.
The pack sizes are not currently configurable. But they are a property of the Product class. Which if it was persisted it would mean that the pack sizes could be stored in the DB and therefore wouldn't need code changes to update.
Test product ID is e8864473-91a0-4f4b-9ce6-903d15acce4f. Products are manually configured in the getProductPacksHandler.
curl http://{HOSTNAME}:{PORT}/products/xxx/packs?quantity={Quantity}
curl http://{HOSTNAME}:{PORT}/products/e8864473-91a0-4f4b-9ce6-903d15acce4f/packs?quantity={Quantity}
After running make start
the API should be available on port 8080.
- cd into the
api
directory. - Execute
go test
- Deployment from https://medium.com/tysonworks/deploy-go-applications-to-ecs-using-aws-cdk-1a97d85bb4cb
- Project structure https://sourcegraph.com/github.com/katzien/go-structure-examples@master/-/blob/layered/main.go?L30 https://about.sourcegraph.com/go/gophercon-2018-how-do-you-structure-your-go-apps/
- Creating a REST API GO https://tutorialedge.net/golang/creating-restful-api-with-golang/