Configuration in this directory creates Azure storage account and enable the static website and create optional CDN service for the static website.
Following example to create a storage account with static website.
module "static-website-cdn" {
source = "kumarvna/static-website-cdn/azurerm"
version = "2.2.0"
# Resource Group, location, and Storage account details
resource_group_name = "rg-demo-westeurope-01"
location = "westeurope"
storage_account_name = "storageaccwesteupore01"
# Static Website createion set to true by default
# account_kind should set to StorageV2 or BlockBlobStorage
static_website_source_folder = var.static_website_source_folder
index_path = var.index_path
custom_404_path = var.custom_404_path
# Adding TAG's to your Azure resources (Required)
tags = {
Terraform = "true"
Environment = "dev"
Owner = "test-user"
}
}
Following example to create a storage account, static website with CDN endpoint.
module "static-website-cdn" {
source = "kumarvna/static-website-cdn/azurerm"
version = "2.2.0"
# Resource Group, location, and Storage account details
create_resource_group = true
resource_group_name = "rg-demo-westeurope-01"
location = "westeurope"
storage_account_name = "storageaccwesteupore01"
# Static Website createion set to true by default
# account_kind should set to StorageV2 or BlockBlobStorage
static_website_source_folder = var.static_website_source_folder
index_path = var.index_path
custom_404_path = var.custom_404_path
# CDN endpoint for satic website
enable_cdn_profile = true
cdn_profile_name = var.cdn_profile_name
cdn_sku_profile = var.cdn_sku_profile
# Custom domain for CDN endpoint
custom_domain_name = "web.example.com"
friendly_name = "mywebapp"
# Adding TAG's to your Azure resources (Required)
tags = {
Terraform = "true"
Environment = "dev"
Owner = "test-user"
}
}
To run this example you need to execute following Terraform commands
terraform init
terraform plan
terraform apply
Run terraform destroy
when you don't need these resources.
Name | Description |
---|---|
static_website_cdn_endpoint_hostname | CDN endpoint URL for Static website |
static_website_cdn_profile_name | CDN profile name for the static website |
static_website_url | static web site URL from storage account |
storage_account_id | The ID of the storage account. |
storage_account_name | The name of the storage account. |
storage_primary_access_key | The primary access key for the storage account. |
storage_primary_connection_string | The primary connection string for the storage account. |