The code in this repository uses Terraform to build an API demo in AWS, whose public endpoints perform basic arithmetic operation examples: sums, multiplications, ...
- Uniform endpoints running GET methods, where the querystring parameters (a & b) are the factors for the underlying operations.
- The exact collection of endpoints is configurable (by extending the
endpointsarray at the configuration file) For this demo, we only have implemented basic arithmetic operations (sum, diff, mul and div) but you can extend the collection by providing a backend at the assets folder - An extra
documentationendpoint. When users hit this API endpoint, they will get a newly generated version of the API's deocumentation describing the current API's configuration. This endpoint accepts aformatquerystring to allow users to decide if they want a Swagger (swagger) or OpenAPI (oas30) version of the documentation.
- Terraform installed
- An AWS account with a infrastructure user able to create API Gateway resources and Lambda functions.
- An AWS CLI instance logged in as the infrastructure user.
We implemented short versions of the native Terraform commands, thus, to set up the infrastructure and test the documentation endpoint we can just:
-
Run
make initat the root folder. -
Configure the API at configuration.tf. Where:
endpoints.operationindicates the backend for any endpoint.endpoints.descriptioninforms about each endpoint in the API's docs.descriptionan API's descriptionterms_of_servicea link to the API's terms of servicecontactAPI's contact informationlicensea link to the API's license
-
Run
make applyat the root folder -
Hit the API's
/documentationendpoint and check if all the details are present. -
Just in case, clean up by running
make destroyat the root folder.
