Skip to content

Commit f5e2605

Browse files
committed
infra - open framework
1 parent f83fcfb commit f5e2605

6 files changed

Lines changed: 301 additions & 1 deletion

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# .tfstate files
55
*.tfstate
66
*.tfstate.*
7+
.terraform.lock.hcl
78

89
# Crash log files
910
crash.log
@@ -13,7 +14,6 @@ crash.*.log
1314
# password, private keys, and other secrets. These should not be part of version
1415
# control as they are data points which are potentially sensitive and subject
1516
# to change depending on the environment.
16-
*.tfvars
1717
*.tfvars.json
1818

1919
# Ignore override files as they are usually used to override resources locally and so

terraform-infrastructure/main.tf

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
# Resource Group
2+
resource "azurerm_resource_group" "rg" {
3+
name = var.resource_group_name
4+
location = var.location
5+
6+
# Output the resource group name
7+
provisioner "local-exec" {
8+
command = "echo Resource Group: ${self.name}"
9+
}
10+
}
11+
# Storage Account
12+
resource "azurerm_storage_account" "storage" {
13+
name = var.storage_account_name
14+
resource_group_name = azurerm_resource_group.rg.name
15+
location = azurerm_resource_group.rg.location
16+
account_tier = "Standard"
17+
account_replication_type = "LRS"
18+
19+
depends_on = [azurerm_resource_group.rg]
20+
21+
# Output the storage account name
22+
provisioner "local-exec" {
23+
command = "echo Storage Account: ${self.name}"
24+
}
25+
}
26+
27+
# Blob Container for Input Files
28+
resource "azurerm_storage_container" "input_container" {
29+
name = "input"
30+
storage_account_id = azurerm_storage_account.storage.id
31+
container_access_type = "private"
32+
33+
depends_on = [azurerm_storage_account.storage]
34+
35+
# Output the container name
36+
provisioner "local-exec" {
37+
command = "echo Input Container: ${self.name}"
38+
}
39+
}
40+
41+
# Blob Container for Output Files
42+
resource "azurerm_storage_container" "output_container" {
43+
name = "output"
44+
storage_account_id = azurerm_storage_account.storage.id
45+
container_access_type = "private"
46+
47+
depends_on = [azurerm_storage_account.storage]
48+
49+
# Output the container name
50+
provisioner "local-exec" {
51+
command = "echo Output Container: ${self.name}"
52+
}
53+
}
54+
55+
# Linux Function App
56+
resource "azurerm_linux_function_app" "function_app" {
57+
name = var.function_app_name
58+
location = azurerm_resource_group.rg.location
59+
resource_group_name = azurerm_resource_group.rg.name
60+
service_plan_id = azurerm_service_plan.asp.id
61+
storage_account_name = azurerm_storage_account.storage.name
62+
storage_account_access_key = azurerm_storage_account.storage.primary_access_key
63+
64+
site_config {
65+
# Other configurations can go here
66+
}
67+
68+
depends_on = [azurerm_service_plan.asp]
69+
70+
provisioner "local-exec" {
71+
command = "echo Function App: ${self.name}"
72+
}
73+
}
74+
75+
76+
# Service Plan
77+
resource "azurerm_service_plan" "asp" {
78+
name = var.app_service_plan_name
79+
location = azurerm_resource_group.rg.location
80+
resource_group_name = azurerm_resource_group.rg.name
81+
os_type = "Linux"
82+
sku_name = "Y1" # Consumption plan
83+
84+
depends_on = [azurerm_resource_group.rg]
85+
86+
# Output the service plan name
87+
provisioner "local-exec" {
88+
command = "echo Service Plan: ${self.name}"
89+
}
90+
}
91+
92+
# Application Insights
93+
resource "azurerm_application_insights" "appinsights" {
94+
name = var.app_insights_name
95+
location = azurerm_resource_group.rg.location
96+
resource_group_name = azurerm_resource_group.rg.name
97+
application_type = "web"
98+
workspace_id = azurerm_log_analytics_workspace.loganalytics.id
99+
100+
depends_on = [azurerm_resource_group.rg]
101+
102+
provisioner "local-exec" {
103+
command = "echo Application Insights: ${self.name}"
104+
}
105+
}
106+
107+
# Log Analytics Workspace
108+
resource "azurerm_log_analytics_workspace" "loganalytics" {
109+
name = var.log_analytics_workspace_name
110+
location = azurerm_resource_group.rg.location
111+
resource_group_name = azurerm_resource_group.rg.name
112+
sku = "PerGB2018"
113+
114+
depends_on = [azurerm_resource_group.rg]
115+
116+
# Output the log analytics workspace name
117+
provisioner "local-exec" {
118+
command = "echo Log Analytics Workspace: ${self.name}"
119+
}
120+
}
121+
122+
# Key Vault
123+
resource "azurerm_key_vault" "keyvault" {
124+
name = var.key_vault_name
125+
location = azurerm_resource_group.rg.location
126+
resource_group_name = azurerm_resource_group.rg.name
127+
tenant_id = data.azurerm_client_config.current.tenant_id
128+
sku_name = "standard"
129+
130+
depends_on = [azurerm_resource_group.rg]
131+
132+
# Output the key vault name
133+
provisioner "local-exec" {
134+
command = "echo Key Vault: ${self.name}"
135+
}
136+
}
137+
138+
# Data source to get tenant ID
139+
data "azurerm_client_config" "current" {}
140+
141+
# CosmosDB
142+
resource "azurerm_cosmosdb_account" "cosmosdb" {
143+
name = var.cosmosdb_account_name
144+
location = azurerm_resource_group.rg.location
145+
resource_group_name = azurerm_resource_group.rg.name
146+
offer_type = "Standard"
147+
kind = "GlobalDocumentDB"
148+
consistency_policy {
149+
consistency_level = "Session"
150+
}
151+
152+
geo_location {
153+
location = azurerm_resource_group.rg.location
154+
failover_priority = 0
155+
}
156+
157+
depends_on = [azurerm_resource_group.rg]
158+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
output "resource_group_name" {
2+
description = "The name of the resource group."
3+
value = azurerm_resource_group.rg.name
4+
}
5+
6+
output "storage_account_name" {
7+
description = "The name of the storage account"
8+
value = azurerm_storage_account.storage.name
9+
}
10+
11+
output "input_container_name" {
12+
description = "The name of the input container"
13+
value = azurerm_storage_container.input_container.name
14+
}
15+
16+
output "output_container_name" {
17+
description = "The name of the output container"
18+
value = azurerm_storage_container.output_container.name
19+
}
20+
21+
output "function_app_name" {
22+
description = "The name of the Linux Function App."
23+
value = azurerm_linux_function_app.function_app.name
24+
}
25+
26+
output "app_service_plan_name" {
27+
description = "The name of the Service Plan"
28+
value = azurerm_service_plan.asp.name
29+
}
30+
31+
output "app_insights_name" {
32+
description = "The name of the Application Insights instance"
33+
value = azurerm_application_insights.appinsights.name
34+
}
35+
36+
output "log_analytics_workspace_name" {
37+
description = "The name of the Log Analytics workspace"
38+
value = azurerm_log_analytics_workspace.loganalytics.name
39+
}
40+
41+
output "key_vault_name" {
42+
description = "The name of the Key Vault"
43+
value = azurerm_key_vault.keyvault.name
44+
}
45+
46+
47+
output "cosmosdb_account_name" {
48+
description = "The name of the CosmosDB account."
49+
value = azurerm_cosmosdb_account.cosmosdb.name
50+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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 features for the AzureRM provider
18+
key_vault {
19+
recover_soft_deleted_key_vaults = false
20+
purge_soft_delete_on_destroy = true
21+
}
22+
}
23+
24+
subscription_id = var.subscription_id # Use the subscription ID variable
25+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Sample values
2+
subscription_id = "" # "your-subscription_id"
3+
resource_group_name = "RG-PDFs-Processing-OpenFramework" # "your-resource-group-name"
4+
location = "West US" # "your-location"
5+
# Storage Account
6+
storage_account_name = "storageaccountbrownpdfof" # "your-storage-account-name"
7+
# Function App
8+
function_app_name = "fapdfofbrown" # "your-function-app-name"
9+
# App Service Plan
10+
app_service_plan_name = "asppdfofbrown" # "your-app-service-plan-name"
11+
# Application Insights
12+
app_insights_name = "apppdfofbrown" # "your-app-insights-name"
13+
# Log Analytics Workspace
14+
log_analytics_workspace_name = "logwspdfofbrown" # "your-log-analytics-workspace-name"
15+
# Key Vault
16+
key_vault_name = "kvpdfofrbrown" # "your-key-vault-name"
17+
# CosmosDB
18+
cosmosdb_account_name = "cosmospdfofbrown" # "your-cosmosdb-account-name"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
variable "subscription_id" {
2+
description = "The subscription ID for the Azure account."
3+
type = string
4+
}
5+
6+
variable "resource_group_name" {
7+
description = "The name of the resource group."
8+
type = string
9+
}
10+
11+
variable "location" {
12+
description = "The Azure region where resources will be created."
13+
type = string
14+
}
15+
16+
17+
variable "storage_account_name" {
18+
description = "The name of the storage account"
19+
type = string
20+
}
21+
22+
variable "function_app_name" {
23+
description = "The name of the Linux Function App."
24+
type = string
25+
}
26+
27+
variable "app_service_plan_name" {
28+
description = "The name of the App Service plan"
29+
type = string
30+
}
31+
32+
variable "app_insights_name" {
33+
description = "The name of the Application Insights instance"
34+
type = string
35+
}
36+
37+
variable "log_analytics_workspace_name" {
38+
description = "The name of the Log Analytics workspace"
39+
type = string
40+
}
41+
42+
variable "key_vault_name" {
43+
description = "The name of the Key Vault"
44+
type = string
45+
}
46+
variable "cosmosdb_account_name" {
47+
description = "The name of the CosmosDB account."
48+
type = string
49+
}

0 commit comments

Comments
 (0)