Skip to content

Commit c6c3ae6

Browse files
authored
Merge pull request #22 from MicrosoftCloudEssentials-LearningHub/mongo-atlas
Batch account
2 parents 4576ca7 + a786491 commit c6c3ae6

File tree

8 files changed

+158
-1
lines changed

8 files changed

+158
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Local .terraform directories
22
**/.terraform/*
3+
**/.terraform
34

45
# .tfstate files
56
*.tfstate
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Terraform Template - Azure Batch
2+
3+
Costa Rica
4+
5+
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
6+
[brown9804](https://github.com/brown9804)
7+
8+
Last updated: 2025-06-01
9+
10+
----------
11+
12+
> This template contains Terraform configurations to create and manage an Azure Batch environment with dependencies on a Resource Group and Storage Account. Below is a description of the files and the variables used in this template.
13+
14+
> [!NOTE]
15+
> The Azure Batch environment depends on the Resource Group and Storage Account. Terraform ensures that these resources are created before the Batch environment by using the `depends_on` argument in the configuration.
16+
17+
<p align="center">
18+
<img width="700" alt="image" src="https://github.com/user-attachments/assets/f3079753-80f4-405e-9791-380050e5121a">
19+
</p>
20+
21+
## File Descriptions
22+
23+
- **main.tf**: Contains the main configuration for creating the Azure Batch environment and the resources it depends on.
24+
- **variables.tf**: Defines the input variables used in the Terraform configuration.
25+
- **provider.tf**: Configures the Azure provider to interact with Azure resources.
26+
- **terraform.tfvars**: Provides default values for the variables defined in `variables.tf`.
27+
- **outputs.tf**: Defines the outputs of the Terraform configuration, such as the Batch account name, pool names, and associated Resource Group.
28+
29+
## Variables
30+
31+
Below is a list of variables used in this template, their expected values, types, and examples:
32+
33+
| Variable Name | Description | Type | Example Value |
34+
|---------------------------|--------------------------------------------------|--------|-----------------------|
35+
| `resource_group_name` | The name of the Azure Resource Group to associate the Batch environment with. | string | `"my-resource-group"` |
36+
| `location` | The Azure region where the Resource Group will be created. | string | `"East US"` |
37+
| `storage_account_name` | The name of the Azure Storage Account to create. | string | `"mystorageaccount"` |
38+
| `batch_account_name` | The name of the Azure Batch Account to create. | string | `"mybatchaccount"` |
39+
| `tags` | A map of tags to assign to the resources. | map | `{ "env": "dev" }` |
40+
41+
<div align="center">
42+
<h3 style="color: #4CAF50;">Total Visitors</h3>
43+
<img src="https://profile-counter.glitch.me/brown9804/count.svg" alt="Visitor Count" style="border: 2px solid #4CAF50; border-radius: 5px; padding: 5px;"/>
44+
</div>

2_compute-containers/batch/main.tf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
resource "azurerm_resource_group" "example" {
2+
name = var.resource_group_name
3+
location = var.location
4+
}
5+
6+
7+
resource "azurerm_storage_account" "example" {
8+
name = var.storage_account_name
9+
resource_group_name = azurerm_resource_group.example.name
10+
location = azurerm_resource_group.example.location
11+
account_tier = "Standard"
12+
account_replication_type = "LRS"
13+
14+
depends_on = [
15+
azurerm_resource_group.example
16+
]
17+
}
18+
19+
resource "azurerm_batch_account" "example" {
20+
name = var.batch_account_name
21+
resource_group_name = azurerm_resource_group.example.name
22+
location = azurerm_resource_group.example.location
23+
pool_allocation_mode = "BatchService"
24+
storage_account_id = azurerm_storage_account.example.id
25+
storage_account_authentication_mode = "StorageKeys"
26+
27+
tags = {
28+
env = "test"
29+
}
30+
31+
depends_on = [
32+
azurerm_resource_group.example,
33+
azurerm_storage_account.example
34+
]
35+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
output "batch_account_name" {
2+
value = azurerm_batch_account.example.name
3+
}
4+
5+
output "resource_group_name" {
6+
value = azurerm_resource_group.example.name
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# provider.tf
2+
# This file configures the Azure provider to interact with Azure resources.
3+
# It specifies the required provider and its version, along with provider-specific configurations.
4+
5+
terraform {
6+
required_version = ">= 1.8, < 2.0"
7+
# Specify the required provider and its version
8+
required_providers {
9+
azurerm = {
10+
source = "hashicorp/azurerm" # Source of the AzureRM provider
11+
version = "~> 4.16.0" # Version of the AzureRM provider
12+
}
13+
}
14+
}
15+
16+
provider "azurerm" {
17+
features {} # Enable all features for the AzureRM provider
18+
subscription_id = var.subscription_id # Use the subscription ID variable
19+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resource_group_name = "my-resource-groupx2"
2+
location = "East US 2"
3+
storage_account_name = "mysabrownx2"
4+
batch_account_name = "mybatchbrwx2"
5+
subscription_id = "your-subscription-id"
6+
tags = {
7+
env = "dev"
8+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
variable "resource_group_name" {
2+
description = "The name of the Azure Resource Group to associate the Batch environment with."
3+
type = string
4+
}
5+
6+
variable "location" {
7+
description = "The Azure region where the Resource Group will be created."
8+
type = string
9+
}
10+
11+
variable "storage_account_name" {
12+
description = "The name of the Azure Storage Account to create."
13+
type = string
14+
}
15+
16+
variable "batch_account_name" {
17+
description = "The name of the Azure Batch Account to create."
18+
type = string
19+
}
20+
21+
variable "tags" {
22+
description = "A map of tags to assign to the resources."
23+
type = map(string)
24+
}
25+
26+
variable "subscription_id" {
27+
description = "The subscription ID for Azure"
28+
type = string
29+
}

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Costa Rica
55
[![GitHub](https://img.shields.io/badge/--181717?logo=github&logoColor=ffffff)](https://github.com/)
66
[brown9804](https://github.com/brown9804)
77

8-
Last updated: 2025-03-27
8+
Last updated: 2025-06-01
99

1010
----------
1111

@@ -50,6 +50,20 @@ Last updated: 2025-03-27
5050

5151
</details>
5252

53+
<details>
54+
<summary><b> Compute and Containers </b> (Click to expand) </summary>
55+
56+
- [Azure Virtual Machine](./2_compute-containers/virtual-machine)
57+
- [Azure Virtual Desktop](./2_compute-containers/virtual-desktop)
58+
- [Azure Kubernetes Service (AKS)](./2_compute-containers/kubernetes-service)
59+
- [Azure Functions (Function App)](./2_compute-containers/function-app)
60+
- [Azure Container Instances](./2_compute-containers/container-instances)
61+
- [Azure Batch](./2_compute-containers/batch)
62+
- [Azure App Service](./2_compute-containers/app-service)
63+
64+
</details>
65+
66+
5367
## Prerequisites
5468

5569
- An `Azure subscription is required`. All other resources, including instructions for creating a Resource Group, are provided in this repository.

0 commit comments

Comments
 (0)