title: Terraform - Copy multiple Files to bucket at the same time bucket creation
body: <p>Hello,</p>
  <p>I have a little head hache.</p>
  <p>I want to create buckets and cp bulk files at the same time. I have multiple folder (datasetname) in schema folder with json file: schema/dataset1 schema/dataset2 schema/dataset3</p>
  <p>The trick is Terraform generate bucketname + random numbers to avoid already name used. I have one question:</p>
  <p>How to copy bulk files in a bucket (at the same time bucket creation)</p>
  <pre><code>
  resource &quot;google_storage_bucket&quot; &quot;map&quot; {
    for_each                    = {for i, v in var.gcs_buckets: i =&gt; v} 
    name                        = &quot;${each.value.id}_${random_id.suffix[0].hex}&quot;
    location                    = var.default_region
    storage_class               = &quot;REGIONAL&quot;
    uniform_bucket_level_access = true 
  
    #If you destroy your bucket, this option will delete all objects inside this bucket 
    #if not Terrafom will fail that run
    force_destroy               = true 
    labels = {
      env = var.env_label
    }
  
  
  resource &quot;google_storage_bucket_object&quot; &quot;map&quot; {
    for_each  = {for i, v in var.json_buckets: i =&gt; v} 
    name      =  &quot;&quot;
    source    = &quot;schema/${each.value.dataset_name}/*&quot;
    bucket = contains([each.value.bucket_name], each.value.dataset_name) 
    #bucket = &quot;${google_storage_bucket.map[contains([each.value.bucket_name], each.value.dataset_name)]}&quot;     
  }
  
  
  variable &quot;json_buckets&quot; {
    type = list(object({
      bucket_name    = string
      dataset_name   = string
    }))
    default = [
        {
      bucket_name      = &quot;schema_table1&quot;,
      dataset_name     = &quot;dataset1&quot;,
      },
        {
      bucket_name      = &quot;schema_table2&quot;,
      dataset_name     = &quot;dataset2&quot;,
      },
      {
      bucket_name      = &quot;schema_table2&quot;,
      dataset_name     = &quot;dataset3&quot;,
      },
      ]
  }
  
  
  variable &quot;gcs_buckets&quot; {
    type = list(object({
      id       = string
      description = string
    }))
    default = [
        {
      id       = &quot;schema_table1&quot;,
      description = &quot;schema_table1&quot;,
      },
      ]
  }
  ...
  </code></pre>