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/v9/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 dictionaryThe 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<Get
Images Image> - Filter string
- Project string
- Id string
- The provider-assigned unique ID for this managed resource.
- Images
[]Get
Images Image - Filter string
- Project string
- id String
- The provider-assigned unique ID for this managed resource.
- images
List<Get
Images Image> - filter String
- project String
- id string
- The provider-assigned unique ID for this managed resource.
- images
Get
Images Image[] - filter string
- project string
- id str
- The provider-assigned unique ID for this managed resource.
- images
Sequence[Get
Images Image] - 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
- Archive
Size intBytes - The size of the image tar.gz archive stored in Google Cloud Storage in bytes.
- Creation
Timestamp string - The creation timestamp in RFC3339 text format.
- Description string
- An optional description of this image.
- Disk
Size intGb - The size of the image when restored onto a persistent disk in gigabytes.
- Family string
- The family name of the image.
- Image
Id 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.
- Self
Link string - The URI of the image.
- Source
Disk string - The URL of the source disk used to create this image.
- Source
Disk stringId - The ID value of the disk used to create this image.
- Source
Image stringId - The ID value of the image used to create this image.
- Archive
Size intBytes - The size of the image tar.gz archive stored in Google Cloud Storage in bytes.
- Creation
Timestamp string - The creation timestamp in RFC3339 text format.
- Description string
- An optional description of this image.
- Disk
Size intGb - The size of the image when restored onto a persistent disk in gigabytes.
- Family string
- The family name of the image.
- Image
Id 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.
- Self
Link string - The URI of the image.
- Source
Disk string - The URL of the source disk used to create this image.
- Source
Disk stringId - The ID value of the disk used to create this image.
- Source
Image stringId - The ID value of the image used to create this image.
- archive
Size IntegerBytes - The size of the image tar.gz archive stored in Google Cloud Storage in bytes.
- creation
Timestamp String - The creation timestamp in RFC3339 text format.
- description String
- An optional description of this image.
- disk
Size IntegerGb - The size of the image when restored onto a persistent disk in gigabytes.
- family String
- The family name of the image.
- image
Id 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.
- self
Link String - The URI of the image.
- source
Disk String - The URL of the source disk used to create this image.
- source
Disk StringId - The ID value of the disk used to create this image.
- source
Image StringId - The ID value of the image used to create this image.
- archive
Size numberBytes - The size of the image tar.gz archive stored in Google Cloud Storage in bytes.
- creation
Timestamp string - The creation timestamp in RFC3339 text format.
- description string
- An optional description of this image.
- disk
Size numberGb - The size of the image when restored onto a persistent disk in gigabytes.
- family string
- The family name of the image.
- image
Id 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.
- self
Link string - The URI of the image.
- source
Disk string - The URL of the source disk used to create this image.
- source
Disk stringId - The ID value of the disk used to create this image.
- source
Image stringId - The ID value of the image used to create this image.
- archive_
size_ intbytes - 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_ intgb - 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_ strid - The ID value of the disk used to create this image.
- source_
image_ strid - The ID value of the image used to create this image.
- archive
Size NumberBytes - The size of the image tar.gz archive stored in Google Cloud Storage in bytes.
- creation
Timestamp String - The creation timestamp in RFC3339 text format.
- description String
- An optional description of this image.
- disk
Size NumberGb - The size of the image when restored onto a persistent disk in gigabytes.
- family String
- The family name of the image.
- image
Id 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.
- self
Link String - The URI of the image.
- source
Disk String - The URL of the source disk used to create this image.
- source
Disk StringId - The ID value of the disk used to create this image.
- source
Image StringId - 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-betaTerraform Provider.
