1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. getImages
Google Cloud v8.29.0 published on Thursday, May 1, 2025 by Pulumi

gcp.compute.getImages

Explore with Pulumi AI

gcp logo
Google Cloud v8.29.0 published on Thursday, May 1, 2025 by Pulumi

    Get information about Google Compute Images. 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 debian = gcp.compute.getImages({
        filter: "name eq my-image.*",
    });
    const _default = new gcp.compute.Instance("default", {
        name: "test",
        machineType: "f1-micro",
        zone: "us-central1-a",
        bootDisk: {
            initializeParams: {
                image: debian.then(debian => debian.images?.[0]?.selfLink),
            },
        },
        networkInterfaces: [{
            network: defaultGoogleComputeNetwork.name,
        }],
    });
    
    import pulumi
    import pulumi_gcp as gcp
    
    debian = gcp.compute.get_images(filter="name eq my-image.*")
    default = gcp.compute.Instance("default",
        name="test",
        machine_type="f1-micro",
        zone="us-central1-a",
        boot_disk={
            "initialize_params": {
                "image": debian.images[0].self_link,
            },
        },
        network_interfaces=[{
            "network": default_google_compute_network["name"],
        }])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/compute"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		debian, err := compute.GetImages(ctx, &compute.GetImagesArgs{
    			Filter: pulumi.StringRef("name eq my-image.*"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		_, err = compute.NewInstance(ctx, "default", &compute.InstanceArgs{
    			Name:        pulumi.String("test"),
    			MachineType: pulumi.String("f1-micro"),
    			Zone:        pulumi.String("us-central1-a"),
    			BootDisk: &compute.InstanceBootDiskArgs{
    				InitializeParams: &compute.InstanceBootDiskInitializeParamsArgs{
    					Image: pulumi.String(debian.Images[0].SelfLink),
    				},
    			},
    			NetworkInterfaces: compute.InstanceNetworkInterfaceArray{
    				&compute.InstanceNetworkInterfaceArgs{
    					Network: pulumi.Any(defaultGoogleComputeNetwork.Name),
    				},
    			},
    		})
    		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 debian = Gcp.Compute.GetImages.Invoke(new()
        {
            Filter = "name eq my-image.*",
        });
    
        var @default = new Gcp.Compute.Instance("default", new()
        {
            Name = "test",
            MachineType = "f1-micro",
            Zone = "us-central1-a",
            BootDisk = new Gcp.Compute.Inputs.InstanceBootDiskArgs
            {
                InitializeParams = new Gcp.Compute.Inputs.InstanceBootDiskInitializeParamsArgs
                {
                    Image = debian.Apply(getImagesResult => getImagesResult.Images[0]?.SelfLink),
                },
            },
            NetworkInterfaces = new[]
            {
                new Gcp.Compute.Inputs.InstanceNetworkInterfaceArgs
                {
                    Network = defaultGoogleComputeNetwork.Name,
                },
            },
        });
    
    });
    
    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.GetImagesArgs;
    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 com.pulumi.gcp.compute.inputs.InstanceNetworkInterfaceArgs;
    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 debian = ComputeFunctions.getImages(GetImagesArgs.builder()
                .filter("name eq my-image.*")
                .build());
    
            var default_ = new Instance("default", InstanceArgs.builder()
                .name("test")
                .machineType("f1-micro")
                .zone("us-central1-a")
                .bootDisk(InstanceBootDiskArgs.builder()
                    .initializeParams(InstanceBootDiskInitializeParamsArgs.builder()
                        .image(debian.images()[0].selfLink())
                        .build())
                    .build())
                .networkInterfaces(InstanceNetworkInterfaceArgs.builder()
                    .network(defaultGoogleComputeNetwork.name())
                    .build())
                .build());
    
        }
    }
    
    resources:
      default:
        type: gcp:compute:Instance
        properties:
          name: test
          machineType: f1-micro
          zone: us-central1-a
          bootDisk:
            initializeParams:
              image: ${debian.images[0].selfLink}
          networkInterfaces:
            - network: ${defaultGoogleComputeNetwork.name}
    variables:
      debian:
        fn::invoke:
          function: gcp:compute:getImages
          arguments:
            filter: name eq my-image.*
    

    Using getImages

    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 getImages(args: GetImagesArgs, opts?: InvokeOptions): Promise<GetImagesResult>
    function getImagesOutput(args: GetImagesOutputArgs, opts?: InvokeOptions): Output<GetImagesResult>
    def get_images(filter: Optional[str] = None,
                   project: Optional[str] = None,
                   opts: Optional[InvokeOptions] = None) -> GetImagesResult
    def get_images_output(filter: Optional[pulumi.Input[str]] = None,
                   project: Optional[pulumi.Input[str]] = None,
                   opts: Optional[InvokeOptions] = None) -> Output[GetImagesResult]
    func GetImages(ctx *Context, args *GetImagesArgs, opts ...InvokeOption) (*GetImagesResult, error)
    func GetImagesOutput(ctx *Context, args *GetImagesOutputArgs, opts ...InvokeOption) GetImagesResultOutput

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

    public static class GetImages 
    {
        public static Task<GetImagesResult> InvokeAsync(GetImagesArgs args, InvokeOptions? opts = null)
        public static Output<GetImagesResult> Invoke(GetImagesInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetImagesResult> getImages(GetImagesArgs args, InvokeOptions options)
    public static Output<GetImagesResult> getImages(GetImagesArgs args, InvokeOptions options)
    
    fn::invoke:
      function: gcp:compute/getImages:getImages
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Filter string
    Filter for the images to be returned by the data source. 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.
    Filter string
    Filter for the images to be returned by the data source. 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.
    filter String
    Filter for the images to be returned by the data source. 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.
    filter string
    Filter for the images to be returned by the data source. 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.
    filter str
    Filter for the images to be returned by the data source. 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.
    filter String
    Filter for the images to be returned by the data source. 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.

    getImages Result

    The following output properties are available:

    Id string
    The provider-assigned unique ID for this managed resource.
    Images List<GetImagesImage>
    Filter string
    Project string
    Id string
    The provider-assigned unique ID for this managed resource.
    Images []GetImagesImage
    Filter string
    Project string
    id String
    The provider-assigned unique ID for this managed resource.
    images List<GetImagesImage>
    filter String
    project String
    id string
    The provider-assigned unique ID for this managed resource.
    images GetImagesImage[]
    filter string
    project string
    id str
    The provider-assigned unique ID for this managed resource.
    images Sequence[GetImagesImage]
    filter str
    project str
    id String
    The provider-assigned unique ID for this managed resource.
    images List<Property Map>
    filter String
    project String

    Supporting Types

    GetImagesImage

    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.
    ImageId int
    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.
    Name string
    The name of the image.
    SelfLink string
    The URI of the image.
    SourceDisk string
    The URL of the source disk used to create 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.
    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.
    ImageId int
    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.
    Name string
    The name of the image.
    SelfLink string
    The URI of the image.
    SourceDisk string
    The URL of the source disk used to create 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.
    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.
    imageId Integer
    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.
    name String
    The name of the image.
    selfLink String
    The URI of the image.
    sourceDisk String
    The URL of the source disk used to create 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.
    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.
    imageId number
    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.
    name string
    The name of the image.
    selfLink string
    The URI of the image.
    sourceDisk string
    The URL of the source disk used to create 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.
    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.
    image_id int
    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.
    name str
    The name of the image.
    self_link str
    The URI of the image.
    source_disk str
    The URL of the source disk used to create 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.
    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.
    imageId Number
    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.
    name String
    The name of the image.
    selfLink String
    The URI of the image.
    sourceDisk String
    The URL of the source disk used to create 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.

    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 v8.29.0 published on Thursday, May 1, 2025 by Pulumi