|
| 1 | +# Terraform deployment for Azure resources required for this use case |
| 2 | + |
| 3 | +Costa Rica |
| 4 | + |
| 5 | +[](https://github.com/) |
| 6 | +[brown9804](https://github.com/brown9804) |
| 7 | + |
| 8 | +Last updated: 2025-02-04 |
| 9 | + |
| 10 | +------------------------------------------ |
| 11 | + |
| 12 | +> Terraform templates to deploy an Azure-based automated file processing and summary generation tool. The solution includes: |
| 13 | +
|
| 14 | +<div align="center"> |
| 15 | + <img src="" alt="Centered Image" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px; width: 700px;"/> |
| 16 | +</div> |
| 17 | + |
| 18 | +<details> |
| 19 | +<summary><b>Table of Content </b> (Click to expand)</summary> |
| 20 | + |
| 21 | +- [Overview](#overview) |
| 22 | +- [Resources](#resources) |
| 23 | +- [How to execute it](#how-to-execute-it) |
| 24 | + |
| 25 | +</details> |
| 26 | + |
| 27 | + |
| 28 | +## Overview |
| 29 | + |
| 30 | +``` |
| 31 | +. |
| 32 | +├── README.md |
| 33 | +├── src |
| 34 | +├────── main.tf |
| 35 | +├────── variables.tf |
| 36 | +├────── provider.tf |
| 37 | +├────── terraform.tfvars |
| 38 | +├────── remote-storage.tf |
| 39 | +├────── outputs.tf |
| 40 | +``` |
| 41 | + |
| 42 | +- **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. |
| 43 | +- **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. |
| 44 | +- **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. |
| 45 | +- **terraform.tfvars** `(Variable values)`: This file contains the actual values for the variables defined in `variables.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. |
| 46 | +- **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. |
| 47 | +- **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. |
| 48 | + |
| 49 | +## Resources |
| 50 | + |
| 51 | + |
| 52 | +## How to execute it |
| 53 | + |
| 54 | +```mermaid |
| 55 | +graph TD; |
| 56 | + A[az login] --> B(terraform init) |
| 57 | + B --> C{Terraform provisioning stage} |
| 58 | + C -->|Review| D[terraform plan] |
| 59 | + C -->|Order Now| E[terraform apply] |
| 60 | + C -->|Delete Resource if needed| F[terraform destroy] |
| 61 | +``` |
| 62 | + |
| 63 | +> [!IMPORTANT] |
| 64 | +> Please modify `terraform.tfvars` with your information. Then run the following flow: |
| 65 | +
|
| 66 | +1. **Login 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. |
| 67 | + |
| 68 | + ```sh |
| 69 | + az login |
| 70 | + ``` |
| 71 | + |
| 72 | +2. **Initialize Terraform**: Initializes the working directory containing the Terraform configuration files. It downloads the necessary provider plugins and sets up the backend for storing the state. |
| 73 | + |
| 74 | + ``` sh |
| 75 | + terraform init |
| 76 | + ``` |
| 77 | + |
| 78 | + <div align="center"> |
| 79 | + <img src="" alt="Centered Image" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/> |
| 80 | + </div> |
| 81 | + |
| 82 | + |
| 83 | +3. **Terraform Provisioning Stage**: |
| 84 | + |
| 85 | + - **Review**: Creates an execution plan, showing what actions Terraform will take to achieve the desired state defined in your configuration files. It uses the variable values specified in `terraform.tfvars`. |
| 86 | + |
| 87 | + ```sh |
| 88 | + terraform plan -var-file terraform.tfvars |
| 89 | + ``` |
| 90 | + |
| 91 | + <div align="center"> |
| 92 | + <img src="" alt="Centered Image" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/> |
| 93 | + </div> |
| 94 | + |
| 95 | + - **Order Now**: Applies the changes required to reach the desired state of the configuration. It prompts for confirmation before making any changes. It also uses the variable values specified in `terraform.tfvars`. |
| 96 | + |
| 97 | + ```sh |
| 98 | + terraform apply -var-file terraform.tfvars |
| 99 | + ``` |
| 100 | + |
| 101 | + <img width="550" alt="image" src="" /> |
| 102 | + |
| 103 | + <img width="550" alt="image" src="" /> |
| 104 | + |
| 105 | + - **Remove**: Destroys the infrastructure managed by Terraform. It prompts for confirmation before deleting any resources. It also uses the variable values specified in `terraform.tfvars`. |
| 106 | + |
| 107 | + ```sh |
| 108 | + terraform destroy -var-file terraform.tfvars |
| 109 | + ``` |
| 110 | + |
| 111 | +<div align="center"> |
| 112 | + <h3 style="color: #4CAF50;">Total Visitors</h3> |
| 113 | + <img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/> |
| 114 | +</div> |
| 115 | + |
0 commit comments