Looking for a comprehensive guide? Check out our Cloud-Init Deployment Guide for detailed examples and best practices.
Our provided cloud images rely on Cloud-Init to properly configure your instance upon creation.
Cloud-Init handles such items as networking, hostnames, SSH keys, passwords, etc. Our default configuration should work for almost all cases, but you do have the option to customize your initial instance configuration using cloud-init user data.
What is Cloud-Init?
Cloud-Init is an industry-standard method for cloud instance initialization. It allows you to:
Configure Users
Create users, set passwords, add SSH keys
Install Packages
Install software automatically on first boot
Run Commands
Execute scripts or commands at boot
Write Files
Create configuration files automatically
Common Examples
Basic Package Installation
#cloud-config
packages:
- nginx
- git
- htop
- curl
package_update: true
package_upgrade: trueCreate Users with SSH Keys
#cloud-config
users:
- name: deploy
groups: sudo
shell: /bin/bash
sudo: ['ALL=(ALL) NOPASSWD:ALL']
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2E... user@example.comRun Commands on First Boot
#cloud-config
runcmd:
- echo "Hello from Cloud-Init!" > /tmp/hello.txt
- systemctl enable nginx
- systemctl start nginxWrite Configuration Files
#cloud-config
write_files:
- path: /etc/myapp/config.yml
content: |
environment: production
database: mysql
port: 3000
permissions: '0644'
owner: root:root⚠️ Important
Cloud-Init user data is only executed on the first boot of an instance. Changes to user data after instance creation will not be applied unless you create a new instance.
Learning Resources
Cloud-Init documentation provides a variety of cloud config user data examples. We will update this page with some of our own as we encounter different customer scenarios.
