Skip to content

OpenAPI terraform templating for API gateway with CORS, S3 results handling, and artifact tracking#88

Merged
Kayle-Verhiel merged 6 commits intomainfrom
73-generate-the-api-gateway-using-the-openapi-specification-and-terraform-templtes
Mar 20, 2026
Merged

OpenAPI terraform templating for API gateway with CORS, S3 results handling, and artifact tracking#88
Kayle-Verhiel merged 6 commits intomainfrom
73-generate-the-api-gateway-using-the-openapi-specification-and-terraform-templtes

Conversation

@prathikanand7
Copy link
Copy Markdown
Owner

@prathikanand7 prathikanand7 commented Mar 20, 2026

Issue

ISSUE > OpenAPI templating of Terraform

Description

This pull request introduces several improvements to both the frontend and backend of the batch platform, focusing on better error handling for missing artifacts, more robust frontend state management, and a major simplification of the API Gateway Terraform configuration by moving to an OpenAPI-driven approach.

Frontend improvements:

  • Improved handling of missing artifacts: The frontend now tracks jobs whose artifacts are unavailable, avoids repeated fetch attempts for these, and batches artifact hydration requests for efficiency. [1] [2] [3] [4] [5]
  • Updated the default API base URL.

Backend improvements:

  • Added a utility function _is_s3_not_found to standardize S3 404 error detection in the Lambda function that serves result artifacts, making error handling more robust and readable. [1] [2]

Infrastructure (Terraform) changes:

  • Major refactor of the API Gateway configuration: replaced the resource-by-resource Terraform setup with a single OpenAPI-driven configuration, greatly simplifying the code and making it easier to maintain and update the API structure.
  • Updated deployment triggers and dependencies to track changes in the OpenAPI spec and new gateway responses, ensuring deployments are correctly triggered.

These changes improve the reliability, maintainability, and clarity of both the frontend and backend codebases, while also streamlining infrastructure as code for the API Gateway

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation update
  • Configuration / infrastructure change
  • Other:

How has this been tested?

Describe how you verified that your changes work correctly. Include any relevant commands, test cases, or environments used. If no testing was needed, explain why.

  • Unit tests
  • Manual testing
  • No testing required

Notes for reviewers

Checklist

Go through each item before marking the PR as ready for review.

  • I filled in the releated issue link
  • My PR has the name of the branch
  • My code follows the project's coding style
  • I have reviewed my own changes before requesting review
  • I have added or updated relevant documentation
  • My changes do not introduce new warnings or errors
  • I have not committed any secrets, credentials, or sensitive values

Kayle-Verhiel and others added 5 commits March 17, 2026 11:43
Frontend: track unavailable artifacts and limit concurrent hydration (max 8), avoid repeatedly polling missing results, and update default API base URL. Backend lambda: add _is_s3_not_found helper and use it to correctly detect missing S3 objects and return 404. Terraform/API GW: add gateway-level CORS responses (4xx/5xx/MISSING_AUTHENTICATION_TOKEN/RESOURCE_NOT_FOUND) and adjust OpenAPI mock OPTIONS operations so preflight responses include required headers. Also updates the packaged results lambda artifact (results_lambda.zip). These changes improve browser CORS behavior and reduce unnecessary S3/API calls for missing artifacts.
Expand module README to describe the OpenAPI-driven implementation and operational model. Adds implementation steps, explicit list of routes from openapi.yaml, clarifies resource mappings and outputs, and details two-layer CORS handling (preflight via OpenAPI OPTIONS and gateway-level error responses). Also clarifies authentication (ApiKeyAuth for functional routes, unauthenticated OPTIONS) and tweaks example variable formatting and wording.
Replace resource-based assertions with string-count checks against aws_api_gateway_rest_api.api.body in the API Gateway tf tests. Tests now verify CORS OPTIONS operations, MOCK integrations, CORS response headers, inclusion of x-api-key, AWS_PROXY integration types, POST integration HTTP methods, non-OPTIONS ApiKeyAuth, OPTIONS security: [], and presence of gateway-level CORS responses (DEFAULT_4XX, DEFAULT_5XX, MISSING_AUTHENTICATION_TOKEN, RESOURCE_NOT_FOUND). This simplifies assertions to validate the generated OpenAPI body and ensures the expected five functional routes are represented.
@prathikanand7 prathikanand7 changed the title OpenAPI terraform templating for API gateway with CORS, S3 handling, and artifact tracking OpenAPI terraform templating for API gateway with CORS, S3 results handling, and artifact tracking Mar 20, 2026
Copy link
Copy Markdown
Collaborator

@Kayle-Verhiel Kayle-Verhiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review checklist

  • I checked all the changed files
  • I performed a manual test myself on both the EC2 and the fargate instance.
  • I tested all the endpoints.
  • I checked whether the code held up to our standards

Well done guys, let's get this merged!!

@Kayle-Verhiel Kayle-Verhiel merged commit 903fde9 into main Mar 20, 2026
17 checks passed
@Kayle-Verhiel Kayle-Verhiel deleted the 73-generate-the-api-gateway-using-the-openapi-specification-and-terraform-templtes branch March 20, 2026 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate the Api Gateway using the OpenAPI specification and terraform templtes

3 participants