REGISTER NOW FOR THE KONG AGENTIC ERA WORLD TOUR GOVERN A2A TRAFFIC WITH KONG'S NEW AGENT GATEWAY WHY GARTNER’S “CONTEXT MESH” CHANGES EVERYTHING DON’T MISS API + AI SUMMIT 2026 SEPT 30 – OCT 1
  • [Why Kong](/company/why-kong)Why Kong
    • Explore the unified API Platform
        • BUILD APIs
        • [
          Kong Insomnia](/products/kong-insomnia)
          Kong Insomnia
        • [
          API Design](/products/kong-insomnia/api-design)
          API Design
        • [
          API Mocking](/products/kong-insomnia/api-mocking)
          API Mocking
        • [
          API Testing and Debugging](/products/kong-insomnia/api-testing-and-debugging)
          API Testing and Debugging
        • [
          MCP Client](/products/kong-insomnia/mcp-client)
          MCP Client
        • RUN APIs
        • [
          API Gateway](/products/kong-gateway)
          API Gateway
        • [
          Context Mesh](/products/kong-konnect/features/context-mesh)
          Context Mesh
        • [
          AI Gateway](/products/kong-ai-gateway)
          AI Gateway
        • [
          Event Gateway](/products/event-gateway)
          Event Gateway
        • [
          Kubernetes Operator](/products/kong-gateway-operator)
          Kubernetes Operator
        • [
          Service Mesh](/products/kong-mesh)
          Service Mesh
        • [
          Ingress Controller](/products/kong-ingress-controller)
          Ingress Controller
        • [
          Runtime Management](/products/kong-konnect/features/runtime-management)
          Runtime Management
        • DISCOVER APIs
        • [
          Developer Portal](/products/kong-konnect/features/developer-portal)
          Developer Portal
        • [
          Service Catalog](/products/kong-konnect/features/api-service-catalog)
          Service Catalog
        • [
          MCP Registry](/products/mcp-registry)
          MCP Registry
        • GOVERN APIs
        • [
          Metering and Billing](/products/kong-konnect/features/usage-based-metering-and-billing)
          Metering and Billing
        • [
          APIOps and Automation](/products/apiops-automation)
          APIOps and Automation
        • [
          API Observability](/products/kong-konnect/features/api-observability)
          API Observability
        • [Why Kong?](/company/why-kong)Why Kong?
      • CLOUD
      • [Cloud API Gateways](/products/kong-konnect/features/dedicated-cloud-gateways)Cloud API Gateways
      • [Need a self-hosted or hybrid option?](/products/kong-enterprise)Need a self-hosted or hybrid option?
      • COMPARE
      • [Considering AI Gateway alternatives? ](/performance-comparison/ai-gateway-alternatives)Considering AI Gateway alternatives?
      • [Kong vs. Postman](/performance-comparison/kong-vs-postman)Kong vs. Postman
      • [Kong vs. MuleSoft](/performance-comparison/kong-vs-mulesoft)Kong vs. MuleSoft
      • [Kong vs. Apigee](/performance-comparison/kong-vs-apigee)Kong vs. Apigee
      • [Kong vs. IBM](/performance-comparison/ibm-api-connect-vs-kong)Kong vs. IBM
      • GET STARTED
      • [Sign Up for Kong Konnect](/products/kong-konnect/register)Sign Up for Kong Konnect
      • [Documentation](https://developer.konghq.com/)Documentation
      • FOR PLATFORM TEAMS
      • [Developer Platform](/solutions/building-developer-platform)Developer Platform
      • [Kubernetes and Microservices](/solutions/build-on-kubernetes)Kubernetes and Microservices
      • [Observability](/solutions/observability)Observability
      • [Service Mesh Connectivity ](/solutions/service-mesh-connectivity)Service Mesh Connectivity
      • [Kafka Event Streaming](/solutions/kafka-stream-api-management)Kafka Event Streaming
      • FOR EXECUTIVES
      • [AI Connectivity](/ai-connectivity)AI Connectivity
      • [Open Banking](/solutions/open-banking)Open Banking
      • [Legacy Migration](/solutions/legacy-api-management-migration)Legacy Migration
      • [Platform Cost Reduction](/solutions/api-platform-consolidation)Platform Cost Reduction
      • [Kafka Cost Optimization](/solutions/reduce-kafka-cost)Kafka Cost Optimization
      • [API Monetization](/solutions/api-monetization)API Monetization
      • [AI Monetization](/solutions/ai-monetization)AI Monetization
      • [AI FinOps](/solutions/ai-cost-governance-finops)AI FinOps
      • FOR AI TEAMS
      • [Agent Gateway](/agent-gateway)Agent Gateway
      • [AI Governance](/solutions/ai-governance)AI Governance
      • [AI Security](/solutions/ai-security)AI Security
      • [AI Cost Control](/solutions/ai-cost-optimization-management)AI Cost Control
      • [Agentic Infrastructure](/solutions/agentic-ai-workflows)Agentic Infrastructure
      • [MCP Production](/solutions/mcp-production-and-consumption)MCP Production
      • [MCP Traffic Gateway](/solutions/mcp-governance)MCP Traffic Gateway
      • FOR DEVELOPERS
      • [Mobile App API Development](/solutions/mobile-application-api-development)Mobile App API Development
      • [GenAI App Development](/solutions/power-openai-applications)GenAI App Development
      • [API Gateway for Istio](/solutions/istio-gateway)API Gateway for Istio
      • [Decentralized Load Balancing](/solutions/decentralized-load-balancing)Decentralized Load Balancing
      • BY INDUSTRY
      • [Financial Services](/solutions/financial-services-industry)Financial Services
      • [Healthcare](/solutions/healthcare)Healthcare
      • [Higher Education](/solutions/api-platform-for-education-services)Higher Education
      • [Insurance](/solutions/insurance)Insurance
      • [Manufacturing](/solutions/manufacturing)Manufacturing
      • [Retail](/solutions/retail)Retail
      • [Software & Technology](/solutions/software-and-technology)Software & Technology
      • [Transportation](/solutions/transportation-and-logistics)Transportation
      • [See all Solutions](/solutions)See all Solutions
  • [Pricing](/pricing)Pricing
      • DOCUMENTATION
      • [Kong Konnect](https://developer.konghq.com/konnect/)Kong Konnect
      • [Kong Gateway](https://developer.konghq.com/gateway/)Kong Gateway
      • [Kong Mesh](https://developer.konghq.com/mesh/)Kong Mesh
      • [Kong AI Gateway](https://developer.konghq.com/ai-gateway/)Kong AI Gateway
      • [Kong Event Gateway](https://developer.konghq.com/event-gateway/)Kong Event Gateway
      • [Kong Insomnia](https://developer.konghq.com/insomnia/)Kong Insomnia
      • [Plugin Hub](https://developer.konghq.com/plugins/)Plugin Hub
      • EXPLORE
      • [Blog](/blog)Blog
      • [Learning Center](/blog/learning-center)Learning Center
      • [eBooks](/resources/e-book)eBooks
      • [Reports](/resources/reports)Reports
      • [Demos](/resources/demos)Demos
      • [Customer Stories](/customer-stories)Customer Stories
      • [Videos](/resources/videos)Videos
      • EVENTS
      • [API + AI Summit](/events/conferences/api-ai-summit)API + AI Summit
      • [Agentic Era World Tour](/agentic-era-world-tour)Agentic Era World Tour
      • [Webinars](/events/webinars)Webinars
      • [User Calls](/events/user-calls)User Calls
      • [Workshops](/events/workshops)Workshops
      • [Meetups](/events/meetups)Meetups
      • [See All Events](/events)See All Events
      • FOR DEVELOPERS
      • [Get Started](https://developer.konghq.com/)Get Started
      • [Community](/community)Community
      • [Certification](/academy/certification)Certification
      • [Training](https://education.konghq.com)Training
      • COMPANY
      • [About Us](/company/about-us)About Us
      • [We're Hiring!](/company/careers)We're Hiring!
      • [Press Room](/company/press-room)Press Room
      • [Contact Us](/company/contact-us)Contact Us
      • [Kong Partner Program](/partners)Kong Partner Program
      • [Enterprise Support Portal](https://support.konghq.com/s/)Enterprise Support Portal
      • [Documentation](https://developer.konghq.com/?_gl=1*tphanb*_gcl_au*MTcxNTQ5NjQ0MC4xNzY5Nzg4MDY0LjIwMTI3NzEwOTEuMTc3MzMxODI2MS4xNzczMzE4MjYw*_ga*NDIwMDU4MTU3LjE3Njk3ODgwNjQ.*_ga_4JK9146J1H*czE3NzQwMjg1MjkkbzE4OSRnMCR0MTc3NDAyODUyOSRqNjAkbDAkaDA)Documentation
  • [](/search)
  • [Login](https://cloud.konghq.com/login)Login
  • [Book Demo](/contact-sales)Book Demo
  • [Get Started](/products/kong-konnect/register)Get Started
[Blog](/blog)Blog
  • [AI Gateway](/blog/tag/ai-gateway)AI Gateway
  • [AI Security](/blog/tag/ai-security)AI Security
  • [AIOps](/blog/tag/aiops)AIOps
  • [API Security](/blog/tag/api-security)API Security
  • [API Gateway](/blog/tag/api-gateway)API Gateway
|
    • [API Management](/blog/tag/api-management)API Management
    • [API Development](/blog/tag/api-development)API Development
    • [API Design](/blog/tag/api-design)API Design
    • [Automation](/blog/tag/automation)Automation
    • [Service Mesh](/blog/tag/service-mesh)Service Mesh
    • [Insomnia](/blog/tag/insomnia)Insomnia
    • [Event Gateway](/blog/tag/event-gateway)Event Gateway
    • [View All Blogs](/blog/page/1)View All Blogs
We're Entering the Age of AI Connectivity [Read more](/blog/news/the-age-of-ai-connectivity)Read moreProducts & Agents:
    • [Kong AI Gateway](/products/kong-ai-gateway)Kong AI Gateway
    • [Kong API Gateway](/products/kong-gateway)Kong API Gateway
    • [Kong Event Gateway](/products/event-gateway)Kong Event Gateway
    • [Kong Metering & Billing](/products/usage-based-metering-and-billing)Kong Metering & Billing
    • [Kong Insomnia](/products/kong-insomnia)Kong Insomnia
    • [Kong Konnect](/products/kong-konnect)Kong Konnect
  • [Documentation](https://developer.konghq.com)Documentation
  • [Book Demo](/contact-sales)Book Demo
  1. Home
  2. Blog
  3. Engineering
  4. Kong Configurations Using Terraform via GitOps Model
[Engineering](/blog/engineering)Engineering
May 4, 2021
4 min read

# Kong Configurations Using Terraform via GitOps Model

Vaibhav Khurana

As organizations adopt a [microservices architecture](https://konghq.com/learning-center/microservices/microservices-architectures)microservices architecture, API gateway usage has increased. [Kong Gateway](https://konghq.com/kong)Kong Gateway is one of the promising [API gateways](https://konghq.com/blog/learning-center/what-is-an-api-gateway)API gateways in the market. It has both OSS and enterprise support, releases multiple features and is easy to use.

[Kong Admin API](https://docs.konghq.com/gateway-oss/2.4.x/admin-api)Kong Admin API helps administrators configure the system easily, but it's still error-prone. That's because the user has to hit many curl calls for creating all the configs. When numerous folks are managing the system, this becomes difficult.

The simplistic approach to solving all these issues is to move all the configurations to the GitOps model. Then, move all the configs to a VCS repository and follow the PR model to apply all the changes to any environment. To do this, you must have:

  1. - All the configurations present in VCS for easy consumption
  2. - A PR approval mechanism in place to verify all the configurations
  3. - A way to revert the commit and re-apply mistakes during reviews

Combining the benefits of GitOps and Terraform as IAC gives us the following advantages over the conventional manual curl calls:

  1. - A state lock so that no two people make changes on the same objects
  2. - Easy-to-identify changes introduced as part of the apply, making a more informed decision
  3. - Using terraform apply to fix any mistakes

## Demo: Kong Configs Using Terraform

For this demo, I'll be doing the following:

  1. - Use a VCS repo to push the code that will create a service, route, upstream and the targets for this service.
  2. - Apply the Kong configurations via Terraform.
  3. - Make a change, analyze the diffs and apply the changes.

**Prerequisites:**

  • - [Kong's Terraform Provider](https://github.com/Kong/kong-terraform-aws)Kong's Terraform Provider
  • - [Kevholditch's Kong Terraform Provider](https://github.com/kevholditch/terraform-provider-kong)Kevholditch's Kong Terraform Provider
  • - [Terraform ~= 0.12.x](https://www.terraform.io/downloads.html)Terraform ~= 0.12.x
  • - [Kong Gateway](https://konghq.com/kong)Kong Gateway

For making configurations more simple and easy to manage, I published a [module in the Terraform Registry](https://registry.terraform.io/modules/vaibhavkhurana2018/kong-module/kong/latest)module in the Terraform Registry.

[The code used in this demo is also there in the GitHub repo for reference.](https://github.com/vaibhavkhurana2018/terraform-kong-kong-module)The code used in this demo is also there in the GitHub repo for reference.

Before moving ahead with the code, verify that your Kong Admin API is working and that you have this configuration:

Kong Configurations Start

Kong Configurations at Start

From the above picture, it is clear that Kong Admin API is accessible and has no configurations.

### **1. State.tf**

This file contains the state information, including the backend and the providers I will be using.

*Note: Please replace the **kong_admin_uri** with the admin URI of your Kong Gateway.*

provider "kong" {
  kong_admin_uri = "http://127.0.0.1:8001" 
}
terraform {
  required_version = "0.12.20"
}

*Pro Tip: You should use remote backend storage like S3 for storing the state.*

### **2. B****asesvc.tf**

Create this file and use the below code for creating all the required resources.

module base-svc {
  source = "vaibhavkhurana2018/kong-module/kong"
  name   = "base-svc"
  upstream_config = {
    targets = {
      "base-svc.cluster.local:8001" = {
        weight = 100
      }
    }
  }
  route_config = {
    hosts = ["basesvc.example.com"]
    paths = {
      all_route={
        path=[""]
      },
    }
  }
}

This code is required for creating a service called base-svc, which will forward all the requests to the target base-svc.cluster.local:8001 for the requests matching route https://basesvc.example.com/ or http://basesvc.example.com.

### **3. Run Terraform Init for initializing the backend and the provider.**

Successful Terraform Init

Successful Terraform Init

If your Terraform provider configuration is correct, then you will get the above success message.

### **4. Run Terraform Plan for planning the changes done by the code.**

Terraform Plan Output

Terraform Plan Output

Terraform Plan Output

`

If you have followed everything until now, you will get a similar output of the plan that will show you all the resources that are getting created.

### **5. Run Terraform Apply for applying all these configurations on Kong.**

Successful Apply

Successful Apply

### **6. Verify the changes via the Admin API curl calls:**

http://<admin-uri>/services
http://<admin-uri>/routes
http://<admin-uri>/upstreams

Verified Kong Service Creation

Verified Creation of Service

Verified Kong Route Creation

Verified Creation of Route

Verified Kong Upstream Creation

Verified Creation-Upstream

### **7. Add a change in the code. **

For example, I added another host header in the above configuration and planned again. The below shows that I added another host, base1.svc.example.com, in my route config. The system will update it in place.

Added Host Route Config

The module gives the flexibility of configuring all the required things by providing minimal information and code as well as the ability to do customizations on the default values from the callers, which is in the module's [README](https://github.com/vaibhavkhurana2018/terraform-kong-kong-module/blob/main/README.md)README.

### **Bonus**

In the demo above, I did the Terraform plan and applied it from my local machine. That might work for smaller teams, but that will not be something you'll want with a big team. For achieving a true GitOps model, you can use [Atlantis](https://www.runatlantis.io)Atlantis for Terraform planning and apply it directly from the PR.

Plan via Atlantis

Plan via Atlantis

## Summary

In this article, I configured a Kong Gateway service using the module with minimal code and no hassle by ensuring that all configurations exist in a VCS repo. This solved issues like audit, approvals, reverts, etc., thus helping me follow the GitOps model. Along with Atlantis, this gives me a way to make sure that all the changes to Kong configurations are on track, audited and have clear visibility on the changes made as part of a PR.

If you have any additional questions, [post them on Kong Nation](https://discuss.konghq.com)post them on Kong Nation.

To stay in touch, [join the Kong Community](https://konghq.com/community)join the Kong Community.

Once you've successfully set up Kong Configurations Using Terraform, you may find these other tutorials helpful:

  • - [How to Use the Kong Gateway JWT Plugin for Service Authentication](https://konghq.com/blog/jwt-kong-gateway)How to Use the Kong Gateway JWT Plugin for Service Authentication
  • - [4 Steps to Authorizing Services With the Kong Gateway OAuth2 Plugin](https://konghq.com/blog/kong-gateway-oauth2)4 Steps to Authorizing Services With the Kong Gateway OAuth2 Plugin
  • - [Getting Started With Kuma Service Mesh](https://konghq.com/blog/getting-started-kuma-service-mesh)Getting Started With Kuma Service Mesh

- [API Management](/blog/tag/api-management)API Management- [GitOps](/blog/tag/gitops)GitOps- [API Development](/blog/tag/api-development)API Development

## More on this topic

_Videos_

## From Zero to Hero: A Roadmap for Automating the Development Lifecycle Across Any Environment with GitOps

_eBooks_

## How to Sell Kong's API Platform to your CIO

## See Kong in action

Accelerate deployments, reduce vulnerabilities, and gain real-time visibility. 

[Get a Demo](/contact-sales)Get a Demo
**Topics**
- [API Management](/blog/tag/api-management)API Management- [GitOps](/blog/tag/gitops)GitOps- [API Development](/blog/tag/api-development)API Development
Vaibhav Khurana

Recommended posts

# What Is CI/CD?

[Engineering](/blog)EngineeringJuly 23, 2024

The pace of the industry today is pressuring software developers to build, test, and release software more frequently than ever. To achieve this pace, teams have built two core processes into their workflow: Continuous Integration and Continuous Dep

Kong
[](https://konghq.com/blog/engineering/what-is-ci-cd)

# Announcing Standard Webhooks

[Engineering](/blog)EngineeringDecember 13, 2023

We're pleased to announce the launch of Standard Webhooks!  Kong has been part of the Technical Committee of this standard with other great companies like Svix (the initiator of the project), Ngrok, Zapier, Twillio, Lob, Mux, and Supabase. This was

Vincent Le Goff
[](https://konghq.com/blog/engineering/announcing-standard-webhooks)

# How to Streamline API Development with Consistent API Controls Across Teams

[Engineering](/blog)EngineeringAugust 29, 2023

This post is part of a series on becoming a secure API-first company. For a deeper dive, check out the eBook Leading Digital Transformation: Best Practices for Becoming a Secure API-First Company . The growth of APIs isn't just rapid — it's a seism

Kong
[](https://konghq.com/blog/engineering/consistent-controls-api-security)

# Getting Started With Kong Konnect in 10 Minutes

[Engineering](/blog)EngineeringJuly 7, 2023

In this Kong Konnect tutorial, you'll learn how to leverage the platform to manage your API ecosystem from a single easy-to-use interface. We’ll run through how to: Use Konnect Runtime Manager to set up your own Kong Gateway runtime instance i

Adam Bauman
[](https://konghq.com/blog/engineering/getting-started-konnect)

# Writing an eBPF/XDP load-balancer in Rust

[Engineering](/blog)EngineeringOctober 19, 2022

In today's cloud ecosystem the demands for high functioning and high performance observability, security and networking functionality for applications and their network traffic are as high as ever. Historically a great deal of this kind of functio

Shane Utt
[](https://konghq.com/blog/engineering/writing-an-ebpf-xdp-load-balancer-in-rust)

# Optimize Your API Gateway with Chaos Engineering

[Engineering](/blog)EngineeringAugust 10, 2022

As engineers and architects, we automatically build resilience into platforms as far as possible. But what about the unknown failures? What about the unknown behavior of your platform? The philosopher, Socrates, once said "You don’t know what you do

Andrew Kew
[](https://konghq.com/blog/engineering/optimize-your-api-gateway-with-chaos-engineering)

# Argo Use Cases for GitOps & ML

[Engineering](/blog)EngineeringApril 4, 2022

In this Kongcast episode , Henrik Blixt, Product Manager for Argo at Intuit, gives an introduction to Argo, an open source tool for Kubernetes and incubating project of CNCF. Check out the transcript and video from our conversation below, and be su

Kaitlyn Barnard
[](https://konghq.com/blog/engineering/argo-use-cases-for-gitops-ml)

## Ready to see Kong in action?

Get a personalized walkthrough of Kong's platform tailored to your architecture, use cases, and scale requirements.

[Get a Demo](/contact-sales)Get a Demo

## step-0

  • ## Company

    • [About Kong](/company/about-us)About Kong
    • [Customers](/customer-stories)Customers
    • [Careers](/company/careers)Careers
    • [Press](/company/press-room)Press
    • [Events](/events)Events
    • [Contact](/company/contact-us)Contact
    • [Pricing](/pricing)Pricing
      • Terms
      • Privacy
      • Trust and Compliance
  • ## Platform

    • [Kong AI Gateway](/products/kong-ai-gateway)Kong AI Gateway
    • [Kong Konnect](/products/kong-konnect)Kong Konnect
    • [Kong Gateway](/products/kong-gateway)Kong Gateway
    • [Kong Event Gateway](/products/event-gateway)Kong Event Gateway
    • [Kong Insomnia](/products/kong-insomnia)Kong Insomnia
    • [Documentation](https://developer.konghq.com)Documentation
    • [Book Demo](/contact-sales)Book Demo
  • ## Compare

    • [AI Gateway Alternatives](/performance-comparison/ai-gateway-alternatives)AI Gateway Alternatives
    • [Kong vs Apigee](/performance-comparison/kong-vs-apigee)Kong vs Apigee
    • [Kong vs IBM](/performance-comparison/ibm-api-connect-vs-kong)Kong vs IBM
    • [Kong vs Postman](/performance-comparison/kong-vs-postman)Kong vs Postman
    • [Kong vs Mulesoft](/performance-comparison/kong-vs-mulesoft)Kong vs Mulesoft
  • ## Explore More

    • [Open Banking API Solutions](/solutions/open-banking)Open Banking API Solutions
    • [API Governance Solutions](/solutions/api-governance)API Governance Solutions
    • [Istio API Gateway Integration](/solutions/istio-gateway)Istio API Gateway Integration
    • [Kubernetes API Management](/solutions/build-on-kubernetes)Kubernetes API Management
    • [API Gateway: Build vs Buy](/campaign/secure-api-scalability)API Gateway: Build vs Buy
    • [Kong vs Apigee](/performance-comparison/kong-vs-apigee)Kong vs Apigee
  • ## Open Source

    • [Kong Gateway](https://developer.konghq.com/gateway/install/)Kong Gateway
    • [Kuma](https://kuma.io/)Kuma
    • [Insomnia](https://insomnia.rest/)Insomnia
    • [Kong Community](/community)Kong Community

Kong enables the connectivity layer for the agentic era – securely connecting, governing, and monetizing APIs and AI tokens across any model or cloud.

  • English
  • Japanese
  • Frenchcoming soon
  • Spanishcoming soon
  • Germancoming soon
© Kong Inc. 2026
Interaction mode