1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. getImage
Google Cloud Classic v7.27.0 published on Thursday, Jun 13, 2024 by Pulumi

gcp.compute.getImage

Explore with Pulumi AI

gcp logo
Google Cloud Classic v7.27.0 published on Thursday, Jun 13, 2024 by Pulumi

    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

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

    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,
                  most_recent: Optional[bool] = 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,
                  most_recent: Optional[pulumi.Input[bool]] = 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
    MostRecent bool
    A boolean to indicate either to take to most recent image if your filter returns more than one image.
    Name string
    , 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 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
    MostRecent bool
    A boolean to indicate either to take to most recent image if your filter returns more than one image.
    Name string
    , 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 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
    mostRecent Boolean
    A boolean to indicate either to take to most recent image if your filter returns more than one image.
    name String
    , 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 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
    mostRecent boolean
    A boolean to indicate either to take to most recent image if your filter returns more than one image.
    name string
    , 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 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
    most_recent bool
    A boolean to indicate either to take to most recent image if your filter returns more than one image.
    name str
    , 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 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
    mostRecent Boolean
    A boolean to indicate either to take to most recent image if your filter returns more than one image.
    name String
    , 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 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>
    All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
    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
    MostRecent bool
    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
    All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
    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
    MostRecent bool
    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>
    All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
    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
    mostRecent Boolean
    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}
    All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
    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
    mostRecent boolean
    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]
    All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
    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
    most_recent bool
    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>
    All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Pulumi, other clients and services.
    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
    mostRecent Boolean

    Package Details

    Repository
    Google Cloud (GCP) Classic pulumi/pulumi-gcp
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the google-beta Terraform Provider.
    gcp logo
    Google Cloud Classic v7.27.0 published on Thursday, Jun 13, 2024 by Pulumi