Cloud Init can do quite complex things if you configure it so.
For a Host/Server being installed on an actual IaaS “Cloud”, the cloud-init file may be limited in maximum “size”.
However, does that still apply to the LXD container use-case as the referenced comment  below suggests it may only apply to Host/Servers on an IaaS Cloud not containers.
I guess experimenting with a larger Cloud Init file would tell us if LXD has a problem with say a 32,000 byte (or larger) Cloud Init but I thought I’d ask first:
Content found to be gzip compressed will be uncompressed. The uncompressed data will then be used as if it were not compressed. This is typically useful because user-data is limited to ~16384  bytes.
 See your cloud provider for applicable user-data size limitations…