Terraform deployment for Azure resources required for this use case¶
Terraform templates to deploy an Azure-based automated file processing and summary generation tool. The solution includes:
Table of Content (Click to expand)
Overview¶
.
├── README.md
├── src
├────── main.tf
├────── variables.tf
├────── provider.tf
├────── terraform.tfvars
├────── remote-storage.tf
├────── outputs.tf
- main.tf
(Main Terraform configuration file): This file contains the core infrastructure code. It defines the resources you want to create, such as Azure Blob Storage, Azure Functions, and other necessary services. It's the primary file where you describe your infrastructure in a declarative manner. - variables.tf
(Variable definitions): This file is used to define variables that can be used throughout your Terraform configuration. By using variables, you can make your configuration more flexible and reusable. For example, you can define variables for resource names, sizes, and other parameters that might change between environments. - provider.tf
(Provider configurations): Providers are plugins that Terraform uses to interact with cloud providers, SaaS providers, and other APIs. This file specifies the Azure provider and any necessary configuration for it, such as authentication details. - terraform.tfvars
(Variable values): This file contains the actual values for the variables defined invariables.tf. By separating variable definitions and values, you can easily switch between different sets of values for different environments (e.g., development, staging, production) without changing the main configuration files. - remote-storage.tf
(Remote state storage configuration): Terraform uses a state file to keep track of the resources it manages. This file configures remote state storage, which allows you to store the state file in a remote location (e.g., Azure Blob Storage). Remote state storage is crucial for collaboration and ensuring that the state file is not lost or corrupted. - outputs.tf
(Output values): This file defines the output values that Terraform should return after applying the configuration. Outputs are useful for displaying information about the resources created, such as resource IDs, connection strings, and other important details. They can also be used as inputs for other Terraform configurations or scripts.
Resources¶
| Resource | Description |
|---|---|
| Azure Resource Group | A logical container that organizes and manages all the related Azure resources. |
| Azure Blob Storage | Stores input files (xlsx, csv, docs, pdfs) and output summary files. |
| Azure Functions | Executes serverless compute tasks to process the uploaded files and generate summaries. |
| Azure AI Services | Provides text analytics and OCR capabilities to handle text data from docs and pdfs. |
| Azure Storage Account | Manages Blob Storage and other storage services. |
| Azure Key Vault | Stores and manages sensitive information such as connection strings and API keys. |
| Application Insights | Monitors the performance and usage of the file processing tool. |
| Log Analytics Workspace | Collects and analyzes log data from various sources. |
How to execute it¶
Important Modify
terraform.tfvarswith your information, then run the following flow.
1. Log in to Azure¶
This command logs you into your Azure account. It opens a browser window where you can enter your Azure credentials. Once logged in, you can manage your Azure resources from the command line.
cd ./terraform/src/
az login
2. Initialize Terraform¶
Initialize the working directory containing the Terraform configuration files. This downloads the required provider plugins and sets up the state backend.
terraform init
3. Provision infrastructure¶
Review the plan¶
Create an execution plan that shows the changes Terraform will make using the values in terraform.tfvars.
terraform plan -var-file terraform.tfvars
Apply the configuration¶
Apply the changes required to reach the configured state. Terraform prompts for confirmation before making changes and uses the values in terraform.tfvars.
terraform apply -var-file terraform.tfvars
Remove the infrastructure¶
Destroy the infrastructure managed by Terraform when it is no longer needed. Terraform prompts for confirmation and uses the values in terraform.tfvars.
terraform destroy -var-file terraform.tfvars