Compare commits
9 Commits
UserStory3
...
UserStory2
Author | SHA1 | Date | |
---|---|---|---|
7908433829 | |||
5620b3e327 | |||
8c3f290e61 | |||
3a6dd12ab9 | |||
5192273700 | |||
d2e47ddadd | |||
96d88c3c41 | |||
e405273660 | |||
98f857a865 |
@ -21,7 +21,7 @@ resource "tls_private_key" "signing_cert" {
|
||||
resource "tls_self_signed_cert" "attestation" {
|
||||
count = local.create_signing_cert ? 1 : 0
|
||||
|
||||
private_key_pem = tls_private_key.signing_cert[0].private_key_pem
|
||||
private_key_pem = tls_private_key.signing_cert[0].private_key_pem
|
||||
validity_period_hours = 12
|
||||
allowed_uses = [
|
||||
"cert_signing",
|
||||
@ -40,4 +40,13 @@ resource "azurerm_attestation_provider" "corp_attestation" {
|
||||
name = "${var.attestation_provider_name}${random_string.attestation_suffix.result}"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
policy_signing_certificate_data = try(tls_self_signed_cert.attestation[0].cert_pem, file(var.cert_path))
|
||||
#https://github.com/hashicorp/terraform-provider-azurerm/issues/21998#issuecomment-1573312297
|
||||
lifecycle {
|
||||
ignore_changes = [
|
||||
"open_enclave_policy_base64",
|
||||
"sev_snp_policy_base64",
|
||||
"sgx_enclave_policy_base64",
|
||||
"tpm_policy_base64",
|
||||
]
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>2.0"
|
||||
version = "~>3.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
|
@ -8,7 +8,7 @@ terraform {
|
||||
}
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>2.0"
|
||||
version = "~>3.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
|
21
quickstart/101-batch-pools-with-job/README.md
Normal file
21
quickstart/101-batch-pools-with-job/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Azure Batch
|
||||
|
||||
Deploy an Azure Batch account and two batch pools.
|
||||
|
||||
## Terraform resource types
|
||||
|
||||
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
|
||||
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
|
||||
- [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string)
|
||||
- [azurerm_storage_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account)
|
||||
- [azurerm_batch_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/batch_account)
|
||||
- [azurerm_batch_pool](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/batch_pool)
|
||||
|
||||
## Variables
|
||||
|
||||
| Name | Description | Default |
|
||||
|-|-|-|
|
||||
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
|
||||
| `resource_group_location` | Location of the resource group. | eastus |
|
||||
|
||||
## Example
|
114
quickstart/101-batch-pools-with-job/main.tf
Normal file
114
quickstart/101-batch-pools-with-job/main.tf
Normal file
@ -0,0 +1,114 @@
|
||||
resource "random_pet" "rg_name" {
|
||||
prefix = var.resource_group_name_prefix
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "rg" {
|
||||
location = var.resource_group_location
|
||||
name = random_pet.rg_name.id
|
||||
}
|
||||
|
||||
resource "random_string" "storage_account_name" {
|
||||
length = 8
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_storage_account" "example" {
|
||||
name = random_string.storage_account_name.result
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.rg.location
|
||||
account_tier = "Standard"
|
||||
account_replication_type = "LRS"
|
||||
}
|
||||
|
||||
resource "random_string" "batch_account_name" {
|
||||
length = 8
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_batch_account" "example" {
|
||||
name = random_string.batch_account_name.result
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.rg.location
|
||||
storage_account_id = azurerm_storage_account.example.id
|
||||
storage_account_authentication_mode = "StorageKeys"
|
||||
}
|
||||
|
||||
resource "random_pet" "azurerm_batch_pool_name" {
|
||||
prefix = "pool"
|
||||
}
|
||||
|
||||
resource "azurerm_batch_pool" "fixed" {
|
||||
name = "${random_pet.azurerm_batch_pool_name.id}-fixed-pool"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
account_name = azurerm_batch_account.example.name
|
||||
display_name = "Fixed Scale Pool"
|
||||
vm_size = "Standard_A1"
|
||||
node_agent_sku_id = "batch.node.ubuntu 22.04"
|
||||
|
||||
fixed_scale {
|
||||
target_dedicated_nodes = 2
|
||||
resize_timeout = "PT15M"
|
||||
}
|
||||
|
||||
storage_image_reference {
|
||||
publisher = "Canonical"
|
||||
offer = "0001-com-ubuntu-server-jammy"
|
||||
sku = "22_04-lts"
|
||||
version = "latest"
|
||||
}
|
||||
|
||||
start_task {
|
||||
command_line = "echo 'Hello World from $env'"
|
||||
task_retry_maximum = 1
|
||||
wait_for_success = true
|
||||
|
||||
common_environment_properties = {
|
||||
env = "TEST"
|
||||
}
|
||||
|
||||
user_identity {
|
||||
auto_user {
|
||||
elevation_level = "NonAdmin"
|
||||
scope = "Task"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
metadata = {
|
||||
"tagName" = "Example tag"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_batch_pool" "autopool" {
|
||||
name = "${random_pet.azurerm_batch_pool_name.id}-autoscale-pool"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
account_name = azurerm_batch_account.example.name
|
||||
display_name = "Auto Scale Pool"
|
||||
vm_size = "Standard_A1"
|
||||
node_agent_sku_id = "batch.node.ubuntu 22.04"
|
||||
|
||||
auto_scale {
|
||||
evaluation_interval = "PT15M"
|
||||
|
||||
formula = <<EOF
|
||||
startingNumberOfVMs = 1;
|
||||
maxNumberofVMs = 25;
|
||||
pendingTaskSamplePercent = $PendingTasks.GetSamplePercent(180 * TimeInterval_Second);
|
||||
pendingTaskSamples = pendingTaskSamplePercent < 70 ? startingNumberOfVMs : avg($PendingTasks.GetSample(180 * TimeInterval_Second));
|
||||
$TargetDedicatedNodes=min(maxNumberofVMs, pendingTaskSamples);
|
||||
EOF
|
||||
}
|
||||
|
||||
storage_image_reference {
|
||||
publisher = "Canonical"
|
||||
offer = "0001-com-ubuntu-server-jammy"
|
||||
sku = "22_04-lts"
|
||||
version = "latest"
|
||||
}
|
||||
}
|
19
quickstart/101-batch-pools-with-job/outputs.tf
Normal file
19
quickstart/101-batch-pools-with-job/outputs.tf
Normal file
@ -0,0 +1,19 @@
|
||||
output "resource_group_name" {
|
||||
value = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
output "storage_account_name" {
|
||||
value = azurerm_storage_account.example.name
|
||||
}
|
||||
|
||||
output "batch_account_name" {
|
||||
value = azurerm_batch_account.example.name
|
||||
}
|
||||
|
||||
output "batch_pool_fixed_name" {
|
||||
value = azurerm_batch_pool.fixed.name
|
||||
}
|
||||
|
||||
output "batch_pool_autopool_name" {
|
||||
value = azurerm_batch_pool.autopool.name
|
||||
}
|
11
quickstart/101-batch-pools-with-job/variables.tf
Normal file
11
quickstart/101-batch-pools-with-job/variables.tf
Normal file
@ -0,0 +1,11 @@
|
||||
variable "resource_group_location" {
|
||||
type = string
|
||||
default = "eastus"
|
||||
description = "Location of the resource group."
|
||||
}
|
||||
|
||||
variable "resource_group_name_prefix" {
|
||||
type = string
|
||||
default = "rg"
|
||||
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
|
||||
}
|
21
quickstart/101-batch-pools-with-start-task/README.md
Normal file
21
quickstart/101-batch-pools-with-start-task/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# Azure Batch with start task
|
||||
|
||||
Deploy an Azure Batch account and two batch pools, one of which has a "start task".
|
||||
|
||||
## Terraform resource types
|
||||
|
||||
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
|
||||
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
|
||||
- [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string)
|
||||
- [azurerm_storage_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/storage_account)
|
||||
- [azurerm_batch_account](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/batch_account)
|
||||
- [azurerm_batch_pool](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/batch_pool)
|
||||
|
||||
## Variables
|
||||
|
||||
| Name | Description | Default |
|
||||
|-|-|-|
|
||||
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
|
||||
| `resource_group_location` | Location of the resource group. | eastus |
|
||||
|
||||
## Example
|
114
quickstart/101-batch-pools-with-start-task/main.tf
Normal file
114
quickstart/101-batch-pools-with-start-task/main.tf
Normal file
@ -0,0 +1,114 @@
|
||||
resource "random_pet" "rg_name" {
|
||||
prefix = var.resource_group_name_prefix
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "rg" {
|
||||
location = var.resource_group_location
|
||||
name = random_pet.rg_name.id
|
||||
}
|
||||
|
||||
resource "random_string" "storage_account_name" {
|
||||
length = 8
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_storage_account" "example" {
|
||||
name = random_string.storage_account_name.result
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.rg.location
|
||||
account_tier = "Standard"
|
||||
account_replication_type = "LRS"
|
||||
}
|
||||
|
||||
resource "random_string" "batch_account_name" {
|
||||
length = 8
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_batch_account" "example" {
|
||||
name = random_string.batch_account_name.result
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.rg.location
|
||||
storage_account_id = azurerm_storage_account.example.id
|
||||
storage_account_authentication_mode = "StorageKeys"
|
||||
}
|
||||
|
||||
resource "random_pet" "azurerm_batch_pool_name" {
|
||||
prefix = "pool"
|
||||
}
|
||||
|
||||
resource "azurerm_batch_pool" "fixed" {
|
||||
name = "${random_pet.azurerm_batch_pool_name.id}-fixed-pool"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
account_name = azurerm_batch_account.example.name
|
||||
display_name = "Fixed Scale Pool"
|
||||
vm_size = "Standard_D4_v3"
|
||||
node_agent_sku_id = "batch.node.ubuntu 22.04"
|
||||
|
||||
fixed_scale {
|
||||
target_dedicated_nodes = 2
|
||||
resize_timeout = "PT15M"
|
||||
}
|
||||
|
||||
storage_image_reference {
|
||||
publisher = "Canonical"
|
||||
offer = "0001-com-ubuntu-server-jammy"
|
||||
sku = "22_04-lts"
|
||||
version = "latest"
|
||||
}
|
||||
|
||||
start_task {
|
||||
command_line = "echo 'Hello World from $env'"
|
||||
task_retry_maximum = 1
|
||||
wait_for_success = true
|
||||
|
||||
common_environment_properties = {
|
||||
env = "TEST"
|
||||
}
|
||||
|
||||
user_identity {
|
||||
auto_user {
|
||||
elevation_level = "NonAdmin"
|
||||
scope = "Task"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
metadata = {
|
||||
"tagName" = "Example tag"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_batch_pool" "autopool" {
|
||||
name = "${random_pet.azurerm_batch_pool_name.id}-autoscale-pool"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
account_name = azurerm_batch_account.example.name
|
||||
display_name = "Auto Scale Pool"
|
||||
vm_size = "Standard_D4_v3"
|
||||
node_agent_sku_id = "batch.node.ubuntu 22.04"
|
||||
|
||||
auto_scale {
|
||||
evaluation_interval = "PT15M"
|
||||
|
||||
formula = <<EOF
|
||||
startingNumberOfVMs = 1;
|
||||
maxNumberofVMs = 25;
|
||||
pendingTaskSamplePercent = $PendingTasks.GetSamplePercent(180 * TimeInterval_Second);
|
||||
pendingTaskSamples = pendingTaskSamplePercent < 70 ? startingNumberOfVMs : avg($PendingTasks.GetSample(180 * TimeInterval_Second));
|
||||
$TargetDedicatedNodes=min(maxNumberofVMs, pendingTaskSamples);
|
||||
EOF
|
||||
}
|
||||
|
||||
storage_image_reference {
|
||||
publisher = "Canonical"
|
||||
offer = "0001-com-ubuntu-server-jammy"
|
||||
sku = "22_04-lts"
|
||||
version = "latest"
|
||||
}
|
||||
}
|
19
quickstart/101-batch-pools-with-start-task/outputs.tf
Normal file
19
quickstart/101-batch-pools-with-start-task/outputs.tf
Normal file
@ -0,0 +1,19 @@
|
||||
output "resource_group_name" {
|
||||
value = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
output "storage_account_name" {
|
||||
value = azurerm_storage_account.example.name
|
||||
}
|
||||
|
||||
output "batch_account_name" {
|
||||
value = azurerm_batch_account.example.name
|
||||
}
|
||||
|
||||
output "batch_pool_fixed_name" {
|
||||
value = azurerm_batch_pool.fixed.name
|
||||
}
|
||||
|
||||
output "batch_pool_autopool_name" {
|
||||
value = azurerm_batch_pool.autopool.name
|
||||
}
|
18
quickstart/101-batch-pools-with-start-task/providers.tf
Normal file
18
quickstart/101-batch-pools-with-start-task/providers.tf
Normal file
@ -0,0 +1,18 @@
|
||||
terraform {
|
||||
required_version = ">=1.0"
|
||||
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>3.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
version = "~>3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {}
|
||||
}
|
11
quickstart/101-batch-pools-with-start-task/variables.tf
Normal file
11
quickstart/101-batch-pools-with-start-task/variables.tf
Normal file
@ -0,0 +1,11 @@
|
||||
variable "resource_group_location" {
|
||||
type = string
|
||||
default = "eastus"
|
||||
description = "Location of the resource group."
|
||||
}
|
||||
|
||||
variable "resource_group_name_prefix" {
|
||||
type = string
|
||||
default = "rg"
|
||||
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
|
||||
}
|
@ -3,7 +3,7 @@ terraform {
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>2.0"
|
||||
version = "~>3.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
|
@ -1,42 +0,0 @@
|
||||
# Azure CDN Frontdoor
|
||||
This template deploys an Azure CDN Frontdoor with a Frontdoor managed TLS/SSL certificate Custom Domain.
|
||||
|
||||
## Terraform resource types
|
||||
|
||||
- [random_pet](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/pet)
|
||||
- [azurerm_resource_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group)
|
||||
- [azurerm_cdn_frontdoor_profile](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_profile)
|
||||
- [random_string](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string)
|
||||
- [azurerm_dns_zone](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/dns_zone)
|
||||
- [azurerm_cdn_frontdoor_firewall_policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_firewall_policy)
|
||||
- [azurerm_cdn_frontdoor_security_policy](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_security_policy)
|
||||
- [azurerm_cdn_frontdoor_endpoint](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_endpoint)
|
||||
- [azurerm_cdn_frontdoor_origin_group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_origin_group)
|
||||
- [azurerm_cdn_frontdoor_origin](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_origin)
|
||||
- [azurerm_cdn_frontdoor_rule_set](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_rule_set)
|
||||
- [azurerm_cdn_frontdoor_rule](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_rule)
|
||||
- [azurerm_cdn_frontdoor_route](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_route)
|
||||
- [azurerm_cdn_frontdoor_custom_domain](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_custom_domain)
|
||||
- [azurerm_cdn_frontdoor_custom_domain_association](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/cdn_frontdoor_custom_domain_association)
|
||||
- [azurerm_dns_txt_record](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/dns_txt_record)
|
||||
- [azurerm_dns_cname_record](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/dns_cname_record)
|
||||
|
||||
## Variables
|
||||
|
||||
| Name | Description | Default value |
|
||||
|-|-|-|
|
||||
| `resource_group_name_prefix` | Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription. | rg |
|
||||
| `resource_group_location` | Location of the resource group. | eastus |
|
||||
| `cdn_frontdoor_profile_name` | Name of the CDN Frontdoor profile resource. | "" |
|
||||
| `dns_zone_name` | Name of the DNS zone resource. | "" |
|
||||
| `cdn_frontdoor_firewall_policy_name` | Name of the CDN Frontdoor firewall policy resource. | "" |
|
||||
| `cdn_frontdoor_security_policy_name` | Name of the CDN Frontdoor security policy resource. | "" |
|
||||
| `cdn_frontdoor_endpoint_name` | Name of the CDN Frontdoor endpoint resource. | "" |
|
||||
| `cdn_frontdoor_origin_group_name` | Name of the CDN Frontdoor origin group resource. | "" |
|
||||
| `cdn_frontdoor_origin_name` | Name of the CDN Frontdoor origin resource. | "" |
|
||||
| `cdn_frontdoor_rule_set_name` | Name of the CDN Frontdoor rule set resource. | "" |
|
||||
| `cdn_frontdoor_rule_name` | Name of the CDN Frontdoor rule resource. | "" |
|
||||
| `cdn_frontdoor_route_name` | Name of the CDN Frontdoor route resource. | "" |
|
||||
| `cdn_frontdoor_custom_domain_name` | Name of the CDN Frontdoor custom domain resource. | "" |
|
||||
|
||||
## Example
|
@ -1,394 +0,0 @@
|
||||
resource "random_pet" "rg_name" {
|
||||
prefix = var.resource_group_name_prefix
|
||||
}
|
||||
|
||||
resource "azurerm_resource_group" "rg" {
|
||||
location = var.resource_group_location
|
||||
name = random_pet.rg_name.id
|
||||
}
|
||||
|
||||
resource "random_string" "azurerm_cdn_frontdoor_profile_name" {
|
||||
length = 13
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_cdn_frontdoor_profile" "example" {
|
||||
name = coalesce(var.cdn_frontdoor_profile_name, "profile-${random_string.azurerm_cdn_frontdoor_profile_name.result}")
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
sku_name = "Premium_AzureFrontDoor"
|
||||
|
||||
response_timeout_seconds = 120
|
||||
|
||||
tags = {
|
||||
environment = "example"
|
||||
}
|
||||
}
|
||||
|
||||
resource "random_string" "azurerm_dns_zone_name" {
|
||||
length = 13
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_dns_zone" "example" {
|
||||
name = coalesce(var.dns_zone_name, "zone-${random_string.azurerm_dns_zone_name.result}")
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
resource "random_string" "azurerm_cdn_frontdoor_firewall_policy_name" {
|
||||
length = 13
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_cdn_frontdoor_firewall_policy" "example" {
|
||||
name = coalesce(var.cdn_frontdoor_firewall_policy_name, "firewall-${random_string.azurerm_cdn_frontdoor_firewall_policy_name.result}")
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
sku_name = azurerm_cdn_frontdoor_profile.example.sku_name
|
||||
enabled = true
|
||||
mode = "Prevention"
|
||||
redirect_url = "https://www.example.com"
|
||||
custom_block_response_status_code = 403
|
||||
custom_block_response_body = "PGh0bWw+CjxoZWFkZXI+PHRpdGxlPkhlbGxvPC90aXRsZT48L2hlYWRlcj4KPGJvZHk+CkhlbGxvIHdvcmxkCjwvYm9keT4KPC9odG1sPg=="
|
||||
|
||||
custom_rule {
|
||||
name = "Rule1"
|
||||
enabled = true
|
||||
priority = 1
|
||||
rate_limit_duration_in_minutes = 1
|
||||
rate_limit_threshold = 10
|
||||
type = "MatchRule"
|
||||
action = "Block"
|
||||
|
||||
match_condition {
|
||||
match_variable = "RemoteAddr"
|
||||
operator = "IPMatch"
|
||||
negation_condition = false
|
||||
match_values = ["10.0.2.0/24", "10.0.1.0/24"]
|
||||
}
|
||||
}
|
||||
|
||||
managed_rule {
|
||||
type = "DefaultRuleSet"
|
||||
version = "preview-0.1"
|
||||
action = "Block"
|
||||
|
||||
override {
|
||||
rule_group_name = "PHP"
|
||||
|
||||
rule {
|
||||
rule_id = "933111"
|
||||
enabled = false
|
||||
action = "Block"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
managed_rule {
|
||||
type = "BotProtection"
|
||||
version = "preview-0.1"
|
||||
action = "Block"
|
||||
}
|
||||
}
|
||||
|
||||
resource "random_string" "azurerm_cdn_frontdoor_security_policy_name" {
|
||||
length = 13
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_cdn_frontdoor_security_policy" "example" {
|
||||
name = coalesce(var.cdn_frontdoor_security_policy_name, "security-${random_string.azurerm_cdn_frontdoor_security_policy_name.result}")
|
||||
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
|
||||
|
||||
security_policies {
|
||||
firewall {
|
||||
cdn_frontdoor_firewall_policy_id = azurerm_cdn_frontdoor_firewall_policy.example.id
|
||||
|
||||
association {
|
||||
domain {
|
||||
cdn_frontdoor_domain_id = azurerm_cdn_frontdoor_custom_domain.contoso.id
|
||||
}
|
||||
|
||||
domain {
|
||||
cdn_frontdoor_domain_id = azurerm_cdn_frontdoor_custom_domain.fabrikam.id
|
||||
}
|
||||
|
||||
patterns_to_match = ["/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "random_string" "azurerm_cdn_frontdoor_endpoint_name" {
|
||||
length = 13
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_cdn_frontdoor_endpoint" "example" {
|
||||
name = coalesce(var.cdn_frontdoor_endpoint_name, "endpoint-${random_string.azurerm_cdn_frontdoor_endpoint_name.result}")
|
||||
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
|
||||
enabled = true
|
||||
}
|
||||
|
||||
resource "random_string" "azurerm_cdn_frontdoor_origin_group_name" {
|
||||
length = 13
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_cdn_frontdoor_origin_group" "example" {
|
||||
name = coalesce(var.cdn_frontdoor_origin_group_name, "origin-group-${random_string.azurerm_cdn_frontdoor_origin_group_name.result}")
|
||||
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
|
||||
session_affinity_enabled = true
|
||||
|
||||
restore_traffic_time_to_healed_or_new_endpoint_in_minutes = 10
|
||||
|
||||
health_probe {
|
||||
interval_in_seconds = 100
|
||||
path = "/"
|
||||
protocol = "Http"
|
||||
request_type = "HEAD"
|
||||
}
|
||||
|
||||
load_balancing {
|
||||
additional_latency_in_milliseconds = 0
|
||||
sample_size = 16
|
||||
successful_samples_required = 3
|
||||
}
|
||||
}
|
||||
|
||||
resource "random_string" "azurerm_cdn_frontdoor_origin_name" {
|
||||
length = 13
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_cdn_frontdoor_origin" "example" {
|
||||
name = coalesce(var.cdn_frontdoor_origin_name, "origin-${random_string.azurerm_cdn_frontdoor_origin_name.result}")
|
||||
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.example.id
|
||||
enabled = true
|
||||
|
||||
certificate_name_check_enabled = false
|
||||
host_name = join(".", ["contoso", azurerm_dns_zone.example.name])
|
||||
priority = 1
|
||||
weight = 1
|
||||
}
|
||||
|
||||
resource "random_string" "azurerm_cdn_frontdoor_rule_set_name" {
|
||||
length = 13
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_cdn_frontdoor_rule_set" "example" {
|
||||
name = coalesce(var.cdn_frontdoor_rule_set_name, "rule-set-${random_string.azurerm_cdn_frontdoor_rule_set_name.result}")
|
||||
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
|
||||
}
|
||||
|
||||
resource "random_string" "azurerm_cdn_frontdoor_rule_name" {
|
||||
length = 13
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_cdn_frontdoor_rule" "example" {
|
||||
depends_on = [azurerm_cdn_frontdoor_origin_group.example, azurerm_cdn_frontdoor_origin.example]
|
||||
|
||||
name = coalesce(var.cdn_frontdoor_rule_name, "rule-${random_string.azurerm_cdn_frontdoor_rule_name.result}")
|
||||
cdn_frontdoor_rule_set_id = azurerm_cdn_frontdoor_rule_set.example.id
|
||||
order = 1
|
||||
behavior_on_match = "Continue"
|
||||
|
||||
actions {
|
||||
route_configuration_override_action {
|
||||
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.example.id
|
||||
forwarding_protocol = "HttpsOnly"
|
||||
query_string_caching_behavior = "IncludeSpecifiedQueryStrings"
|
||||
query_string_parameters = ["foo", "clientIp={client_ip}"]
|
||||
compression_enabled = true
|
||||
cache_behavior = "OverrideIfOriginMissing"
|
||||
cache_duration = "365.23:59:59"
|
||||
}
|
||||
|
||||
url_redirect_action {
|
||||
redirect_type = "PermanentRedirect"
|
||||
redirect_protocol = "MatchRequest"
|
||||
query_string = "clientIp={client_ip}"
|
||||
destination_path = "/exampleredirection"
|
||||
destination_hostname = "example.com"
|
||||
destination_fragment = "UrlRedirect"
|
||||
}
|
||||
}
|
||||
|
||||
conditions {
|
||||
host_name_condition {
|
||||
operator = "Equal"
|
||||
negate_condition = false
|
||||
match_values = ["www.example.com", "images.example.com", "video.example.com"]
|
||||
transforms = ["Lowercase", "Trim"]
|
||||
}
|
||||
|
||||
is_device_condition {
|
||||
operator = "Equal"
|
||||
negate_condition = false
|
||||
match_values = ["Mobile"]
|
||||
}
|
||||
|
||||
post_args_condition {
|
||||
post_args_name = "customerName"
|
||||
operator = "BeginsWith"
|
||||
match_values = ["J", "K"]
|
||||
transforms = ["Uppercase"]
|
||||
}
|
||||
|
||||
request_method_condition {
|
||||
operator = "Equal"
|
||||
negate_condition = false
|
||||
match_values = ["DELETE"]
|
||||
}
|
||||
|
||||
url_filename_condition {
|
||||
operator = "Equal"
|
||||
negate_condition = false
|
||||
match_values = ["media.mp4"]
|
||||
transforms = ["Lowercase", "RemoveNulls", "Trim"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "random_string" "azurerm_cdn_frontdoor_route_name" {
|
||||
length = 13
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_cdn_frontdoor_route" "example" {
|
||||
name = coalesce(var.cdn_frontdoor_route_name, "route-${random_string.azurerm_cdn_frontdoor_route_name.result}")
|
||||
cdn_frontdoor_endpoint_id = azurerm_cdn_frontdoor_endpoint.example.id
|
||||
cdn_frontdoor_origin_group_id = azurerm_cdn_frontdoor_origin_group.example.id
|
||||
cdn_frontdoor_origin_ids = [azurerm_cdn_frontdoor_origin.example.id]
|
||||
enabled = true
|
||||
|
||||
forwarding_protocol = "MatchRequest"
|
||||
https_redirect_enabled = true
|
||||
patterns_to_match = ["/*"]
|
||||
supported_protocols = ["Http", "Https"]
|
||||
cdn_frontdoor_rule_set_ids = [azurerm_cdn_frontdoor_rule_set.example.id]
|
||||
|
||||
cdn_frontdoor_custom_domain_ids = [azurerm_cdn_frontdoor_custom_domain.contoso.id, azurerm_cdn_frontdoor_custom_domain.fabrikam.id]
|
||||
link_to_default_domain = false
|
||||
|
||||
cache {
|
||||
compression_enabled = true
|
||||
content_types_to_compress = ["text/html", "text/javascript", "text/xml"]
|
||||
query_strings = ["account", "settings"]
|
||||
query_string_caching_behavior = "IgnoreSpecifiedQueryStrings"
|
||||
}
|
||||
}
|
||||
|
||||
resource "random_string" "azurerm_cdn_frontdoor_custom_domain_name" {
|
||||
length = 13
|
||||
lower = true
|
||||
numeric = false
|
||||
special = false
|
||||
upper = false
|
||||
}
|
||||
|
||||
resource "azurerm_cdn_frontdoor_custom_domain" "contoso" {
|
||||
name = coalesce(var.cdn_frontdoor_custom_domain_name, "custom-domain-${random_string.azurerm_cdn_frontdoor_custom_domain_name.result}")
|
||||
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
|
||||
dns_zone_id = azurerm_dns_zone.example.id
|
||||
host_name = join(".", ["contoso", azurerm_dns_zone.example.name])
|
||||
|
||||
tls {
|
||||
certificate_type = "ManagedCertificate"
|
||||
minimum_tls_version = "TLS12"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_cdn_frontdoor_custom_domain" "fabrikam" {
|
||||
name = coalesce(var.cdn_frontdoor_custom_domain_name, "custom-domain-${random_string.azurerm_cdn_frontdoor_custom_domain_name.result}")
|
||||
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.example.id
|
||||
dns_zone_id = azurerm_dns_zone.example.id
|
||||
host_name = join(".", ["fabrikam", azurerm_dns_zone.example.name])
|
||||
|
||||
tls {
|
||||
certificate_type = "ManagedCertificate"
|
||||
minimum_tls_version = "TLS12"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_cdn_frontdoor_custom_domain_association" "contoso" {
|
||||
cdn_frontdoor_custom_domain_id = azurerm_cdn_frontdoor_custom_domain.contoso.id
|
||||
cdn_frontdoor_route_ids = [azurerm_cdn_frontdoor_route.example.id]
|
||||
}
|
||||
|
||||
resource "azurerm_cdn_frontdoor_custom_domain_association" "fabrikam" {
|
||||
cdn_frontdoor_custom_domain_id = azurerm_cdn_frontdoor_custom_domain.fabrikam.id
|
||||
cdn_frontdoor_route_ids = [azurerm_cdn_frontdoor_route.example.id]
|
||||
}
|
||||
|
||||
resource "azurerm_dns_txt_record" "contoso" {
|
||||
name = join(".", ["_dnsauth", "contoso"])
|
||||
zone_name = azurerm_dns_zone.example.name
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
ttl = 3600
|
||||
|
||||
record {
|
||||
value = azurerm_cdn_frontdoor_custom_domain.contoso.validation_token
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_dns_txt_record" "fabrikam" {
|
||||
name = join(".", ["_dnsauth", "fabrikam"])
|
||||
zone_name = azurerm_dns_zone.example.name
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
ttl = 3600
|
||||
|
||||
record {
|
||||
value = azurerm_cdn_frontdoor_custom_domain.fabrikam.validation_token
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_dns_cname_record" "contoso" {
|
||||
depends_on = [azurerm_cdn_frontdoor_route.example, azurerm_cdn_frontdoor_security_policy.example]
|
||||
|
||||
name = "contoso"
|
||||
zone_name = azurerm_dns_zone.example.name
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
ttl = 3600
|
||||
record = azurerm_cdn_frontdoor_endpoint.example.host_name
|
||||
}
|
||||
|
||||
resource "azurerm_dns_cname_record" "fabrikam" {
|
||||
depends_on = [azurerm_cdn_frontdoor_route.example, azurerm_cdn_frontdoor_security_policy.example]
|
||||
|
||||
name = "fabrikam"
|
||||
zone_name = azurerm_dns_zone.example.name
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
ttl = 3600
|
||||
record = azurerm_cdn_frontdoor_endpoint.example.host_name
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
output "resource_group_name" {
|
||||
value = azurerm_resource_group.rg.name
|
||||
}
|
||||
|
||||
output "cdn_frontdoor_profile_name" {
|
||||
value = azurerm_cdn_frontdoor_profile.example.name
|
||||
}
|
||||
|
||||
output "dns_zone_name" {
|
||||
value = azurerm_dns_zone.example.name
|
||||
}
|
||||
|
||||
output "cdn_frontdoor_firewall_policy_name" {
|
||||
value = azurerm_cdn_frontdoor_firewall_policy.example.name
|
||||
}
|
||||
|
||||
output "cdn_frontdoor_security_policy_name" {
|
||||
value = azurerm_cdn_frontdoor_security_policy.example.name
|
||||
}
|
||||
|
||||
output "cdn_frontdoor_endpoint_name" {
|
||||
value = azurerm_cdn_frontdoor_endpoint.example.name
|
||||
}
|
||||
|
||||
output "cdn_frontdoor_origin_group_name" {
|
||||
value = azurerm_cdn_frontdoor_origin_group.example.name
|
||||
}
|
||||
|
||||
output "cdn_frontdoor_origin_name" {
|
||||
value = azurerm_cdn_frontdoor_origin.example.name
|
||||
}
|
||||
|
||||
output "cdn_frontdoor_rule_set_name" {
|
||||
value = azurerm_cdn_frontdoor_rule_set.example.name
|
||||
}
|
||||
|
||||
output "cdn_frontdoor_rule_name" {
|
||||
value = azurerm_cdn_frontdoor_rule.example.name
|
||||
}
|
||||
|
||||
output "cdn_frontdoor_route_name" {
|
||||
value = azurerm_cdn_frontdoor_route.example.name
|
||||
}
|
||||
|
||||
output "cdn_frontdoor_custom_domain_name" {
|
||||
value = azurerm_cdn_frontdoor_custom_domain.contoso.name
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
variable "resource_group_name_prefix" {
|
||||
type = string
|
||||
default = "rg"
|
||||
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
|
||||
}
|
||||
|
||||
variable "resource_group_location" {
|
||||
type = string
|
||||
default = "eastus"
|
||||
description = "Location of the resource group."
|
||||
}
|
||||
|
||||
variable "cdn_frontdoor_profile_name" {
|
||||
type = string
|
||||
description = "The name of the CDN Frontdoor profile resource. The value will be randomly generated if blank."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "dns_zone_name" {
|
||||
type = string
|
||||
description = "The name of the DNS zone resource. The value will be randomly generated if blank."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cdn_frontdoor_firewall_policy_name" {
|
||||
type = string
|
||||
description = "The name of the CDN Frontdoor firewall policy resource. The value will be randomly generated if blank."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cdn_frontdoor_security_policy_name" {
|
||||
type = string
|
||||
description = "The name of the CDN Frontdoor security policy resource. The value will be randomly generated if blank."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cdn_frontdoor_endpoint_name" {
|
||||
type = string
|
||||
description = "The name of the CDN Frontdoor endpoint resource. The value will be randomly generated if blank."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cdn_frontdoor_origin_group_name" {
|
||||
type = string
|
||||
description = "The name of the CDN Frontdoor origin group resource. The value will be randomly generated if blank."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cdn_frontdoor_origin_name" {
|
||||
type = string
|
||||
description = "The name of the CDN Frontdoor origin resource. The value will be randomly generated if blank."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cdn_frontdoor_rule_set_name" {
|
||||
type = string
|
||||
description = "The name of the CDN Frontdoor rule set resource. The value will be randomly generated if blank."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cdn_frontdoor_rule_name" {
|
||||
type = string
|
||||
description = "The name of the CDN Frontdoor rule resource. The value will be randomly generated if blank."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cdn_frontdoor_route_name" {
|
||||
type = string
|
||||
description = "The name of the CDN Frontdoor route resource. The value will be randomly generated if blank."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "cdn_frontdoor_custom_domain_name" {
|
||||
type = string
|
||||
description = "The name of the CDN Frontdoor custom domain resource. The value will be randomly generated if blank."
|
||||
default = ""
|
||||
}
|
@ -8,7 +8,7 @@ terraform {
|
||||
}
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>2.0"
|
||||
version = "~>3.0"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
|
Reference in New Issue
Block a user