Terraform config for quickly spinning up Multipass VMs. It builds on the efforts of this project.
This setup allows us to define a cloud-init template, which will help us add such things as users, groups, startup commands, ssh keys for access, etc. to the VMs.
The key module manages the SSH keys. For every new VM, a SSH public-private key pair is generated.
The ssh_key
resource wraps up calls to a script that creates, reads and deletes the key, according to the resource lifecycle.
The config module provides the cloud-init yaml content. It reads from the template file, replaces some placeholders in the template with values from the module, then returns valid cloud-init content.
The multipass module manages the VM, allowing the name, memory, cpus and disk-space to be customized.
The vm
resource wraps up calls to a script that creates, reads and deletes the vm, according to the resource lifecycle.
Apply the configuration:
terraform init
terraform apply -auto-approve
Access a VM:
ssh -i multipass/key/keys/id_rsa_test-vm-0 -oStrictHostKeyChecking=no [email protected]
ToDo: Use Terraform to spin up a microk8s cluster entirely on this config.