The module deploys a static website hosting solution on Azure using Storage Account and Front Door for CDN, providing a secure and scalable infrastructure for hosting static web content.

Azure Static Website

Creates and manages a Static Website in Azure
$350
BUY
Log in to Corewide IaC registry

Once you have a Corewide Solutions Portal account, this one-time action will use your browser session to retrieve credentials:

 shellterraform login solutions.corewide.com
Provision instructions

Initialize mandatory providers:

Copy and paste into your Terraform configuration and insert the variables:

 hclmodule "tf_azure_static_website" {
  source  = "solutions.corewide.com/azure/tf-azure-static-website/azurerm"
  version = "~> 1.0.0"

  # specify module inputs here or try one of the examples below
  ...
}

Initialize the setup:

 shellterraform init
Define update strategy

Corewide DevOps team strictly follows Semantic Versioning Specification to provide our clients with products that have predictable upgrades between versions. We recommend pinning patch versions of our modules using pessimistic constraint operator (~>) to prevent breaking changes during upgrades.

To get new features during the upgrades (without breaking compatibility), use ~> 1.0 and run terraform init -upgrade

For the safest setup, use strict pinning with version = "1.0.0"

v1.0.0 released 4 months ago

Setup a static website with custom domains and virtual routing enabled for SPA. Use Azure DNS module to provision TXT records for domain validation, A and CNAME records to point domains to the Front Door endpoint:

 hclresource "azurerm_resource_group" "foo" {
  name     = "static-website-rg-foo"
  location = "westeurope"
}

module "dns" {
  source  = "solutions.corewide.com/azure/tf-azure-dns/azurerm"
  version = "~> 1.0"

  resource_group_name = azurerm_resource_group.foo.name
  create_zone         = true
  zone_name           = "example.com"

  records = {
    "_dnsauth" = {
      type  = "TXT"
      ttl   = 120
      value = [module.static_website.domain_validation_tokens["example.com"]]
    }
    "_dnsauth.www" = {
      type  = "TXT"
      ttl   = 120
      value = [module.static_website.domain_validation_tokens["www.example.com"]]
    }
    "@" = {
      type  = "A"
      ttl   = 120
      alias = "${module.static_website.frontdoor_profile.id}/afdendpoints/${module.static_website.frontdoor_endpoint.name}"
    }
    "www" = {
      type  = "CNAME"
      ttl   = 120
      value = [module.static_website.frontdoor_endpoint.host_name]
    }
  }
}

module "static_website" {
  source  = "solutions.corewide.com/azure/tf-azure-static-website/azurerm"
  version = "~> 1.0"

  storage_account_name    = "mystaticwebsite-cdn"
  resource_group_name     = azurerm_resource_group.foo.name
  region                  = azurerm_resource_group.foo.location
  dns_zone_id             = module.dns.zone.id
  virtual_routing_enabled = true

  domains = [
    "example.com",
    "www.example.com",
  ]
}

Minimal setup with default parameters:

 hclresource "azurerm_resource_group" "foo" {
  name     = "static-website-rg-foo"
  location = "East US"
}

module "static_website" {
  source  = "solutions.corewide.com/azure/tf-azure-static-website/azurerm"
  version = "~> 1.0"

  storage_account_name = "mystaticwebsite-foo"
  resource_group_name  = azurerm_resource_group.foo.name
  region               = azurerm_resource_group.foo.location
}
Variable Description Type Default Required Sensitive
region Azure region to deploy resources into string yes no
resource_group_name Name of the resource group to deploy resources into string yes no
storage_account_name Globally unique storage account name string yes no
dns_zone_id ID of the DNS zone for custom domain configuration string no no
domains Custom domain names for Front Door distribution list(string) [] no no
min_tls_version The minimum supported TLS version for the storage account string TLS1_2 no no
tags Tags to be assigned to resources map(string) {} no no
virtual_routing_enabled Enable virtual routing for correct processing of Single Page Applications bool false no no
Output Description Type Sensitive
domain_validation_tokens Map of domains to their validation tokens computed no
frontdoor_endpoint Front Door endpoint attributes resource no
frontdoor_profile Front Door profile attributes resource no
storage_account_data Storage account attributes resource yes
Dependency Version Kind
terraform >= 1.3 CLI
hashicorp/azurerm ~> 4.6 provider

Not sure where to start?
Let's find your perfect match.