LUKS encryption with cloud-init with only one drive sda

Posted by Pandoks_@reddit | linuxadmin | View on Reddit | 7 comments

I'm using a Hetzner vps running Ubuntu 22.04. I have a cloud-init config that sets everything up (firewalls, users, hardening, etc). The only thing that I don't have is disk encryption. I want to fully automate everything meaning that I don't want to go on the Hetzner website to configure things (using IaC to manage my boxes) and I also don't want to ssh into the box.

Is there a way to use LUKS to encrypt sda or at least some of the important directories (maybe a way to partition the disk) as a script I can run in cloud-init?