Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi
gcp.compute.getImage
Explore with Pulumi AI
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={
"initialize_params": {
"image": my_image.self_link,
},
})
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 {
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
- Most
Recent bool - A boolean to indicate either to take to most recent image if your filter returns more than one image.
- Name string
- ,
family
orfilter
- (Required) The name of a specific image or a family. Exactly one ofname
,family
orfilter
must be specified. Ifname
is specified, it will fetch the corresponding image. Iffamily
is specified, it will return the latest image that is part of an image family and is not deprecated. If you specifyfilter
, your filter must return exactly one image unless you usemost_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
- Most
Recent bool - A boolean to indicate either to take to most recent image if your filter returns more than one image.
- Name string
- ,
family
orfilter
- (Required) The name of a specific image or a family. Exactly one ofname
,family
orfilter
must be specified. Ifname
is specified, it will fetch the corresponding image. Iffamily
is specified, it will return the latest image that is part of an image family and is not deprecated. If you specifyfilter
, your filter must return exactly one image unless you usemost_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
- most
Recent Boolean - A boolean to indicate either to take to most recent image if your filter returns more than one image.
- name String
- ,
family
orfilter
- (Required) The name of a specific image or a family. Exactly one ofname
,family
orfilter
must be specified. Ifname
is specified, it will fetch the corresponding image. Iffamily
is specified, it will return the latest image that is part of an image family and is not deprecated. If you specifyfilter
, your filter must return exactly one image unless you usemost_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
- most
Recent boolean - A boolean to indicate either to take to most recent image if your filter returns more than one image.
- name string
- ,
family
orfilter
- (Required) The name of a specific image or a family. Exactly one ofname
,family
orfilter
must be specified. Ifname
is specified, it will fetch the corresponding image. Iffamily
is specified, it will return the latest image that is part of an image family and is not deprecated. If you specifyfilter
, your filter must return exactly one image unless you usemost_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
orfilter
- (Required) The name of a specific image or a family. Exactly one ofname
,family
orfilter
must be specified. Ifname
is specified, it will fetch the corresponding image. Iffamily
is specified, it will return the latest image that is part of an image family and is not deprecated. If you specifyfilter
, your filter must return exactly one image unless you usemost_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
- most
Recent Boolean - A boolean to indicate either to take to most recent image if your filter returns more than one image.
- name String
- ,
family
orfilter
- (Required) The name of a specific image or a family. Exactly one ofname
,family
orfilter
must be specified. Ifname
is specified, it will fetch the corresponding image. Iffamily
is specified, it will return the latest image that is part of an image family and is not deprecated. If you specifyfilter
, your filter must return exactly one image unless you usemost_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:
- 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.
- Id string
- The provider-assigned unique ID for this managed resource.
- Image
Encryption stringKey Sha256 - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.
- Image
Id string - The unique identifier for the image.
- Label
Fingerprint 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
- Self
Link string - The URI of the image.
- Source
Disk string - The URL of the source disk used to create this image.
- Source
Disk stringEncryption Key Sha256 - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects 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.
- Status string
- The status of the image. Possible values are FAILED, PENDING, or READY.
- Filter string
- Most
Recent bool
- 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.
- Id string
- The provider-assigned unique ID for this managed resource.
- Image
Encryption stringKey Sha256 - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.
- Image
Id string - The unique identifier for the image.
- Label
Fingerprint 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
- Self
Link string - The URI of the image.
- Source
Disk string - The URL of the source disk used to create this image.
- Source
Disk stringEncryption Key Sha256 - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects 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.
- Status string
- The status of the image. Possible values are FAILED, PENDING, or READY.
- Filter string
- Most
Recent bool
- 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.
- id String
- The provider-assigned unique ID for this managed resource.
- image
Encryption StringKey Sha256 - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.
- image
Id String - The unique identifier for the image.
- label
Fingerprint 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
- self
Link String - The URI of the image.
- source
Disk String - The URL of the source disk used to create this image.
- source
Disk StringEncryption Key Sha256 - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects 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.
- status String
- The status of the image. Possible values are FAILED, PENDING, or READY.
- filter String
- most
Recent Boolean
- 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.
- id string
- The provider-assigned unique ID for this managed resource.
- image
Encryption stringKey Sha256 - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.
- image
Id string - The unique identifier for the image.
- label
Fingerprint 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
- self
Link string - The URI of the image.
- source
Disk string - The URL of the source disk used to create this image.
- source
Disk stringEncryption Key Sha256 - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects 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.
- status string
- The status of the image. Possible values are FAILED, PENDING, or READY.
- filter string
- most
Recent boolean
- 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.
- id str
- The provider-assigned unique ID for this managed resource.
- image_
encryption_ strkey_ sha256 - 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_ strencryption_ key_ sha256 - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects 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.
- status str
- The status of the image. Possible values are FAILED, PENDING, or READY.
- filter str
- most_
recent bool
- 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.
- id String
- The provider-assigned unique ID for this managed resource.
- image
Encryption StringKey Sha256 - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this image.
- image
Id String - The unique identifier for the image.
- label
Fingerprint 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
- self
Link String - The URI of the image.
- source
Disk String - The URL of the source disk used to create this image.
- source
Disk StringEncryption Key Sha256 - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects 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.
- status String
- The status of the image. Possible values are FAILED, PENDING, or READY.
- filter String
- most
Recent 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.