DEV Community

Cory M
Cory M

Posted on

Cloud Resume Challenge - Part 3

I completed writing the backend as IaC in Terraform. As this was the first complicated project I have done in Terraform, I used an incremental approach to build each component and testing before expanding scope. While most of the essential parts, such as S3 buckets, IAM permissions, Route 53, and CloudFront were quite straightforward; there were a few issues that required a lot of research to fix, primarily due to cryptic error messages. For example, in the API Gateway Integration, I would receive an "BadRequestException: Enumeration value for HttpMethod must be non-empty" error. After digging through documentation and many searches on Stack Overflow, I discovered that this was due to not having used the integration_http_method argument, which the documentation identified as being optional, in addition to the required http_method argument.

After the Terraform code was competed and tested, the next step was to learn how to migrate the activation and distribution to GitHub Actions. This went fairly smoothly, as I had already learned the basics for the frontend code. I had a slight misstep in initializing tfvars, and in forgetting to remove reference to AWS credentials that had been stored locally during testing.

Once the backend had been proven as functional from GitHub Actions, the last step was for me to write a test. I had seen multiple references to a testing framework called Cypress, which interested me as an end-to-end tool for testing web applications. I used Cypress to request a GET on my API, then validate the response as 200 status and a number. This test was then integrated into my GitHub Action workflow to be run from a Docker image after Terraform apply has completed.

Top comments (0)