Skip to content

Lightweight Terraform template for Azure with modular structure, env workspaces, sane naming/tagging, and ready-to-use resource examples.

Notifications You must be signed in to change notification settings

Khavanw/azure-terraform-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Azure Functions Terraform Template

This repository provides a Terraform template to deploy Azure Functions and related resources.

Getting Started

Prerequisites

  • Terraform installed
  • Azure CLI authenticated

Usage

1. Initialize Terraform

terraform init

2. Plan and Apply for Development

terraform plan -var-file=dev.tfvars terraform apply -var-file=dev.tfvars

3. Plan and Apply for Production

terraform plan -var-file=prod.tfvars terraform apply -var-file=prod.tfvars

Import Existing Azure Resources

If you already have existing resources in Azure, you can import them into your Terraform state using the following commands. Replace placeholders (<SUB>, <sa-name>, etc.) with your actual values.

Resource Group

terraform import azurerm_resource_group.rg \ /subscriptions/<SUB>/resourceGroups/rg-kha-dev-core

Storage Account

terraform import azurerm_storage_account.sa \ /subscriptions/<SUB>/resourceGroups/rg-kha-dev-core/providers/Microsoft.Storage/storageAccounts/<sa-name>

App Service Plan

terraform import azurerm_service_plan.sp \ /subscriptions/<SUB>/resourceGroups/rg-kha-dev-core/providers/Microsoft.Web/serverfarms/<asp-name>

Log Analytics Workspace

terraform import azurerm_log_analytics_workspace.log_aw \ /subscriptions/<SUB>/resourceGroups/rg-kha-dev-core/providers/Microsoft.OperationalInsights/workspaces/<ws-name>

Application Insights

terraform import azurerm_application_insights.ai \ /subscriptions/<SUB>/resourceGroups/rg-kha-dev-core/providers/microsoft.insights/components/<ai-name>

Linux Function App

terraform import azurerm_linux_function_app.az_linux \ /subscriptions/<SUB>/resourceGroups/rg-kha-dev-core/providers/Microsoft.Web/sites/func-kha-dev-api

(Optional) Specific Function in the App

terraform import azurerm_function_app_function.az_func \ /subscriptions/<SUB>/resourceGroups/rg-kha-dev-core/providers/Microsoft.Web/sites/func-kha-dev-api/functions/example-function-app-function

Feel free to customize the variables and resource names as needed for your environment.

About

Lightweight Terraform template for Azure with modular structure, env workspaces, sane naming/tagging, and ready-to-use resource examples.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published