Google Cloud (GCP) Classic

v6.38.0 published on Thursday, Sep 22, 2022 by Pulumi

getImage

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 [public images][pubimg], do not forget to specify the dedicated project. For more information see the official documentation and its API.

Example Usage

using System.Collections.Generic;
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/v6/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());

    }
}
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=gcp.compute.InstanceBootDiskArgs(
    initialize_params=gcp.compute.InstanceBootDiskInitializeParamsArgs(
        image=my_image.self_link,
    ),
))
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),
    },
}});
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

Using getImage

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getImage(args: GetImageArgs, opts?: InvokeOptions): Promise<GetImageResult>
function getImageOutput(args: GetImageOutputArgs, opts?: InvokeOptions): Output<GetImageResult>
def get_image(family: Optional[str] = None,
              filter: Optional[str] = None,
              name: Optional[str] = None,
              project: Optional[str] = None,
              opts: Optional[InvokeOptions] = None) -> GetImageResult
def get_image_output(family: Optional[pulumi.Input[str]] = None,
              filter: Optional[pulumi.Input[str]] = None,
              name: Optional[pulumi.Input[str]] = None,
              project: Optional[pulumi.Input[str]] = None,
              opts: Optional[InvokeOptions] = None) -> Output[GetImageResult]
func LookupImage(ctx *Context, args *LookupImageArgs, opts ...InvokeOption) (*LookupImageResult, error)
func LookupImageOutput(ctx *Context, args *LookupImageOutputArgs, opts ...InvokeOption) LookupImageResultOutput

> Note: This function is named LookupImage in the Go SDK.

public static class GetImage 
{
    public static Task<GetImageResult> InvokeAsync(GetImageArgs args, InvokeOptions? opts = null)
    public static Output<GetImageResult> Invoke(GetImageInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetImageResult> getImage(GetImageArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: gcp:compute/getImage:getImage
  Arguments:
    # Arguments dictionary

The following arguments are supported:

Family string

The family name of the image.

Filter string
Name string

The name of the image.

Project string

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

Family string

The family name of the image.

Filter string
Name string

The name of the image.

Project string

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

family String

The family name of the image.

filter String
name String

The name of the image.

project String

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

family string

The family name of the image.

filter string
name string

The name of the image.

project string

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

family str

The family name of the image.

filter str
name str

The name of the image.

project str

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

family String

The family name of the image.

filter String
name String

The name of the image.

project String

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

getImage Result

The following output properties are available:

ArchiveSizeBytes int

The size of the image tar.gz archive stored in Google Cloud Storage in bytes.

CreationTimestamp string

The creation timestamp in RFC3339 text format.

Description string

An optional description of this image.

DiskSizeGb int

The size of the image when restored onto a persistent disk in gigabytes.

Family string

The family name of the image.

Id string

The provider-assigned unique ID for this managed resource.

ImageEncryptionKeySha256 string

The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.

ImageId string

The unique identifier for the image.

LabelFingerprint string

A fingerprint for the labels being applied to this image.

Labels Dictionary<string, string>

A map of labels applied to this image.

Licenses List<string>

A list of applicable license URI.

Name string

The name of the image.

Project string
SelfLink string

The URI of the image.

SourceDisk string

The URL of the source disk used to create this image.

SourceDiskEncryptionKeySha256 string

The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.

SourceDiskId string

The ID value of the disk used to create this image.

SourceImageId string

The ID value of the image used to create this image.

Status string

The status of the image. Possible values are FAILED, PENDING, or READY.

Filter string
ArchiveSizeBytes int

The size of the image tar.gz archive stored in Google Cloud Storage in bytes.

CreationTimestamp string

The creation timestamp in RFC3339 text format.

Description string

An optional description of this image.

DiskSizeGb int

The size of the image when restored onto a persistent disk in gigabytes.

Family string

The family name of the image.

Id string

The provider-assigned unique ID for this managed resource.

ImageEncryptionKeySha256 string

The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.

ImageId string

The unique identifier for the image.

LabelFingerprint string

A fingerprint for the labels being applied to this image.

Labels map[string]string

A map of labels applied to this image.

Licenses []string

A list of applicable license URI.

Name string

The name of the image.

Project string
SelfLink string

The URI of the image.

SourceDisk string

The URL of the source disk used to create this image.

SourceDiskEncryptionKeySha256 string

The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.

SourceDiskId string

The ID value of the disk used to create this image.

SourceImageId string

The ID value of the image used to create this image.

Status string

The status of the image. Possible values are FAILED, PENDING, or READY.

Filter string
archiveSizeBytes Integer

The size of the image tar.gz archive stored in Google Cloud Storage in bytes.

creationTimestamp String

The creation timestamp in RFC3339 text format.

description String

An optional description of this image.

diskSizeGb Integer

The size of the image when restored onto a persistent disk in gigabytes.

family String

The family name of the image.

id String

The provider-assigned unique ID for this managed resource.

imageEncryptionKeySha256 String

The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.

imageId String

The unique identifier for the image.

labelFingerprint String

A fingerprint for the labels being applied to this image.

labels Map<String,String>

A map of labels applied to this image.

licenses List<String>

A list of applicable license URI.

name String

The name of the image.

project String
selfLink String

The URI of the image.

sourceDisk String

The URL of the source disk used to create this image.

sourceDiskEncryptionKeySha256 String

The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.

sourceDiskId String

The ID value of the disk used to create this image.

sourceImageId String

The ID value of the image used to create this image.

status String

The status of the image. Possible values are FAILED, PENDING, or READY.

filter String
archiveSizeBytes number

The size of the image tar.gz archive stored in Google Cloud Storage in bytes.

creationTimestamp string

The creation timestamp in RFC3339 text format.

description string

An optional description of this image.

diskSizeGb number

The size of the image when restored onto a persistent disk in gigabytes.

family string

The family name of the image.

id string

The provider-assigned unique ID for this managed resource.

imageEncryptionKeySha256 string

The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.

imageId string

The unique identifier for the image.

labelFingerprint string

A fingerprint for the labels being applied to this image.

labels {[key: string]: string}

A map of labels applied to this image.

licenses string[]

A list of applicable license URI.

name string

The name of the image.

project string
selfLink string

The URI of the image.

sourceDisk string

The URL of the source disk used to create this image.

sourceDiskEncryptionKeySha256 string

The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.

sourceDiskId string

The ID value of the disk used to create this image.

sourceImageId string

The ID value of the image used to create this image.

status string

The status of the image. Possible values are FAILED, PENDING, or READY.

filter string
archive_size_bytes int

The size of the image tar.gz archive stored in Google Cloud Storage in bytes.

creation_timestamp str

The creation timestamp in RFC3339 text format.

description str

An optional description of this image.

disk_size_gb int

The size of the image when restored onto a persistent disk in gigabytes.

family str

The family name of the image.

id str

The provider-assigned unique ID for this managed resource.

image_encryption_key_sha256 str

The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.

image_id str

The unique identifier for the image.

label_fingerprint str

A fingerprint for the labels being applied to this image.

labels Mapping[str, str]

A map of labels applied to this image.

licenses Sequence[str]

A list of applicable license URI.

name str

The name of the image.

project str
self_link str

The URI of the image.

source_disk str

The URL of the source disk used to create this image.

source_disk_encryption_key_sha256 str

The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.

source_disk_id str

The ID value of the disk used to create this image.

source_image_id str

The ID value of the image used to create this image.

status str

The status of the image. Possible values are FAILED, PENDING, or READY.

filter str
archiveSizeBytes Number

The size of the image tar.gz archive stored in Google Cloud Storage in bytes.

creationTimestamp String

The creation timestamp in RFC3339 text format.

description String

An optional description of this image.

diskSizeGb Number

The size of the image when restored onto a persistent disk in gigabytes.

family String

The family name of the image.

id String

The provider-assigned unique ID for this managed resource.

imageEncryptionKeySha256 String

The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.

imageId String

The unique identifier for the image.

labelFingerprint String

A fingerprint for the labels being applied to this image.

labels Map<String>

A map of labels applied to this image.

licenses List<String>

A list of applicable license URI.

name String

The name of the image.

project String
selfLink String

The URI of the image.

sourceDisk String

The URL of the source disk used to create this image.

sourceDiskEncryptionKeySha256 String

The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.

sourceDiskId String

The ID value of the disk used to create this image.

sourceImageId String

The ID value of the image used to create this image.

status String

The status of the image. Possible values are FAILED, PENDING, or READY.

filter String

Package Details

Repository
https://github.com/pulumi/pulumi-gcp
License
Apache-2.0
Notes

This Pulumi package is based on the google-beta Terraform Provider.