Member-only story
Azure — Backend Architecture Modules with Azure APIM, Function App, Cosmos DB with Terraform
A step by step guide with an example project

In Terraform, modules are the way to modularize your terraform code and make it reusable. We should not create a wrapper for every resource and call it a module. The module should be a logical group of resources that you can deploy at once.
There are a number of ways you can build a backend infrastructure on Azure such as App Services, Function Apps, etc. You can even build and deploy the entire backend on Kubernetes as well. Companies are using serverless architectures more and more for the backend. In this post, we will use a simple backend on Azure with APIM, Function App, and Cosmos DB.
- Prerequisites
- Example Project
- When Should We Create Modules
- Terraform Code Without Modules
- Creating Function App and CosmosDB Modules
- Creating an APIM Module
- Importing a Module
- Module Inputs
- Module Outputs
- Module Dependencies
- Configuring Backend
- Implementation and Demo