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.
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
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
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"
|
Module
50% off
|
€320
|
| TOTAL | €320 |
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.
All notable changes to this project are documented here.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
5.01.9 due to using cross-object referencing for input variable validationsmin_tls_version input because the Azure provider kept only TLS1_2 as the only available option(Last version compatible with the Azure Terraform provider version 4.0)
4.57static_website block in the storage account resource to a dedicated azurerm_storage_account_static_website resourceFirst stable version
v1.x to v2.xModule from v2.0 has changed Azure Terraform provider version, which isn't compatible with older versions. After the module version is upgraded, re-init the module to upgrade the provider version. Upgrade the Azure provider version at the project level:
hclterraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 5.0"
}
}
}
Upgrade project dependencies:
bashterraform init --upgrade
Update the declaration of the module according to the requirements and examples to match the designed configuration, then the configuration can be applied.
Apply the changes to make sure the state of the resources is up-to-date with the new provider version:
bashterraform apply
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
}
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",
]
}
| 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 |