Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ module "vm_mssql_win" {
location = azurerm_resource_group.this.location
resource_group_name = azurerm_resource_group.this.name
storage_account_id = module.vnet_app[0].resource_ids["storage_account"]
storage_account_name = module.vnet_app[0].resource_names["storage_account"]
storage_blob_endpoint = module.vnet_app[0].storage_endpoints["blob"]
storage_container_id = module.vnet_app[0].resource_ids["storage_container"]
storage_container_name = module.vnet_app[0].storage_container_name
subnet_id = module.vnet_app[0].subnets["snet-db-01"].id
tags = var.tags
Expand Down
2 changes: 1 addition & 1 deletion modules/vm-mssql-win/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ key_vault_name | | The name of the key vault defined in the root module.
location | | The name of the Azure Region where resources will be provisioned.
resource_group_name | | The name of the resource group defined in the root module.
storage_account_id | | The ID of the storage account defined in the vnet-app module.
storage_account_name | | The name of the storage account defined in the vnet-app module.
storage_container_id | | The ID of the storage container defined in the vnet-app module.
storage_container_name | scripts | The name of the storage container defined in the vnet-app module.
storage_blob_endpoint | | The blob endpoint for the storage account defined in the vnet-app module.
subnet_id | | The subnet ID defined in the vnet-app module.
Expand Down
9 changes: 4 additions & 5 deletions modules/vm-mssql-win/storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
resource "azurerm_storage_blob" "remote_scripts" {
for_each = local.remote_scripts

name = each.value.name
storage_account_name = var.storage_account_name
storage_container_name = var.storage_container_name
type = "Block"
source = "./${path.module}/scripts/${each.value.name}"
name = each.value.name
storage_container_id = var.storage_container_id
type = "Block"
source = "./${path.module}/scripts/${each.value.name}"

depends_on = [time_sleep.wait_for_roles]
}
Expand Down
8 changes: 4 additions & 4 deletions modules/vm-mssql-win/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ variable "storage_account_id" {

}

variable "storage_account_name" {
variable "storage_container_id" {
type = string
description = "The name of the shared storage account."
description = "The ID of the storage container where the remote scripts are stored."

validation {
condition = can(regex("^[a-z0-9]{3,24}$", var.storage_account_name))
error_message = "Must conform to Azure storage account naming requirements: it can only contain lowercase letters and numbers, and must be between 3 and 24 characters long."
condition = can(regex("^/subscriptions/[0-9a-fA-F-]+/resourceGroups/[a-zA-Z0-9-_()]+/providers/Microsoft.Storage/storageAccounts/[a-zA-Z0-9]{3,24}/blobServices/default/containers/[a-z0-9]{3,63}$", var.storage_container_id))
error_message = "Must be a valid Azure Resource ID for a storage container. It should follow the format '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{storageAccountName}/blobServices/default/containers/{containerName}'."
}
}

Expand Down
2 changes: 2 additions & 0 deletions modules/vnet-app/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ output "resource_ids" {
application_insights = azurerm_application_insights.this.id
container_registry = azurerm_container_registry.this.id
storage_account = azurerm_storage_account.this.id
storage_container = azurerm_storage_container.this.id
storage_share = azurerm_storage_share.this.id
virtual_machine_jumpwin1 = azurerm_windows_virtual_machine.this.id
virtual_network_app = azurerm_virtual_network.this.id
Expand All @@ -41,6 +42,7 @@ output "resource_names" {
application_insights = azurerm_application_insights.this.name
container_registry = azurerm_container_registry.this.name
storage_account = azurerm_storage_account.this.name
storage_container = azurerm_storage_container.this.name
storage_share = azurerm_storage_share.this.name
virtual_machine_jumpwin1 = azurerm_windows_virtual_machine.this.name
virtual_network_app = azurerm_virtual_network.this.name
Expand Down
9 changes: 4 additions & 5 deletions modules/vnet-app/storage.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ resource "azurerm_storage_container" "this" {
resource "azurerm_storage_blob" "remote_scripts" {
for_each = local.remote_scripts

name = each.value.name
storage_account_name = azurerm_storage_account.this.name
storage_container_name = azurerm_storage_container.this.name
type = "Block"
source = "./${path.module}/scripts/${each.value.name}"
name = each.value.name
storage_container_id = azurerm_storage_container.this.id
type = "Block"
source = "./${path.module}/scripts/${each.value.name}"

depends_on = [time_sleep.wait_for_roles]
}
Expand Down
Loading