# Dynamics with child blocks

**URL:** <https://discuss.hashicorp.com/t/dynamics-with-child-blocks/6184>\
**Category:** Terraform\
**Created:** [February 21, 2020, 3:20pm UTC](https://discuss.hashicorp.com/t/dynamics-with-child-blocks/6184 "2020-02-21T15:20:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohrerb](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/rohrerb/32/1761_2.png) [@rohrerb](https://discuss.hashicorp.com/u/rohrerb)\
**Post date:** [February 21, 2020, 3:20pm UTC](https://discuss.hashicorp.com/t/dynamics-with-child-blocks/6184/1 "2020-02-21T15:20:02Z")

</div>

We have been waiting for the following change \> [https://github.com/terraform-providers/terraform-provider-azurerm/pull/5440](https://github.com/terraform-providers/terraform-provider-azurerm/pull/5440)

Now that it is here I am a bit confused on how to implement a dynamic in a child block.

We have a list of ips we would like to add using a dynamic blocks. Terraform itself doesn’t give us a error but the plan shows no changes what so ever.

```auto
resource "azurerm_function_app" "app" {
  for_each = { for o in local.functions : o.group_key => o }

  name = format("%s%s%s", upper(var.full_env_code), "-", each.value.group_key)
  location = data.azurerm_resource_group.rg.location
  resource_group_name = data.azurerm_resource_group.rg.name
  app_service_plan_id = azurerm_app_service_plan.service_plan[each.value.key].id
  storage_connection_string = module.storage.primary_connection_string
  version = "~2"

  site_config {
     dynamic "ip_restriction" {
        for_each = var.ip_restrictions

        content {
          ip_address = ip_restriction.key
        }
      } 
  }

}

```

If i swap out

```auto
  site_config {
     dynamic "ip_restriction" {
        for_each = var.ip_restrictions

        content {
          ip_address = ip_restriction.key
        }
      } 
  }

```

and hardcode a ip

```auto
  site_config {
     ip_restriction {
         ip_address = "10.0.0.1
      } 
  }

```

We are able to see the change in a plan

```auto
site_config {
            always_on = false
            ftps_state = "AllAllowed"
            http2_enabled = false
          ~ ip_restriction = [
              + {
                  + ip_address = "10.0.0.1"
                  + subnet_id = null
                },
            ]

```

How can we use a dynamic on a child block?

---

<div class="post-metadata">

**Author:** ![apparentlymart](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/apparentlymart/32/702_2.png) [@apparentlymart](https://discuss.hashicorp.com/u/apparentlymart)\
**Post date:** [February 21, 2020, 10:59pm UTC](https://discuss.hashicorp.com/t/dynamics-with-child-blocks/6184/2 "2020-02-21T22:59:23Z")

</div>

Hi @rohrerb!

Can you show the declaration and definition of `var.ip_restrictions`? The behavior you are seeing suggests that Terraform is seeing it as an empty collection for some reason.

---

<div class="post-metadata">

**Author:** ![rohrerb](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/rohrerb/32/1761_2.png) [@rohrerb](https://discuss.hashicorp.com/u/rohrerb)\
**Post date:** [February 22, 2020, 12:02am UTC](https://discuss.hashicorp.com/t/dynamics-with-child-blocks/6184/3 "2020-02-22T00:02:53Z")

</div>

The list wasn’t empty but i did pass it into the module in the wrong location. Thus this is a non issue. 😃

Sorry for the churn.
