1. Packages
  2. Juju Provider
  3. API Docs
  4. Machine
juju 0.18.0 published on Monday, Apr 14, 2025 by juju

juju.Machine

Explore with Pulumi AI

A resource that represents a Juju machine deployment. Refer to the juju add-machine CLI command for more information and limitations.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as juju from "@pulumi/juju";

const thisMachine = new juju.Machine("thisMachine", {
    model: juju_model.development.name,
    base: "ubuntu@22.04",
    constraints: "tags=my-machine-tag",
});
Copy
import pulumi
import pulumi_juju as juju

this_machine = juju.Machine("thisMachine",
    model=juju_model["development"]["name"],
    base="ubuntu@22.04",
    constraints="tags=my-machine-tag")
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/juju/juju"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := juju.NewMachine(ctx, "thisMachine", &juju.MachineArgs{
			Model:       pulumi.Any(juju_model.Development.Name),
			Base:        pulumi.String("ubuntu@22.04"),
			Constraints: pulumi.String("tags=my-machine-tag"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Juju = Pulumi.Juju;

return await Deployment.RunAsync(() => 
{
    var thisMachine = new Juju.Machine("thisMachine", new()
    {
        Model = juju_model.Development.Name,
        Base = "ubuntu@22.04",
        Constraints = "tags=my-machine-tag",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.juju.Machine;
import com.pulumi.juju.MachineArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var thisMachine = new Machine("thisMachine", MachineArgs.builder()
            .model(juju_model.development().name())
            .base("ubuntu@22.04")
            .constraints("tags=my-machine-tag")
            .build());

    }
}
Copy
resources:
  thisMachine:
    type: juju:Machine
    properties:
      model: ${juju_model.development.name}
      base: ubuntu@22.04
      constraints: tags=my-machine-tag
Copy

Create Machine Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Machine(name: string, args: MachineArgs, opts?: CustomResourceOptions);
@overload
def Machine(resource_name: str,
            args: MachineArgs,
            opts: Optional[ResourceOptions] = None)

@overload
def Machine(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            model: Optional[str] = None,
            base: Optional[str] = None,
            constraints: Optional[str] = None,
            disks: Optional[str] = None,
            name: Optional[str] = None,
            placement: Optional[str] = None,
            private_key_file: Optional[str] = None,
            public_key_file: Optional[str] = None,
            series: Optional[str] = None,
            ssh_address: Optional[str] = None)
func NewMachine(ctx *Context, name string, args MachineArgs, opts ...ResourceOption) (*Machine, error)
public Machine(string name, MachineArgs args, CustomResourceOptions? opts = null)
public Machine(String name, MachineArgs args)
public Machine(String name, MachineArgs args, CustomResourceOptions options)
type: juju:Machine
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. MachineArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. MachineArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. MachineArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. MachineArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. MachineArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var machineResource = new Juju.Machine("machineResource", new()
{
    Model = "string",
    Base = "string",
    Constraints = "string",
    Disks = "string",
    Name = "string",
    Placement = "string",
    PrivateKeyFile = "string",
    PublicKeyFile = "string",
    SshAddress = "string",
});
Copy
example, err := juju.NewMachine(ctx, "machineResource", &juju.MachineArgs{
Model: pulumi.String("string"),
Base: pulumi.String("string"),
Constraints: pulumi.String("string"),
Disks: pulumi.String("string"),
Name: pulumi.String("string"),
Placement: pulumi.String("string"),
PrivateKeyFile: pulumi.String("string"),
PublicKeyFile: pulumi.String("string"),
SshAddress: pulumi.String("string"),
})
Copy
var machineResource = new Machine("machineResource", MachineArgs.builder()
    .model("string")
    .base("string")
    .constraints("string")
    .disks("string")
    .name("string")
    .placement("string")
    .privateKeyFile("string")
    .publicKeyFile("string")
    .sshAddress("string")
    .build());
Copy
machine_resource = juju.Machine("machineResource",
    model="string",
    base="string",
    constraints="string",
    disks="string",
    name="string",
    placement="string",
    private_key_file="string",
    public_key_file="string",
    ssh_address="string")
Copy
const machineResource = new juju.Machine("machineResource", {
    model: "string",
    base: "string",
    constraints: "string",
    disks: "string",
    name: "string",
    placement: "string",
    privateKeyFile: "string",
    publicKeyFile: "string",
    sshAddress: "string",
});
Copy
type: juju:Machine
properties:
    base: string
    constraints: string
    disks: string
    model: string
    name: string
    placement: string
    privateKeyFile: string
    publicKeyFile: string
    sshAddress: string
Copy

Machine Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Machine resource accepts the following input properties:

Model This property is required. string
Base string
Constraints string
Disks string
Name string
Placement string
PrivateKeyFile string
The file path to read the private key from.
PublicKeyFile string
The file path to read the public key from.
Series string

Deprecated: Deprecated

SshAddress string
Model This property is required. string
Base string
Constraints string
Disks string
Name string
Placement string
PrivateKeyFile string
The file path to read the private key from.
PublicKeyFile string
The file path to read the public key from.
Series string

Deprecated: Deprecated

SshAddress string
model This property is required. String
base String
constraints String
disks String
name String
placement String
privateKeyFile String
The file path to read the private key from.
publicKeyFile String
The file path to read the public key from.
series String

Deprecated: Deprecated

sshAddress String
model This property is required. string
base string
constraints string
disks string
name string
placement string
privateKeyFile string
The file path to read the private key from.
publicKeyFile string
The file path to read the public key from.
series string

Deprecated: Deprecated

sshAddress string
model This property is required. str
base str
constraints str
disks str
name str
placement str
private_key_file str
The file path to read the private key from.
public_key_file str
The file path to read the public key from.
series str

Deprecated: Deprecated

ssh_address str
model This property is required. String
base String
constraints String
disks String
name String
placement String
privateKeyFile String
The file path to read the private key from.
publicKeyFile String
The file path to read the public key from.
series String

Deprecated: Deprecated

sshAddress String

Outputs

All input properties are implicitly available as output properties. Additionally, the Machine resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
MachineId string
The id of the machine Juju creates.
Id string
The provider-assigned unique ID for this managed resource.
MachineId string
The id of the machine Juju creates.
id String
The provider-assigned unique ID for this managed resource.
machineId String
The id of the machine Juju creates.
id string
The provider-assigned unique ID for this managed resource.
machineId string
The id of the machine Juju creates.
id str
The provider-assigned unique ID for this managed resource.
machine_id str
The id of the machine Juju creates.
id String
The provider-assigned unique ID for this managed resource.
machineId String
The id of the machine Juju creates.

Look up Existing Machine Resource

Get an existing Machine resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: MachineState, opts?: CustomResourceOptions): Machine
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        base: Optional[str] = None,
        constraints: Optional[str] = None,
        disks: Optional[str] = None,
        machine_id: Optional[str] = None,
        model: Optional[str] = None,
        name: Optional[str] = None,
        placement: Optional[str] = None,
        private_key_file: Optional[str] = None,
        public_key_file: Optional[str] = None,
        series: Optional[str] = None,
        ssh_address: Optional[str] = None) -> Machine
func GetMachine(ctx *Context, name string, id IDInput, state *MachineState, opts ...ResourceOption) (*Machine, error)
public static Machine Get(string name, Input<string> id, MachineState? state, CustomResourceOptions? opts = null)
public static Machine get(String name, Output<String> id, MachineState state, CustomResourceOptions options)
resources:  _:    type: juju:Machine    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Base string
Constraints string
Disks string
MachineId string
The id of the machine Juju creates.
Model string
Name string
Placement string
PrivateKeyFile string
The file path to read the private key from.
PublicKeyFile string
The file path to read the public key from.
Series string

Deprecated: Deprecated

SshAddress string
Base string
Constraints string
Disks string
MachineId string
The id of the machine Juju creates.
Model string
Name string
Placement string
PrivateKeyFile string
The file path to read the private key from.
PublicKeyFile string
The file path to read the public key from.
Series string

Deprecated: Deprecated

SshAddress string
base String
constraints String
disks String
machineId String
The id of the machine Juju creates.
model String
name String
placement String
privateKeyFile String
The file path to read the private key from.
publicKeyFile String
The file path to read the public key from.
series String

Deprecated: Deprecated

sshAddress String
base string
constraints string
disks string
machineId string
The id of the machine Juju creates.
model string
name string
placement string
privateKeyFile string
The file path to read the private key from.
publicKeyFile string
The file path to read the public key from.
series string

Deprecated: Deprecated

sshAddress string
base str
constraints str
disks str
machine_id str
The id of the machine Juju creates.
model str
name str
placement str
private_key_file str
The file path to read the private key from.
public_key_file str
The file path to read the public key from.
series str

Deprecated: Deprecated

ssh_address str
base String
constraints String
disks String
machineId String
The id of the machine Juju creates.
model String
name String
placement String
privateKeyFile String
The file path to read the private key from.
publicKeyFile String
The file path to read the public key from.
series String

Deprecated: Deprecated

sshAddress String

Import

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”:

$ pulumi import juju:index/machine:Machine machine_one `development:1:machine_one`
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
juju juju/terraform-provider-juju
License
Notes
This Pulumi package is based on the juju Terraform Provider.