getImage

suspend fun getImage(argument: GetImagePlainArgs): GetImageResult

Get information about a Google Compute Image. Check that your service account has the compute.imageUser role if you want to share custom images from another project. If you want to use pubimg, do not forget to specify the dedicated project. For more information see the official documentation and its API.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";
const myImage = gcp.compute.getImage({
family: "debian-11",
project: "debian-cloud",
});
const _default = new gcp.compute.Instance("default", {bootDisk: {
initializeParams: {
image: myImage.then(myImage => myImage.selfLink),
},
}});
import pulumi
import pulumi_gcp as gcp
my_image = gcp.compute.get_image(family="debian-11",
project="debian-cloud")
default = gcp.compute.Instance("default", boot_disk={
"initialize_params": {
"image": my_image.self_link,
},
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;
return await Deployment.RunAsync(() =>
{
var myImage = Gcp.Compute.GetImage.Invoke(new()
{
Family = "debian-11",
Project = "debian-cloud",
});
var @default = new Gcp.Compute.Instance("default", new()
{
BootDisk = new Gcp.Compute.Inputs.InstanceBootDiskArgs
{
InitializeParams = new Gcp.Compute.Inputs.InstanceBootDiskInitializeParamsArgs
{
Image = myImage.Apply(getImageResult => getImageResult.SelfLink),
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-gcp/sdk/v7/go/gcp/compute"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
myImage, err := compute.LookupImage(ctx, &compute.LookupImageArgs{
Family: pulumi.StringRef("debian-11"),
Project: pulumi.StringRef("debian-cloud"),
}, nil)
if err != nil {
return err
}
_, err = compute.NewInstance(ctx, "default", &compute.InstanceArgs{
BootDisk: &compute.InstanceBootDiskArgs{
InitializeParams: &compute.InstanceBootDiskInitializeParamsArgs{
Image: pulumi.String(myImage.SelfLink),
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.gcp.compute.ComputeFunctions;
import com.pulumi.gcp.compute.inputs.GetImageArgs;
import com.pulumi.gcp.compute.Instance;
import com.pulumi.gcp.compute.InstanceArgs;
import com.pulumi.gcp.compute.inputs.InstanceBootDiskArgs;
import com.pulumi.gcp.compute.inputs.InstanceBootDiskInitializeParamsArgs;
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) {
final var myImage = ComputeFunctions.getImage(GetImageArgs.builder()
.family("debian-11")
.project("debian-cloud")
.build());
var default_ = new Instance("default", InstanceArgs.builder()
.bootDisk(InstanceBootDiskArgs.builder()
.initializeParams(InstanceBootDiskInitializeParamsArgs.builder()
.image(myImage.applyValue(getImageResult -> getImageResult.selfLink()))
.build())
.build())
.build());
}
}
resources:
default:
type: gcp:compute:Instance
properties:
bootDisk:
initializeParams:
image: ${myImage.selfLink}
variables:
myImage:
fn::invoke:
Function: gcp:compute:getImage
Arguments:
family: debian-11
project: debian-cloud

Return

A collection of values returned by getImage.

Parameters

argument

A collection of arguments for invoking getImage.


suspend fun getImage(family: String? = null, filter: String? = null, mostRecent: Boolean? = null, name: String? = null, project: String? = null): GetImageResult

Return

A collection of values returned by getImage.

Parameters

family

The family name of the image.

filter
mostRecent

A boolean to indicate either to take to most recent image if your filter returns more than one image.

name

, family or filter - (Required) The name of a specific image or a family. Exactly one of name, family or filter must be specified. If name is specified, it will fetch the corresponding image. If family is specified, it will return the latest image that is part of an image family and is not deprecated. If you specify filter, your filter must return exactly one image unless you use most_recent. Filter syntax can be found here in the filter section.

project

The project in which the resource belongs. If it is not provided, the provider project is used. If you are using a pubimg, be sure to specify the correct Image Project.

See also


suspend fun getImage(argument: suspend GetImagePlainArgsBuilder.() -> Unit): GetImageResult

Return

A collection of values returned by getImage.

Parameters

argument

Builder for com.pulumi.gcp.compute.kotlin.inputs.GetImagePlainArgs.

See also