# Cloud-init

> Cloud-init is a multi-distribution package that handles the early initialization of cloud instances.

- Source: https://www.itwonderlab.com/cloud-init/
- Published: 2024-03-01
- Updated: 2026-10-05
- Author: Javier Ruiz Jiménez (https://www.javierruizjimenez.com/)
- Site: IT Wonder Lab (https://www.itwonderlab.com/)

---

**Cloud-init** is a multi-distribution package that handles the early initialization of cloud instances.

Cloud-init is the industry standard multi-distribution method for cross-platform cloud instance initialization.

It is commonly used in cloud computing environments to perform various tasks during the instance’s first boot:

-   **User Data**: When a new instance is launched in a cloud environment, the user provides user data consisting of a script or cloud-init directives with the instructions to configure the instance.
-   **Instance Launch**: AWS injects the user data into the instance metadata.
-   **Cloud-init Execution**: During the first boot of the instance, cloud-init reads the user data and executes the specified actions and tasks, such as setting up SSH keys, installing packages, or configuring users.
-   **Configurations**: cloud-init processes the user data using modules, each responsible for a specific aspect of configuration.
-   **DataSource**: cloud-init relies on a DataSource to retrieve information about the instance and its environment. AWS provides a metadata service with details like instance ID, hostname, and user data.
-   **Output and Logs**: the results of the cloud-init execution are logged in /var/log/cloud-init.log or /var/log/cloud-init-output.log. Additionally, the early configuration of the instance can be inspected with the console output in the AWS Console.
-   **Completion**: Once cloud-init completes its tasks, the instance is ready for use with the configured settings.

### Cloud-Init and SSH Public Keys

During instance launch, Cloud-init appends the [AWS stored Public Key](https://www.itwonderlab.com/aws-key-pairs-terraform/) to the instance authorized\_keys file inside the ~/.ssh/ directory.

[Official Cloud-Init documentation](https://cloudinit.readthedocs.io/).

See tutorials using Cloud-Init:

-   [AWS with Terraform: The Essential Guide (10/21) – AWS Key Pairs](https://www.itwonderlab.com/aws-terraform-tutorial-aws-key-pairs/)
