juju_machine (Resource)¶
A resource that represents a Juju machine deployment. Refer to the juju add-machine CLI command for more information and limitations.
Example Usage¶
resource "juju_machine" "this_machine" {
model = juju_model.development.name
base = "[email protected]"
name = "this_machine"
constraints = "tags=my-machine-tag"
# If you face timeouts destroying machines, add the following lifecycle
# directive, which instructs Terraform to update any dependent resources
# before destroying the machine - in the case of applications this means
# that application units get removed from units before Terraform attempts
# to destroy the machine.
lifecycle {
create_before_destroy = true
}
}
Schema¶
Required¶
model
(String) The Juju model in which to add a new machine. Changing this value will cause the machine to be destroyed and recreated by terraform.
Optional¶
annotations
(Map of String) Annotations are key/value pairs that can be used to store additional information about the machine. May not contain dots (.) in keys.base
(String) The operating system to install on the new machine(s). E.g. ubuntu@22.04. Changing this value will cause the machine to be destroyed and recreated by terraform.constraints
(String) Machine constraints that overwrite those available from ‘juju get-model-constraints’ and provider’s defaults. Changing this value will cause the application to be destroyed and recreated by terraform.disks
(String) Storage constraints for disks to attach to the machine(s). Changing this value will cause the machine to be destroyed and recreated by terraform.name
(String) A name for the machine resource in Terraform.placement
(String) Additional information about how to allocate the machine in the cloud. Changing this value will cause the application to be destroyed and recreated by terraform.private_key_file
(String) The file path to read the private key from.public_key_file
(String) The file path to read the public key from.series
(String, Deprecated) The operating system series to install on the new machine(s). Changing this value will cause the machine to be destroyed and recreated by terraform.ssh_address
(String) The user@host directive for manual provisioning an existing machine via ssh. Requires public_key_file & private_key_file arguments. Changing this value will cause the machine to be destroyed and recreated by terraform.wait_for_hostname
(Boolean) If true, waits for the machine’s hostname to be set during creation. A side effect is that this also waits for the machine to reach ‘active’ state in Juju.
Read-Only¶
hostname
(String) The machine’s hostname. This is set only if ‘wait_for_hostname’ is true.id
(String) The ID of this resource.machine_id
(String) The id of the machine Juju creates.
Notes¶
Juju will automatically remove a machine if all application units deployed to that machine are removed.
Import¶
Import is supported using the following syntax:
# Machines can be imported using the format: `model_name:machine_id:machine_name`.
# The value of machine_id is the Juju Machine ID. machine_name is an optional
# name you can define in Terraform for the machine. It is not used in Juju.
# Here is an example to import a machine from the development model with
# machine ID 1 and a name "machine_one":
$ terraform import juju_machine.machine_one `development:1:machine_one`