Can you inherit a template_cloudinit_config in another template_cloudinit_config object in Terraform?
The cloudinit provider only knows how to encode multipart MIME documents to pass to cloud init; there is no mechanism for parsing to modify and then re-encode.
However, a different way to frame your problem is of constructing a sequence of part objects in a local value and then passing them all together to the cloudinit_config data source, like this:
locals {
  core_config = tolist([
    {
      content_type = &quot;text/x-shellscript&quot;
      content      = file(&quot;${path.module}/scripts/core_script1.sh&quot;)
    },
    {
      content_type = &quot;text/x-shellscript&quot;
      content      = file(&quot;${path.module}/scripts/core_script2.sh&quot;)
    },
  ])
  custom_config = tolist([
    {
      content_type = &quot;text/x-shellscript&quot;
      content      = file(&quot;${path.module}/scripts/custom_script.sh&quot;)
    },
  ])
}

data &quot;cloudinit_config&quot; &quot;core&quot; {
  dynamic &quot;part&quot; {
    for_each = local.core_config
    content {
      content_type = part.value.content_type
      content      = part.value.content
    }
  }
}

data &quot;cloudinit_config&quot; &quot;custom&quot; {
  dynamic &quot;part&quot; {
    for_each = concat(
      local.core_config,
      local.custom_config,
    )
    content {
      content_type = part.value.content_type
      content      = part.value.content
    }
  }
}

resource &quot;aws_instance&quot; &quot;vm1&quot; {
  instance_type = &quot;t2.small&quot;
  ami           = data.aws_ami.ubuntu_ami.image_id
  
  # ...

  user_data = data.cloudinit_config.core.rendered
}

resource &quot;aws_instance&quot; &quot;vm2&quot; {
  instance_type = &quot;t2.small&quot;
  ami           = data.aws_ami.ubuntu_ami.image_id
  
  # ...

  user_data = data.cloudinit_config.custom.rendered
}

The above is using dynamic blocks to generate a dynamic number of part blocks based on the number of elements in a list, which means you can focus on making sure the lists have the necessary items, using whatever dynamic expressions you need to decide that, and have Terraform project that into zero or more part blocks automatically.
Note: the hashicorp/template provider has been deprecated and continues to be available only for backward-compatibility. For that reason, I wrote the above to use the hashicorp/cloudinit provider instead. Its cloudinit_config data source is based on what was formerly template_cloudinit_config.