Google Cloud (GCP) Classic

v6.39.0 published on Wednesday, Sep 28, 2022 by Pulumi

getDisk

Get information about a Google Compute Persistent disks.

the official documentation and its API.

Example Usage

using System.Collections.Generic;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var persistent_boot_disk = Gcp.Compute.GetDisk.Invoke(new()
    {
        Name = "persistent-boot-disk",
        Project = "example",
    });

    // ...
    var @default = new Gcp.Compute.Instance("default", new()
    {
        BootDisk = new Gcp.Compute.Inputs.InstanceBootDiskArgs
        {
            Source = persistent_boot_disk.Apply(getDiskResult => getDiskResult).Apply(persistent_boot_disk => persistent_boot_disk.Apply(getDiskResult => getDiskResult.SelfLink)),
            AutoDelete = false,
        },
    });

});
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 {
		persistent_boot_disk, err := compute.LookupDisk(ctx, &compute.LookupDiskArgs{
			Name:    "persistent-boot-disk",
			Project: pulumi.StringRef("example"),
		}, nil)
		if err != nil {
			return err
		}
		_, err = compute.NewInstance(ctx, "default", &compute.InstanceArgs{
			BootDisk: &compute.InstanceBootDiskArgs{
				Source:     pulumi.String(persistent_boot_disk.SelfLink),
				AutoDelete: pulumi.Bool(false),
			},
		})
		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.GetDiskArgs;
import com.pulumi.gcp.compute.Instance;
import com.pulumi.gcp.compute.InstanceArgs;
import com.pulumi.gcp.compute.inputs.InstanceBootDiskArgs;
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 persistent-boot-disk = ComputeFunctions.getDisk(GetDiskArgs.builder()
            .name("persistent-boot-disk")
            .project("example")
            .build());

        var default_ = new Instance("default", InstanceArgs.builder()        
            .bootDisk(InstanceBootDiskArgs.builder()
                .source(persistent_boot_disk.selfLink())
                .autoDelete(false)
                .build())
            .build());

    }
}
import pulumi
import pulumi_gcp as gcp

persistent_boot_disk = gcp.compute.get_disk(name="persistent-boot-disk",
    project="example")
# ...
default = gcp.compute.Instance("default", boot_disk=gcp.compute.InstanceBootDiskArgs(
    source=persistent_boot_disk.self_link,
    auto_delete=False,
))
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const persistent-boot-disk = gcp.compute.getDisk({
    name: "persistent-boot-disk",
    project: "example",
});
// ...
const _default = new gcp.compute.Instance("default", {bootDisk: {
    source: persistent_boot_disk.then(persistent_boot_disk => persistent_boot_disk.selfLink),
    autoDelete: false,
}});
resources:
  default:
    type: gcp:compute:Instance
    properties:
      bootDisk:
        source: ${["persistent-boot-disk"].selfLink}
        autoDelete: false
variables:
  persistent-boot-disk:
    Fn::Invoke:
      Function: gcp:compute:getDisk
      Arguments:
        name: persistent-boot-disk
        project: example

Using getDisk

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 getDisk(args: GetDiskArgs, opts?: InvokeOptions): Promise<GetDiskResult>
function getDiskOutput(args: GetDiskOutputArgs, opts?: InvokeOptions): Output<GetDiskResult>
def get_disk(name: Optional[str] = None,
             project: Optional[str] = None,
             zone: Optional[str] = None,
             opts: Optional[InvokeOptions] = None) -> GetDiskResult
def get_disk_output(name: Optional[pulumi.Input[str]] = None,
             project: Optional[pulumi.Input[str]] = None,
             zone: Optional[pulumi.Input[str]] = None,
             opts: Optional[InvokeOptions] = None) -> Output[GetDiskResult]
func LookupDisk(ctx *Context, args *LookupDiskArgs, opts ...InvokeOption) (*LookupDiskResult, error)
func LookupDiskOutput(ctx *Context, args *LookupDiskOutputArgs, opts ...InvokeOption) LookupDiskResultOutput

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

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

The following arguments are supported:

Name string

The name of a specific disk.

Project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Zone string

A reference to the zone where the disk resides.

Name string

The name of a specific disk.

Project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Zone string

A reference to the zone where the disk resides.

name String

The name of a specific disk.

project String

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

zone String

A reference to the zone where the disk resides.

name string

The name of a specific disk.

project string

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

zone string

A reference to the zone where the disk resides.

name str

The name of a specific disk.

project str

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

zone str

A reference to the zone where the disk resides.

name String

The name of a specific disk.

project String

The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

zone String

A reference to the zone where the disk resides.

getDisk Result

The following output properties are available:

CreationTimestamp string
Description string
DiskEncryptionKeys List<GetDiskDiskEncryptionKey>
Id string

The provider-assigned unique ID for this managed resource.

Image string
Interface string
LabelFingerprint string
Labels Dictionary<string, string>

A map of labels applied to this disk.

LastAttachTimestamp string
LastDetachTimestamp string
MultiWriter bool
Name string
PhysicalBlockSizeBytes int
ProvisionedIops int
ResourcePolicies List<string>
SelfLink string

The URI of the created resource.

Size int
Snapshot string
SourceImageEncryptionKeys List<GetDiskSourceImageEncryptionKey>
SourceImageId string
SourceSnapshotEncryptionKeys List<GetDiskSourceSnapshotEncryptionKey>
SourceSnapshotId string
Type string
Users List<string>
Project string
Zone string
CreationTimestamp string
Description string
DiskEncryptionKeys []GetDiskDiskEncryptionKey
Id string

The provider-assigned unique ID for this managed resource.

Image string
Interface string
LabelFingerprint string
Labels map[string]string

A map of labels applied to this disk.

LastAttachTimestamp string
LastDetachTimestamp string
MultiWriter bool
Name string
PhysicalBlockSizeBytes int
ProvisionedIops int
ResourcePolicies []string
SelfLink string

The URI of the created resource.

Size int
Snapshot string
SourceImageEncryptionKeys []GetDiskSourceImageEncryptionKey
SourceImageId string
SourceSnapshotEncryptionKeys []GetDiskSourceSnapshotEncryptionKey
SourceSnapshotId string
Type string
Users []string
Project string
Zone string
creationTimestamp String
description String
diskEncryptionKeys List<GetDiskDiskEncryptionKey>
id String

The provider-assigned unique ID for this managed resource.

image String
interface_ String
labelFingerprint String
labels Map<String,String>

A map of labels applied to this disk.

lastAttachTimestamp String
lastDetachTimestamp String
multiWriter Boolean
name String
physicalBlockSizeBytes Integer
provisionedIops Integer
resourcePolicies List<String>
selfLink String

The URI of the created resource.

size Integer
snapshot String
sourceImageEncryptionKeys List<GetDiskSourceImageEncryptionKey>
sourceImageId String
sourceSnapshotEncryptionKeys List<GetDiskSourceSnapshotEncryptionKey>
sourceSnapshotId String
type String
users List<String>
project String
zone String
creationTimestamp string
description string
diskEncryptionKeys GetDiskDiskEncryptionKey[]
id string

The provider-assigned unique ID for this managed resource.

image string
interface string
labelFingerprint string
labels {[key: string]: string}

A map of labels applied to this disk.

lastAttachTimestamp string
lastDetachTimestamp string
multiWriter boolean
name string
physicalBlockSizeBytes number
provisionedIops number
resourcePolicies string[]
selfLink string

The URI of the created resource.

size number
snapshot string
sourceImageEncryptionKeys GetDiskSourceImageEncryptionKey[]
sourceImageId string
sourceSnapshotEncryptionKeys GetDiskSourceSnapshotEncryptionKey[]
sourceSnapshotId string
type string
users string[]
project string
zone string
creationTimestamp String
description String
diskEncryptionKeys List<Property Map>
id String

The provider-assigned unique ID for this managed resource.

image String
interface String
labelFingerprint String
labels Map<String>

A map of labels applied to this disk.

lastAttachTimestamp String
lastDetachTimestamp String
multiWriter Boolean
name String
physicalBlockSizeBytes Number
provisionedIops Number
resourcePolicies List<String>
selfLink String

The URI of the created resource.

size Number
snapshot String
sourceImageEncryptionKeys List<Property Map>
sourceImageId String
sourceSnapshotEncryptionKeys List<Property Map>
sourceSnapshotId String
type String
users List<String>
project String
zone String

Supporting Types

GetDiskDiskEncryptionKey

GetDiskSourceImageEncryptionKey

GetDiskSourceSnapshotEncryptionKey

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.