Skip to content

Instantly share code, notes, and snippets.

@rollendxavier
Created January 2, 2025 04:16
Show Gist options
  • Save rollendxavier/21237468ddef96abe87b7f40e614aa03 to your computer and use it in GitHub Desktop.
Save rollendxavier/21237468ddef96abe87b7f40e614aa03 to your computer and use it in GitHub Desktop.
Provisioning Azure Resources with Terraform
provider "azurerm" {
features {}
subscription_id = "YOUR_AZ_SUBSCRIPTION_ID"
}
terraform {
backend "azurerm" {
resource_group_name = "rg-realtime-crypto-alerts"
storage_account_name = "stgrealtimecryptoalerts"
container_name = "tfstate"
key = "terraform.tfstate"
}
}
resource "azurerm_resource_group" "crypto_rg" {
name = "rg-crypto-alerts"
location = var.location
tags = var.tags
}
resource "azurerm_storage_account" "crypto_storage" {
name = "stgcryptoalerts"
resource_group_name = azurerm_resource_group.crypto_rg.name
location = var.location
account_tier = "Standard"
account_replication_type = "LRS"
tags = var.tags
}
resource "azurerm_service_plan" "crypto_plan" {
name = "asp-realtime-crypto-alerts"
location = var.location
resource_group_name = azurerm_resource_group.crypto_rg.name
os_type = "Linux"
sku_name = "Y1"
tags = var.tags
}
resource "azurerm_function_app" "crypto_function_app" {
name = "func-realtime-crypto-alerts"
resource_group_name = azurerm_resource_group.crypto_rg.name
location = var.location
storage_account_name = azurerm_storage_account.crypto_storage.name
storage_account_access_key = azurerm_storage_account.crypto_storage.primary_access_key
app_service_plan_id = azurerm_service_plan.crypto_plan.id
os_type = "linux"
site_config {
linux_fx_version = "DOTNET|6.0"
}
app_settings = {
"WEBSITE_RUN_FROM_PACKAGE" = "1"
"COINGECKO_API_KEY" = "<your_coingecko_api_key>"
"GMAIL_PASSWORD" = "<your_gmail_password>"
"ALERT_EMAIL" = ""<your_gmail_id>"
}
tags = var.tags
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment