/u/philthynz

Terraform – Reference for_each from a module output

I am trying to use Terraform to create multiple storage containers, and then upload multiple blobs to each container.

I have the part of creating multiple containers working, but can’t figure out how to reference the for_each output of each container when uploading the blobs.

Storage Container Module (Works)

resource "azurerm_storage_container" "azure" { for_each = toset(var.storage_containers) name = each.value storage_account_name = var.storage_account_name container_access_type = var.storage_account_container_access_type } output "azurerm_storage_container_name" { value = toset(keys(azurerm_storage_container.azure)) } 

Child Module (Works)

module "storage_container" { source = "C:/TerraformModules/modules/azurerm/azurerm_storage_container" storage_account_name = module.storage_account.azurerm_storage_account_name storage_containers = var.STORAGE_CONTAINER_NAMES tags = var.TAGS } 

Code to upload blob (doesn’t work for trying to upload into each container)

variable "STORAGE_CONTAINER_DEFAULT_BLOBS" { description = "The default blobs in each storage container" type = list(string) } STORAGE_CONTAINER_DEFAULT_BLOBS = ["one", "two", "three"] resource "azurerm_storage_blob" "storage_blob" { for_each = toset(var.STORAGE_CONTAINER_DEFAULT_BLOBS) name = each.value storage_account_name = module.storage_account.azurerm_storage_account_name storage_container_name = module.storage_container[each.value].azurerm_storage_container_name type = "Block" source_content = "blob file" } 

If I were to set the container name in `storage_container_name`, it works and the container gets each blob. But I’m not able to reference the container from the module.

I have this error:

Error: Invalid index on storage_blobs.tf line 5, in resource "azurerm_storage_blob" "storage_blob": 5: storage_container_name = module.storage_container[each.value].azurerm_storage_container_name |---------------- | each.value is "two" | module.storage_container is object with 1 attribute "azurerm_storage_container_name" The given key does not identify an element in this collection value. 

submitted by /u/philthynz
[link] [comments]

Azure application gateway end to end encryption – Is a cert needed on the servers web server?

If I wanted to use end to end encryption in application gateway, would the backend servers web server, such as nginx require the same certificate too?

I currently have application gateway using the backend http port on the backend web server, so no cert is required, but it also means it’s not end to end encryption.

Is there a way application gateway can manage the certificate for the backend encryption too? Without having to upload certs to nginx on the backend server?

submitted by /u/philthynz
[link] [comments]