Skip to content

telekom-mms/terraform-azurerm-cdn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cdn

This module manages the hashicorp/azurerm cdn resources. For more information see https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs > cdn

<-- This file is autogenerated, please do not change. -->

Requirements

Name Version
terraform >=1.5
azurerm >=3.72.0, <4.0

Providers

Name Version
azurerm >=3.72.0, <4.0

Resources

Name Type
azurerm_cdn_endpoint.cdn_endpoint resource
azurerm_cdn_endpoint_custom_domain.cdn_endpoint_custom_domain resource
azurerm_cdn_frontdoor_custom_domain.cdn_frontdoor_custom_domain resource
azurerm_cdn_frontdoor_endpoint.cdn_frontdoor_endpoint resource
azurerm_cdn_frontdoor_firewall_policy.cdn_frontdoor_firewall_policy resource
azurerm_cdn_frontdoor_origin.cdn_frontdoor_origin resource
azurerm_cdn_frontdoor_origin_group.cdn_frontdoor_origin_group resource
azurerm_cdn_frontdoor_profile.cdn_frontdoor_profile resource
azurerm_cdn_frontdoor_route.cdn_frontdoor_route resource
azurerm_cdn_frontdoor_rule.cdn_frontdoor_rule resource
azurerm_cdn_frontdoor_rule_set.cdn_frontdoor_rule_set resource
azurerm_cdn_frontdoor_secret.cdn_frontdoor_secret resource
azurerm_cdn_frontdoor_security_policy.cdn_frontdoor_security_policy resource
azurerm_cdn_profile.cdn_profile resource

Inputs

Name Description Type Default Required
cdn_endpoint resource definition, default settings are defined within locals and merged with var settings any {} no
cdn_endpoint_custom_domain resource definition, default settings are defined within locals and merged with var settings any {} no
cdn_frontdoor_custom_domain Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
cdn_frontdoor_endpoint Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
cdn_frontdoor_firewall_policy Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
cdn_frontdoor_origin Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
cdn_frontdoor_origin_group Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
cdn_frontdoor_profile Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
cdn_frontdoor_route Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
cdn_frontdoor_rule Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
cdn_frontdoor_rule_set Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
cdn_frontdoor_secret Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
cdn_frontdoor_security_policy Resource definition, default settings are defined within locals and merged with var settings. For more information look at Outputs. any {} no
cdn_profile resource definition, default settings are defined within locals and merged with var settings any {} no

Outputs

Name Description
cdn_endpoint Outputs all attributes of resource_type.
cdn_endpoint_custom_domain Outputs all attributes of resource_type.
cdn_frontdoor_custom_domain Outputs all attributes of resource_type.
cdn_frontdoor_endpoint Outputs all attributes of resource_type.
cdn_frontdoor_firewall_policy Outputs all attributes of resource_type.
cdn_frontdoor_origin Outputs all attributes of resource_type.
cdn_frontdoor_origin_group Outputs all attributes of resource_type.
cdn_frontdoor_profile Outputs all attributes of resource_type.
cdn_frontdoor_route Outputs all attributes of resource_type.
cdn_frontdoor_rule Outputs all attributes of resource_type.
cdn_frontdoor_rule_set Outputs all attributes of resource_type.
cdn_frontdoor_secret Outputs all attributes of resource_type.
cdn_frontdoor_security_policy Outputs all attributes of resource_type.
cdn_profile Outputs all attributes of resource_type.
variables Displays all configurable variables passed by the module. default = predefined values per module. merged = result of merging the default values and custom values passed to the module

Examples

Minimal configuration to install the desired resources with the module

module "cdn" {
  source = "registry.terraform.io/telekom-mms/cdn/azurerm"
  cdn_profile = {
    cdnp-mms = {
      location            = "westeurope"
      resource_group_name = "rg-mms-github"
      sku                 = "Standard_Microsoft"
    }
  }
  cdn_endpoint = {
    cdne-mms = {
      resource_group_name = module.cdn.cdn_profile["cdnp-mms"].resource_group_name
      location            = module.cdn.cdn_profile["cdnp-mms"].location
      profile_name        = module.cdn.cdn_profile["cdnp-mms"].name
      origin = {
        telekom-mms = {
          host_name = "origin.telekom-mms.com"
        }
      }
    }
  }
  cdn_endpoint_custom_domain = {
    telekom-mms = {
      cdn_endpoint_id = module.cdn.cdn_endpoint["cdne-mms"].id
      host_name       = "telekom-mms.com"
    }
  }
  cdn_frontdoor_profile = {
    afd-mms = {
      resource_group_name = "rg-mms-github"
    }
  }
  cdn_frontdoor_origin_group = {
    non-backend = {
      cdn_frontdoor_profile_id = module.cdn.cdn_frontdoor_profile["afd-mms"].id
    }
  }
  cdn_frontdoor_origin = {
    non-backend = {
      cdn_frontdoor_origin_group_id = module.cdn.cdn_frontdoor_origin_group["non-backend"].id
      host_name                     = "127.0.0.0"
    }
  }
  cdn_frontdoor_endpoint = {
    "fde-non-backend" = {
      cdn_frontdoor_profile_id = module.cdn.cdn_frontdoor_profile["afd-mms"].id
    }
  }
  cdn_frontdoor_custom_domain = {
    "telekom-mms-com" = {
      cdn_frontdoor_profile_id = module.cdn.cdn_frontdoor_profile["afd-mms"].id
      host_name                = "telekom-mms.com"
    }
  }
  cdn_frontdoor_route = {
    non-backend = {
      cdn_frontdoor_endpoint_id       = module.cdn.cdn_frontdoor_endpoint["fde-non-backend"].id
      cdn_frontdoor_origin_group_id   = module.cdn.cdn_frontdoor_origin_group["non-backend"].id
      cdn_frontdoor_origin_ids        = [module.cdn.cdn_frontdoor_origin["non-backend"].id]
      cdn_frontdoor_custom_domain_ids = [module.cdn.cdn_frontdoor_custom_domain["telekom-mms-com"].id]
    }
  }
  cdn_frontdoor_rule_set = {
    nonbackend = {
      cdn_frontdoor_profile_id = module.cdn.cdn_frontdoor_profile["afd-mms"].id
    }
  }
  cdn_frontdoor_rule = {
    rewrite = {
      cdn_frontdoor_rule_set_id = module.cdn.cdn_frontdoor_rule_set["nonbackend"].id
      order                     = 0
      actions = {
        leadingDomain = {
          destination_hostname = "www.telekom-mms.com"
        }
      }
    }
  }
  cdn_frontdoor_firewall_policy = {
    fdfpmms = {
      resource_group_name = "rg-mms-github"
      sku_name            = module.cdn.cdn_frontdoor_profile["afd-mms"].sku_name
    }
  }
  cdn_frontdoor_security_policy = {
    default = {
      cdn_frontdoor_profile_id = module.cdn.cdn_frontdoor_profile["afd-mms"].id
      security_policies = {
        firewall = {
          cdn_frontdoor_firewall_policy_id = module.cdn.cdn_frontdoor_firewall_policy["fdfpmms"].id
          association = {
            domain = {
              "www-telekom-mms-com" = {
                cdn_frontdoor_domain_id = module.cdn.cdn_frontdoor_custom_domain["telekom-mms-com"].id
              }
            }
          }
        }
      }
    }
  }
}

Advanced configuration to install the desired resources with the module

module "cdn" {
  source = "registry.terraform.io/telekom-mms/cdn/azurerm"
  cdn_profile = {
    cdnp-mms = {
      location            = "westeurope"
      resource_group_name = "rg-mms-github"
      sku                 = "Standard_Microsoft"
      tags = {
        project     = "mms-github"
        environment = terraform.workspace
        managed-by  = "terraform"
      }
    }
  }
  cdn_endpoint = {
    cdne-mms = {
      resource_group_name = module.cdn.cdn_profile["cdnp-mms"].resource_group_name
      location            = module.cdn.cdn_profile["cdnp-mms"].location
      profile_name        = module.cdn.cdn_profile["cdnp-mms"].name
      origin = {
        telekom-mms = {
          host_name = "origin.telekom-mms.com"
        }
      }
      global_delivery_rule = {
        cache_expiration_action = {
          behavior = "Override"
          duration = "00:05:00"
        }
      }
      tags = {
        project     = "mms-github"
        environment = terraform.workspace
        managed-by  = "terraform"
      }
    }
  }
  cdn_endpoint_custom_domain = {
    telekom-mms = {
      cdn_endpoint_id = module.cdn.cdn_endpoint["cdne-mms"].id
      host_name       = "telekom-mms.com"
      cdn_managed_https = {
        certificate_type = "Dedicated"
        protocol_type    = "ServerNameIndication"
      }
    }
  }
  cdn_frontdoor_profile = {
    afd-mms = {
      resource_group_name = "rg-mms-github"
      sku_name            = "Premium_AzureFrontDoor" // Premium because we want also managed WAF rules
      tags = {
        project     = "mms-github"
        environment = terraform.workspace
        managed-by  = "terraform"
      }
    }
  }
  cdn_frontdoor_origin_group = {
    non-backend = {
      cdn_frontdoor_profile_id = module.cdn.cdn_frontdoor_profile["afd-mms"].id
    }
  }
  cdn_frontdoor_origin = {
    non-backend = {
      cdn_frontdoor_origin_group_id  = module.cdn.cdn_frontdoor_origin_group["non-backend"].id
      host_name                      = "0.0.0.0"
      certificate_name_check_enabled = false
    }
  }
  cdn_frontdoor_endpoint = {
    non-backend = {
      name                     = "fde-non-backend"
      cdn_frontdoor_profile_id = module.cdn.cdn_frontdoor_profile["afd-mms"].id
      tags = {
        project     = "mms-github"
        environment = terraform.workspace
        managed-by  = "terraform"
      }
    }
  }
  cdn_frontdoor_custom_domain = {
    "telekom-mms-com" = {
      cdn_frontdoor_profile_id = module.cdn.cdn_frontdoor_profile["afd-mms"].id
      host_name                = "telekom-mms.com"
    }
  }
  cdn_frontdoor_route = {
    non-backend = {
      cdn_frontdoor_endpoint_id       = module.cdn.cdn_frontdoor_endpoint["non-backend"].id
      cdn_frontdoor_origin_group_id   = module.cdn.cdn_frontdoor_origin_group["non-backend"].id
      cdn_frontdoor_origin_ids        = [module.cdn.cdn_frontdoor_origin["non-backend"].id]
      cdn_frontdoor_custom_domain_ids = [module.cdn.cdn_frontdoor_custom_domain["telekom-mms-com"].id]
      cache = {
        query_string_caching_behavior = "IgnoreQueryString"
      }
    }
  }
  cdn_frontdoor_rule_set = {
    nonbackend = {
      cdn_frontdoor_profile_id = module.cdn.cdn_frontdoor_profile["afd-mms"].id
    }
  }
  cdn_frontdoor_rule = {
    rewrite = {
      cdn_frontdoor_rule_set_id = module.cdn.cdn_frontdoor_rule_set["nonbackend"].id
      order                     = 0
      actions = {
        url_redirect_action = {
          leadingDomain = {
            destination_hostname = "www.telekom-mms.com"
          }
        }
        response_header_action = {
          Content-Security-Policy = {
            header_action = "Append"
            header_name   = "Content-Security-Policy"
            value         = "frame-ancestors 'self'"
          }
          X-Content-Type-Options = {
            header_action = "Append"
            header_name   = "X-Content-Type-Options"
            value         = "nosniff"
          }
        }
      }
      conditions = {
        request_header_condition = {
          Host = {
            header_name  = "Host"
            match_values = ["telekom-mms.com"]
            operator     = "Equal"
          }
        }
      }
    }
  }
  cdn_frontdoor_firewall_policy = {
    fdfpmms = {
      resource_group_name = "rg-mms-github"
      sku_name            = module.cdn.cdn_frontdoor_profile["afd-mms"].sku_name
      custom_rule = {
        frontend = {
          priority = 100
          type     = "MatchRule"
          match_condition = {
            ip_access = {
              match_values       = ["127.0.0.2"]
              match_variable     = "SocketAddr"
              operator           = "IPMatch"
              negation_condition = true
            }
          }
        }
      }
      managed_rule = {
        BotManagerRuleSet = {
          type    = "Microsoft_BotManagerRuleSet"
          version = "1.0"
        }
      }
      tags = {
        project     = "mms-github"
        environment = terraform.workspace
        managed-by  = "terraform"
      }
    }
  }
  cdn_frontdoor_security_policy = {
    default = {
      cdn_frontdoor_profile_id = module.cdn.cdn_frontdoor_profile["afd-mms"].id
      security_policies = {
        firewall = {
          cdn_frontdoor_firewall_policy_id = module.cdn.cdn_frontdoor_firewall_policy["fdfpmms"].id
          association = {
            domain = {
              "www-telekom-mms-com" = {
                cdn_frontdoor_domain_id = module.cdn.cdn_frontdoor_custom_domain["telekom-mms-com"].id
              }
            }
          }
        }
      }
    }
  }
}