<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ikponmwosa Omorisiagbon</title>
    <description>The latest articles on DEV Community by Ikponmwosa Omorisiagbon (@ikponmwosa_omorisiagbon_f).</description>
    <link>https://dev.to/ikponmwosa_omorisiagbon_f</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2345475%2F651f2bd5-c0de-4fa9-8e63-15cca85bb654.png</url>
      <title>DEV Community: Ikponmwosa Omorisiagbon</title>
      <link>https://dev.to/ikponmwosa_omorisiagbon_f</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ikponmwosa_omorisiagbon_f"/>
    <language>en</language>
    <item>
      <title>Auto-Generate API Gateway Terraform from OpenAPI Specs</title>
      <dc:creator>Ikponmwosa Omorisiagbon</dc:creator>
      <pubDate>Mon, 08 Sep 2025 17:14:50 +0000</pubDate>
      <link>https://dev.to/ikponmwosa_omorisiagbon_f/auto-generate-api-gateway-terraform-from-openapi-specs-2gg8</link>
      <guid>https://dev.to/ikponmwosa_omorisiagbon_f/auto-generate-api-gateway-terraform-from-openapi-specs-2gg8</guid>
      <description>&lt;p&gt;&lt;strong&gt;The Problem&lt;/strong&gt;&lt;br&gt;
You've written your OpenAPI spec. It's beautiful, well-documented, and describes your API perfectly. But now you need to deploy it to AWS API Gateway, and that means writing Terraform.&lt;br&gt;
Again.&lt;br&gt;
For the fifth time this month.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hclresource "aws_apigatewayv2_api" "payments_api" {
  name          = "payments-api"
  protocol_type = "HTTP"
}

resource "aws_apigatewayv2_route" "payments_post" {
  api_id    = aws_apigatewayv2_api.payments_api.id
  route_key = "POST /payments"
  target    = "integrations/${aws_apigatewayv2_integration.payments.id}"
}

resource "aws_apigatewayv2_integration" "payments" {
  api_id           = aws_apigatewayv2_api.payments_api.id
  integration_type = "HTTP_PROXY"
  integration_uri  = "https://payments.internal.com"
  integration_method = "POST"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  ... repeat for every endpoint
&lt;/h1&gt;

&lt;p&gt;Sound familiar? You're essentially duplicating information that already exists in your OpenAPI spec.&lt;br&gt;
What if Your API Spec Was Your Infrastructure Definition?&lt;br&gt;
This repetition bothered me enough to build something about it. What if instead of maintaining two sources of truth (OpenAPI spec + Terraform), your API specification could generate the infrastructure?&lt;br&gt;
Here's what that looks like:&lt;br&gt;
yaml# payment-api.yaml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;openapi: 3.0.3
info:
  title: Payment Service API
  version: 1.0.0
x-service: payments  # Infrastructure hint

paths:
  /process:
    post:
      summary: Process payment
      x-rate-limit:    # Infrastructure configuration
        requests: 100
        period: 60
        burst: 150
      responses:
        '200':
          description: Payment processed
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One command later:&lt;br&gt;
&lt;code&gt;bash./striche.sh deploy -s payment-api.yaml -p aws --auto-approve&lt;/code&gt;&lt;br&gt;
Your API Gateway is live, with proper rate limiting, routing, and all the Terraform you didn't have to write.&lt;br&gt;
How It Works&lt;br&gt;
The tool (Striche Gateway) follows a simple pipeline:&lt;br&gt;
OpenAPI Spec → Canonical Model → Platform Templates → Terraform → Deployed Infrastructure&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Parse the Spec
Extract API structure, paths, methods, and custom extensions:
typescript// Simplified parsing logic
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const spec = await parseOpenAPI('payment-api.yaml');
const service = spec.info['x-service'] || 'default';
const routes = extractRoutes(spec.paths);
const rateLimits = extractRateLimits(spec.paths);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Generate Infrastructure
Use Handlebars templates to create clean Terraform:
hcl# Generated main.tf
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module "{{service}}_service" {
  source = "./modules/service"

  service_name = "{{service}}"
  routes = [
    {{#each routes}}
    {
      path = "{{path}}"
      method = "{{method}}"
      {{#if rateLimit}}
      rate_limit = {{rateLimit.requests}}
      burst_limit = {{rateLimit.burst}}
      {{/if}}
    }{{#unless @last}},{{/unless}}
    {{/each}}
  ]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Deploy
Standard Terraform workflow - nothing magical, just automated:
&lt;code&gt;bash terraform init&lt;/code&gt;
&lt;code&gt;terraform plan&lt;/code&gt;
&lt;code&gt;terraform apply&lt;/code&gt;
The Unified Gateway Pattern
The interesting part isn't just generating basic API Gateway configs. It's solving the "multiple microservices, one gateway" problem.
Instead of deploying separate gateways for each service:
bash# Multiple services through a single gateway
&lt;code&gt;./striche.sh deploy -s auth-api.yaml,payments-api.yaml,orders-api.yaml -p aws&lt;/code&gt;
Result: One API Gateway with intelligent routing:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /auth/login → Auth service backend
POST /payments/process → Payments service backend
GET /orders/{id} → Orders service backend
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;All through a single endpoint with consolidated rate limiting and monitoring.&lt;br&gt;
OpenAPI Extensions: Infrastructure Hints&lt;br&gt;
The key insight is using OpenAPI's vendor extension mechanism to embed infrastructure configuration:&lt;br&gt;
yamlpaths:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  /login:
    post:
      x-rate-limit:
        requests: 10    # Allow 10 login attempts
        period: 60      # per minute
        burst: 15       # with burst protection
      x-service: auth   # Route to auth backend
These extensions translate directly to Terraform resources:
hclresource "aws_apigatewayv2_route" "auth_login" {
  api_id    = aws_apigatewayv2_api.main.id
  route_key = "POST /auth/login"

  throttle_settings {
    rate_limit  = 10
    burst_limit = 15
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Real-World Benefits&lt;br&gt;
After using this approach for several microservices deployments:&lt;br&gt;
Time Savings: What used to take 30-45 minutes of Terraform writing now takes 2 minutes&lt;br&gt;
Consistency: Every API Gateway follows the same patterns and best practices&lt;br&gt;
Single Source of Truth: API documentation and infrastructure config live together&lt;br&gt;
Easy Updates: Change the spec, redeploy, infrastructure updates automatically&lt;br&gt;
Generated vs Hand-Written Terraform&lt;br&gt;
The output is standard Terraform that you could have written manually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;out/
├── main.tf              # Clean, readable root config
├── variables.tf         # Parameterized inputs
├── terraform.tfvars     # Service-specific values
├── outputs.tf           # API Gateway URLs and IDs
└── modules/
    └── service/         # Reusable service module
        ├── main.tf
        ├── variables.tf
        └── outputs.tf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No custom providers, no weird abstractions. Just well-structured Terraform that follows community conventions.&lt;br&gt;
When This Makes Sense&lt;br&gt;
This approach works well when:&lt;/p&gt;

&lt;p&gt;You have multiple APIs with similar infrastructure patterns&lt;br&gt;
Your team maintains OpenAPI specs anyway&lt;br&gt;
You want consistency across service deployments&lt;br&gt;
Rate limiting and routing rules change frequently&lt;/p&gt;

&lt;p&gt;It's probably overkill for:&lt;/p&gt;

&lt;p&gt;Single API deployments&lt;br&gt;
Complex custom infrastructure requirements&lt;br&gt;
Teams that don't use OpenAPI specs&lt;/p&gt;

&lt;p&gt;Try It Yourself&lt;br&gt;
The tool is open source and available on GitHub:&lt;br&gt;
&lt;code&gt;bash git clone https://github.com/striche-AI/striche-gateway&lt;/code&gt;&lt;br&gt;
&lt;code&gt;cd striche-gateway&lt;/code&gt;&lt;br&gt;
&lt;code&gt;npm install&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Try with the example specs
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;./striche.sh deploy -s specs/payment-service.yaml -p aws
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Currently supports AWS (API Gateway v2), with GCP and Azure planned.&lt;br&gt;
The Bigger Picture&lt;br&gt;
This is really about closing the gap between API design and infrastructure deployment. Your OpenAPI spec already describes your API's behavior - why not let it describe the infrastructure too?&lt;br&gt;
We're moving toward a world where infrastructure is more declarative and less manual. Treating API specifications as infrastructure definitions feels like a natural evolution.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
