APIS

1. System Context

Developers use Nitric to declare APIs and routes within their application.

  • App code uses the API resource through defined endpoints.
  • Developers define API specifications and implement backend logic to handle HTTP requests.

Operations use default or overridden Terraform modules to provision the necessary resources for their target cloud.

Example AWS Provider
  • AWS API Gateway v2 serves as the HTTP API management service.
  • AWS Lambda functions are deployed to handle API requests.
  • AWS IAM (implicitly assumed) provides roles and policies for secure interaction between API Gateway and Lambda functions.
  • AWS ACM manages TLS certificates for custom domain names.
Define API
Terraform
Create API Gateway
Deploy Lambda Functions
Configure Permissions
Invoke
Provide Certificates
Manage Access
Developer
Operations
nitric up
AWS API Gateway v2
(HTTP API)
AWS Lambda Functions
AWS IAM
AWS ACM
(Certificates)
Example GCP Provider
  • Google API Gateway serves as the HTTP API management service, routing requests to backend services.
  • Google Cloud Run services are deployed to handle API requests with serverless execution.
  • Google IAM provides roles and policies to secure interactions between API Gateway, Cloud Run, and other GCP services.
  • Certificates (Google-managed or custom) ensure secure HTTPS communication for custom domain names.
  • Google Service Account is created and configured to allow API Gateway to invoke the Cloud Run backend securely.
Define API
Terraform
Create API Gateway
Deploy Cloud Run Services
Configure Permissions
Invoke
Provide Certificates
Manage Access
Developer
Operations
nitric up
Google API Gateway
Google Cloud Run
Google IAM
Certificates
(Google Managed or Custom)
Google Service Account

2. Sequence

ClientNitric SDKNitric RuntimeAPI GatewayApp WorkerSend HTTP API requestForward API requestRegister API routes (during deployment)Route incoming requestForward request to application logicProcess request and return responseRespond with resultReturn API responseClientNitric SDKNitric RuntimeAPI GatewayApp Worker

3. Component

API Module

  • Dynamically creates and manages API gateways to expose application functionality through HTTP endpoints and routes.
  • Configures API properties, including protocol type, API specifications (e.g., OpenAPI), and metadata for identification and lifecycle management.
  • Provisions and associates backend integrations with API routes, supporting multiple targets such as serverless functions, containers, or application services.
  • Automates the setup of custom domain names with secure certificates, abstracting provider-specific configurations for HTTPS communication.
  • Grants least privilege permissions to enable secure communication between the API gateway and backend services, ensuring robust security practices.
  • Supports versioning and staging of APIs, enabling seamless updates and rollbacks without disrupting existing deployments.
  • Abstracts the complexities of cloud-native API gateway services, providing a unified interface for developing and deploying HTTP APIs across different providers.

4. Code

Developers write application code that uses the API resource from the SDK, configures the api and implement HTTP routes and middleware.

SDK Reference by language -

Operations will use or extend the Nitric Terraform reference modules:

Last updated on Jan 24, 2025