1. Packages
  2. Lxd Provider
  3. API Docs
  4. PublishImage
lxd 2.5.0 published on Thursday, Mar 13, 2025 by terraform-lxd

lxd.PublishImage

Explore with Pulumi AI

# lxd.PublishImage

Create a LXD image from an instance.

Example Usage

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

const xenial = new lxd.CachedImage("xenial", {
    sourceRemote: "ubuntu",
    sourceImage: "xenial/amd64",
});
const test1Instance = new lxd.Instance("test1Instance", {
    image: xenial.fingerprint,
    running: false,
});
const test1PublishImage = new lxd.PublishImage("test1PublishImage", {
    instance: test1Instance.name,
    aliases: ["test1_img"],
});
Copy
import pulumi
import pulumi_lxd as lxd

xenial = lxd.CachedImage("xenial",
    source_remote="ubuntu",
    source_image="xenial/amd64")
test1_instance = lxd.Instance("test1Instance",
    image=xenial.fingerprint,
    running=False)
test1_publish_image = lxd.PublishImage("test1PublishImage",
    instance=test1_instance.name,
    aliases=["test1_img"])
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		xenial, err := lxd.NewCachedImage(ctx, "xenial", &lxd.CachedImageArgs{
			SourceRemote: pulumi.String("ubuntu"),
			SourceImage:  pulumi.String("xenial/amd64"),
		})
		if err != nil {
			return err
		}
		test1Instance, err := lxd.NewInstance(ctx, "test1Instance", &lxd.InstanceArgs{
			Image:   xenial.Fingerprint,
			Running: pulumi.Bool(false),
		})
		if err != nil {
			return err
		}
		_, err = lxd.NewPublishImage(ctx, "test1PublishImage", &lxd.PublishImageArgs{
			Instance: test1Instance.Name,
			Aliases: pulumi.StringArray{
				pulumi.String("test1_img"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Lxd = Pulumi.Lxd;

return await Deployment.RunAsync(() => 
{
    var xenial = new Lxd.CachedImage("xenial", new()
    {
        SourceRemote = "ubuntu",
        SourceImage = "xenial/amd64",
    });

    var test1Instance = new Lxd.Instance("test1Instance", new()
    {
        Image = xenial.Fingerprint,
        Running = false,
    });

    var test1PublishImage = new Lxd.PublishImage("test1PublishImage", new()
    {
        Instance = test1Instance.Name,
        Aliases = new[]
        {
            "test1_img",
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.lxd.CachedImage;
import com.pulumi.lxd.CachedImageArgs;
import com.pulumi.lxd.Instance;
import com.pulumi.lxd.InstanceArgs;
import com.pulumi.lxd.PublishImage;
import com.pulumi.lxd.PublishImageArgs;
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 xenial = new CachedImage("xenial", CachedImageArgs.builder()
            .sourceRemote("ubuntu")
            .sourceImage("xenial/amd64")
            .build());

        var test1Instance = new Instance("test1Instance", InstanceArgs.builder()
            .image(xenial.fingerprint())
            .running(false)
            .build());

        var test1PublishImage = new PublishImage("test1PublishImage", PublishImageArgs.builder()
            .instance(test1Instance.name())
            .aliases("test1_img")
            .build());

    }
}
Copy
resources:
  xenial:
    type: lxd:CachedImage
    properties:
      sourceRemote: ubuntu
      sourceImage: xenial/amd64
  test1Instance:
    type: lxd:Instance
    properties:
      image: ${xenial.fingerprint}
      running: false
  test1PublishImage:
    type: lxd:PublishImage
    properties:
      instance: ${test1Instance.name}
      aliases:
        - test1_img
Copy

Notes

  • Image can only be published if the instance is stopped.

Create PublishImage Resource

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

Constructor syntax

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

@overload
def PublishImage(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 instance: Optional[str] = None,
                 aliases: Optional[Sequence[str]] = None,
                 compression_algorithm: Optional[str] = None,
                 filename: Optional[str] = None,
                 project: Optional[str] = None,
                 properties: Optional[Mapping[str, str]] = None,
                 public: Optional[bool] = None,
                 remote: Optional[str] = None,
                 triggers: Optional[Sequence[str]] = None)
func NewPublishImage(ctx *Context, name string, args PublishImageArgs, opts ...ResourceOption) (*PublishImage, error)
public PublishImage(string name, PublishImageArgs args, CustomResourceOptions? opts = null)
public PublishImage(String name, PublishImageArgs args)
public PublishImage(String name, PublishImageArgs args, CustomResourceOptions options)
type: lxd:PublishImage
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. PublishImageArgs
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. PublishImageArgs
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. PublishImageArgs
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. PublishImageArgs
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. PublishImageArgs
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 publishImageResource = new Lxd.PublishImage("publishImageResource", new()
{
    Instance = "string",
    Aliases = new[]
    {
        "string",
    },
    CompressionAlgorithm = "string",
    Filename = "string",
    Project = "string",
    Properties = 
    {
        { "string", "string" },
    },
    Public = false,
    Remote = "string",
    Triggers = new[]
    {
        "string",
    },
});
Copy
example, err := lxd.NewPublishImage(ctx, "publishImageResource", &lxd.PublishImageArgs{
Instance: pulumi.String("string"),
Aliases: pulumi.StringArray{
pulumi.String("string"),
},
CompressionAlgorithm: pulumi.String("string"),
Filename: pulumi.String("string"),
Project: pulumi.String("string"),
Properties: pulumi.StringMap{
"string": pulumi.String("string"),
},
Public: pulumi.Bool(false),
Remote: pulumi.String("string"),
Triggers: pulumi.StringArray{
pulumi.String("string"),
},
})
Copy
var publishImageResource = new PublishImage("publishImageResource", PublishImageArgs.builder()
    .instance("string")
    .aliases("string")
    .compressionAlgorithm("string")
    .filename("string")
    .project("string")
    .properties(Map.of("string", "string"))
    .public_(false)
    .remote("string")
    .triggers("string")
    .build());
Copy
publish_image_resource = lxd.PublishImage("publishImageResource",
    instance="string",
    aliases=["string"],
    compression_algorithm="string",
    filename="string",
    project="string",
    properties={
        "string": "string",
    },
    public=False,
    remote="string",
    triggers=["string"])
Copy
const publishImageResource = new lxd.PublishImage("publishImageResource", {
    instance: "string",
    aliases: ["string"],
    compressionAlgorithm: "string",
    filename: "string",
    project: "string",
    properties: {
        string: "string",
    },
    "public": false,
    remote: "string",
    triggers: ["string"],
});
Copy
type: lxd:PublishImage
properties:
    aliases:
        - string
    compressionAlgorithm: string
    filename: string
    instance: string
    project: string
    properties:
        string: string
    public: false
    remote: string
    triggers:
        - string
Copy

PublishImage 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 PublishImage resource accepts the following input properties:

Instance This property is required. string
Required - The name of the instance.
Aliases List<string>
Optional - A list of aliases to assign to the image.
CompressionAlgorithm string
Optional - Override the compression algorithm for the image. Valid values are (bzip2, gzip, lzma, xz or none). Defaults to gzip.
Filename string
Optional - Used for export.
Project string
Optional - Name of the project where the published image will be stored.
Properties Dictionary<string, string>
Optional - A map of properties to assign to the image.
Public bool
Optional - Whether the image can be downloaded by untrusted users. Valid values are true and false. Defaults to false.
Remote string
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
Triggers List<string>
Optional - A list of arbitrary strings that, when changed, will force the resource to be replaced.
Instance This property is required. string
Required - The name of the instance.
Aliases []string
Optional - A list of aliases to assign to the image.
CompressionAlgorithm string
Optional - Override the compression algorithm for the image. Valid values are (bzip2, gzip, lzma, xz or none). Defaults to gzip.
Filename string
Optional - Used for export.
Project string
Optional - Name of the project where the published image will be stored.
Properties map[string]string
Optional - A map of properties to assign to the image.
Public bool
Optional - Whether the image can be downloaded by untrusted users. Valid values are true and false. Defaults to false.
Remote string
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
Triggers []string
Optional - A list of arbitrary strings that, when changed, will force the resource to be replaced.
instance This property is required. String
Required - The name of the instance.
aliases List<String>
Optional - A list of aliases to assign to the image.
compressionAlgorithm String
Optional - Override the compression algorithm for the image. Valid values are (bzip2, gzip, lzma, xz or none). Defaults to gzip.
filename String
Optional - Used for export.
project String
Optional - Name of the project where the published image will be stored.
properties Map<String,String>
Optional - A map of properties to assign to the image.
public_ Boolean
Optional - Whether the image can be downloaded by untrusted users. Valid values are true and false. Defaults to false.
remote String
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
triggers List<String>
Optional - A list of arbitrary strings that, when changed, will force the resource to be replaced.
instance This property is required. string
Required - The name of the instance.
aliases string[]
Optional - A list of aliases to assign to the image.
compressionAlgorithm string
Optional - Override the compression algorithm for the image. Valid values are (bzip2, gzip, lzma, xz or none). Defaults to gzip.
filename string
Optional - Used for export.
project string
Optional - Name of the project where the published image will be stored.
properties {[key: string]: string}
Optional - A map of properties to assign to the image.
public boolean
Optional - Whether the image can be downloaded by untrusted users. Valid values are true and false. Defaults to false.
remote string
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
triggers string[]
Optional - A list of arbitrary strings that, when changed, will force the resource to be replaced.
instance This property is required. str
Required - The name of the instance.
aliases Sequence[str]
Optional - A list of aliases to assign to the image.
compression_algorithm str
Optional - Override the compression algorithm for the image. Valid values are (bzip2, gzip, lzma, xz or none). Defaults to gzip.
filename str
Optional - Used for export.
project str
Optional - Name of the project where the published image will be stored.
properties Mapping[str, str]
Optional - A map of properties to assign to the image.
public bool
Optional - Whether the image can be downloaded by untrusted users. Valid values are true and false. Defaults to false.
remote str
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
triggers Sequence[str]
Optional - A list of arbitrary strings that, when changed, will force the resource to be replaced.
instance This property is required. String
Required - The name of the instance.
aliases List<String>
Optional - A list of aliases to assign to the image.
compressionAlgorithm String
Optional - Override the compression algorithm for the image. Valid values are (bzip2, gzip, lzma, xz or none). Defaults to gzip.
filename String
Optional - Used for export.
project String
Optional - Name of the project where the published image will be stored.
properties Map<String>
Optional - A map of properties to assign to the image.
public Boolean
Optional - Whether the image can be downloaded by untrusted users. Valid values are true and false. Defaults to false.
remote String
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
triggers List<String>
Optional - A list of arbitrary strings that, when changed, will force the resource to be replaced.

Outputs

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

Architecture string
The architecture of the published image.
CreatedAt double
The creation timestamp of the published image.
Fingerprint string
The fingerprint of the published image.
Id string
The provider-assigned unique ID for this managed resource.
Architecture string
The architecture of the published image.
CreatedAt float64
The creation timestamp of the published image.
Fingerprint string
The fingerprint of the published image.
Id string
The provider-assigned unique ID for this managed resource.
architecture String
The architecture of the published image.
createdAt Double
The creation timestamp of the published image.
fingerprint String
The fingerprint of the published image.
id String
The provider-assigned unique ID for this managed resource.
architecture string
The architecture of the published image.
createdAt number
The creation timestamp of the published image.
fingerprint string
The fingerprint of the published image.
id string
The provider-assigned unique ID for this managed resource.
architecture str
The architecture of the published image.
created_at float
The creation timestamp of the published image.
fingerprint str
The fingerprint of the published image.
id str
The provider-assigned unique ID for this managed resource.
architecture String
The architecture of the published image.
createdAt Number
The creation timestamp of the published image.
fingerprint String
The fingerprint of the published image.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing PublishImage Resource

Get an existing PublishImage 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?: PublishImageState, opts?: CustomResourceOptions): PublishImage
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        aliases: Optional[Sequence[str]] = None,
        architecture: Optional[str] = None,
        compression_algorithm: Optional[str] = None,
        created_at: Optional[float] = None,
        filename: Optional[str] = None,
        fingerprint: Optional[str] = None,
        instance: Optional[str] = None,
        project: Optional[str] = None,
        properties: Optional[Mapping[str, str]] = None,
        public: Optional[bool] = None,
        remote: Optional[str] = None,
        triggers: Optional[Sequence[str]] = None) -> PublishImage
func GetPublishImage(ctx *Context, name string, id IDInput, state *PublishImageState, opts ...ResourceOption) (*PublishImage, error)
public static PublishImage Get(string name, Input<string> id, PublishImageState? state, CustomResourceOptions? opts = null)
public static PublishImage get(String name, Output<String> id, PublishImageState state, CustomResourceOptions options)
resources:  _:    type: lxd:PublishImage    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:
Aliases List<string>
Optional - A list of aliases to assign to the image.
Architecture string
The architecture of the published image.
CompressionAlgorithm string
Optional - Override the compression algorithm for the image. Valid values are (bzip2, gzip, lzma, xz or none). Defaults to gzip.
CreatedAt double
The creation timestamp of the published image.
Filename string
Optional - Used for export.
Fingerprint string
The fingerprint of the published image.
Instance string
Required - The name of the instance.
Project string
Optional - Name of the project where the published image will be stored.
Properties Dictionary<string, string>
Optional - A map of properties to assign to the image.
Public bool
Optional - Whether the image can be downloaded by untrusted users. Valid values are true and false. Defaults to false.
Remote string
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
Triggers List<string>
Optional - A list of arbitrary strings that, when changed, will force the resource to be replaced.
Aliases []string
Optional - A list of aliases to assign to the image.
Architecture string
The architecture of the published image.
CompressionAlgorithm string
Optional - Override the compression algorithm for the image. Valid values are (bzip2, gzip, lzma, xz or none). Defaults to gzip.
CreatedAt float64
The creation timestamp of the published image.
Filename string
Optional - Used for export.
Fingerprint string
The fingerprint of the published image.
Instance string
Required - The name of the instance.
Project string
Optional - Name of the project where the published image will be stored.
Properties map[string]string
Optional - A map of properties to assign to the image.
Public bool
Optional - Whether the image can be downloaded by untrusted users. Valid values are true and false. Defaults to false.
Remote string
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
Triggers []string
Optional - A list of arbitrary strings that, when changed, will force the resource to be replaced.
aliases List<String>
Optional - A list of aliases to assign to the image.
architecture String
The architecture of the published image.
compressionAlgorithm String
Optional - Override the compression algorithm for the image. Valid values are (bzip2, gzip, lzma, xz or none). Defaults to gzip.
createdAt Double
The creation timestamp of the published image.
filename String
Optional - Used for export.
fingerprint String
The fingerprint of the published image.
instance String
Required - The name of the instance.
project String
Optional - Name of the project where the published image will be stored.
properties Map<String,String>
Optional - A map of properties to assign to the image.
public_ Boolean
Optional - Whether the image can be downloaded by untrusted users. Valid values are true and false. Defaults to false.
remote String
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
triggers List<String>
Optional - A list of arbitrary strings that, when changed, will force the resource to be replaced.
aliases string[]
Optional - A list of aliases to assign to the image.
architecture string
The architecture of the published image.
compressionAlgorithm string
Optional - Override the compression algorithm for the image. Valid values are (bzip2, gzip, lzma, xz or none). Defaults to gzip.
createdAt number
The creation timestamp of the published image.
filename string
Optional - Used for export.
fingerprint string
The fingerprint of the published image.
instance string
Required - The name of the instance.
project string
Optional - Name of the project where the published image will be stored.
properties {[key: string]: string}
Optional - A map of properties to assign to the image.
public boolean
Optional - Whether the image can be downloaded by untrusted users. Valid values are true and false. Defaults to false.
remote string
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
triggers string[]
Optional - A list of arbitrary strings that, when changed, will force the resource to be replaced.
aliases Sequence[str]
Optional - A list of aliases to assign to the image.
architecture str
The architecture of the published image.
compression_algorithm str
Optional - Override the compression algorithm for the image. Valid values are (bzip2, gzip, lzma, xz or none). Defaults to gzip.
created_at float
The creation timestamp of the published image.
filename str
Optional - Used for export.
fingerprint str
The fingerprint of the published image.
instance str
Required - The name of the instance.
project str
Optional - Name of the project where the published image will be stored.
properties Mapping[str, str]
Optional - A map of properties to assign to the image.
public bool
Optional - Whether the image can be downloaded by untrusted users. Valid values are true and false. Defaults to false.
remote str
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
triggers Sequence[str]
Optional - A list of arbitrary strings that, when changed, will force the resource to be replaced.
aliases List<String>
Optional - A list of aliases to assign to the image.
architecture String
The architecture of the published image.
compressionAlgorithm String
Optional - Override the compression algorithm for the image. Valid values are (bzip2, gzip, lzma, xz or none). Defaults to gzip.
createdAt Number
The creation timestamp of the published image.
filename String
Optional - Used for export.
fingerprint String
The fingerprint of the published image.
instance String
Required - The name of the instance.
project String
Optional - Name of the project where the published image will be stored.
properties Map<String>
Optional - A map of properties to assign to the image.
public Boolean
Optional - Whether the image can be downloaded by untrusted users. Valid values are true and false. Defaults to false.
remote String
Optional - The remote in which the resource will be created. If not provided, the provider's default remote will be used.
triggers List<String>
Optional - A list of arbitrary strings that, when changed, will force the resource to be replaced.

Package Details

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