title: Terraform Error: Invalid value for module argument when running tf plan for cloudfront module
body: <p>I have a module which creates submodules and each submodule have a custom_error_response that land to a different response_page_path.</p>
  <p>In the main module I have added;</p>
  <pre><code> custom_error_response = [
      {
        error_code            = &quot;403&quot;
        error_caching_min_ttl = &quot;30&quot;
        response_code         = &quot;200&quot;
        response_page_path    = &quot;/${var.default_root_object}&quot;
      },
    ]
  </code></pre>
  <p>and the variable default_root_object is:</p>
  <pre><code>variable &quot;default_root_object&quot; {
    description = &quot;Default root object at origin for CloudFront distribution&quot;
  }
  </code></pre>
  <p>In the submodules I have added the following in the variables.tf:</p>
  <pre><code>variable &quot;custom_error_response&quot; {
    description = &quot;(Optional) - List of one or more custom error response element maps&quot;
    type        = &quot;list&quot;
    default     = []
  }
  </code></pre>
  <p>In the main.tf of each sub-module I have also defined the custom_error_response like this:</p>
  <pre><code>    dynamic &quot;custom_error_response&quot; {
      for_each = var.custom_error_response
      content {
        error_caching_min_ttl = lookup(custom_error_response.value, &quot;error_caching_min_ttl&quot;, null)
        error_code            = custom_error_response.value.error_code
        response_code         = lookup(custom_error_response.value, &quot;response_code&quot;, null)
        response_page_path    = lookup(custom_error_response.value, &quot;response_page_path&quot;, null)
      }
    } 
  </code></pre>
  <p>When I am running terraform init it is okay, but when I run terraform plan it gives me the same error 8 times for the 8 sub modules I have made.</p>
  <pre><code>Error: Invalid value for module argument
  
    on portal_distribution/main.tf line 32, in module &quot;**mainmodule**&quot;:
    32:   custom_error_response = [
    33:     {
    34:       error_code            = &quot;403&quot;
    35:       error_caching_min_ttl = &quot;30&quot;
    36:       response_code         = &quot;200&quot;
    37:       response_page_path    = &quot;/${var.default_root_object}&quot;
    38:     },
    39:   ]
  
  The given value is not suitable for child module variable
  &quot;custom_error_response&quot; defined at
  .terraform/modules/**submodule**_portal.**mainmodule**/modules/aws-terraform-cloudfront_s3_origin/variables.tf:302,1-33:
  element 0: string required.
  </code></pre>
  <p>How do I fix the error?</p>