1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. MachineImage
Google Cloud v8.26.0 published on Thursday, Apr 10, 2025 by Pulumi

gcp.compute.MachineImage

Explore with Pulumi AI

Represents a Machine Image resource. Machine images store all the configuration, metadata, permissions, and data from one or more disks required to create a Virtual machine (VM) instance.

To get more information about MachineImage, see:

Example Usage

Machine Image Basic

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const vm = new gcp.compute.Instance("vm", {
    name: "my-vm",
    machineType: "e2-medium",
    bootDisk: {
        initializeParams: {
            image: "debian-cloud/debian-11",
        },
    },
    networkInterfaces: [{
        network: "default",
    }],
});
const image = new gcp.compute.MachineImage("image", {
    name: "my-image",
    sourceInstance: vm.selfLink,
});
Copy
import pulumi
import pulumi_gcp as gcp

vm = gcp.compute.Instance("vm",
    name="my-vm",
    machine_type="e2-medium",
    boot_disk={
        "initialize_params": {
            "image": "debian-cloud/debian-11",
        },
    },
    network_interfaces=[{
        "network": "default",
    }])
image = gcp.compute.MachineImage("image",
    name="my-image",
    source_instance=vm.self_link)
Copy
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 {
		vm, err := compute.NewInstance(ctx, "vm", &compute.InstanceArgs{
			Name:        pulumi.String("my-vm"),
			MachineType: pulumi.String("e2-medium"),
			BootDisk: &compute.InstanceBootDiskArgs{
				InitializeParams: &compute.InstanceBootDiskInitializeParamsArgs{
					Image: pulumi.String("debian-cloud/debian-11"),
				},
			},
			NetworkInterfaces: compute.InstanceNetworkInterfaceArray{
				&compute.InstanceNetworkInterfaceArgs{
					Network: pulumi.String("default"),
				},
			},
		})
		if err != nil {
			return err
		}
		_, err = compute.NewMachineImage(ctx, "image", &compute.MachineImageArgs{
			Name:           pulumi.String("my-image"),
			SourceInstance: vm.SelfLink,
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var vm = new Gcp.Compute.Instance("vm", new()
    {
        Name = "my-vm",
        MachineType = "e2-medium",
        BootDisk = new Gcp.Compute.Inputs.InstanceBootDiskArgs
        {
            InitializeParams = new Gcp.Compute.Inputs.InstanceBootDiskInitializeParamsArgs
            {
                Image = "debian-cloud/debian-11",
            },
        },
        NetworkInterfaces = new[]
        {
            new Gcp.Compute.Inputs.InstanceNetworkInterfaceArgs
            {
                Network = "default",
            },
        },
    });

    var image = new Gcp.Compute.MachineImage("image", new()
    {
        Name = "my-image",
        SourceInstance = vm.SelfLink,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
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 com.pulumi.gcp.compute.MachineImage;
import com.pulumi.gcp.compute.MachineImageArgs;
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) {
        var vm = new Instance("vm", InstanceArgs.builder()
            .name("my-vm")
            .machineType("e2-medium")
            .bootDisk(InstanceBootDiskArgs.builder()
                .initializeParams(InstanceBootDiskInitializeParamsArgs.builder()
                    .image("debian-cloud/debian-11")
                    .build())
                .build())
            .networkInterfaces(InstanceNetworkInterfaceArgs.builder()
                .network("default")
                .build())
            .build());

        var image = new MachineImage("image", MachineImageArgs.builder()
            .name("my-image")
            .sourceInstance(vm.selfLink())
            .build());

    }
}
Copy
resources:
  vm:
    type: gcp:compute:Instance
    properties:
      name: my-vm
      machineType: e2-medium
      bootDisk:
        initializeParams:
          image: debian-cloud/debian-11
      networkInterfaces:
        - network: default
  image:
    type: gcp:compute:MachineImage
    properties:
      name: my-image
      sourceInstance: ${vm.selfLink}
Copy

Compute Machine Image Kms

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const vm = new gcp.compute.Instance("vm", {
    name: "my-vm",
    machineType: "e2-medium",
    bootDisk: {
        initializeParams: {
            image: "debian-cloud/debian-11",
        },
    },
    networkInterfaces: [{
        network: "default",
    }],
});
const keyRing = new gcp.kms.KeyRing("key_ring", {
    name: "keyring",
    location: "us",
});
const cryptoKey = new gcp.kms.CryptoKey("crypto_key", {
    name: "key",
    keyRing: keyRing.id,
});
const image = new gcp.compute.MachineImage("image", {
    name: "my-image",
    sourceInstance: vm.selfLink,
    machineImageEncryptionKey: {
        kmsKeyName: cryptoKey.id,
    },
});
Copy
import pulumi
import pulumi_gcp as gcp

vm = gcp.compute.Instance("vm",
    name="my-vm",
    machine_type="e2-medium",
    boot_disk={
        "initialize_params": {
            "image": "debian-cloud/debian-11",
        },
    },
    network_interfaces=[{
        "network": "default",
    }])
key_ring = gcp.kms.KeyRing("key_ring",
    name="keyring",
    location="us")
crypto_key = gcp.kms.CryptoKey("crypto_key",
    name="key",
    key_ring=key_ring.id)
image = gcp.compute.MachineImage("image",
    name="my-image",
    source_instance=vm.self_link,
    machine_image_encryption_key={
        "kms_key_name": crypto_key.id,
    })
Copy
package main

import (
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/compute"
	"github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/kms"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		vm, err := compute.NewInstance(ctx, "vm", &compute.InstanceArgs{
			Name:        pulumi.String("my-vm"),
			MachineType: pulumi.String("e2-medium"),
			BootDisk: &compute.InstanceBootDiskArgs{
				InitializeParams: &compute.InstanceBootDiskInitializeParamsArgs{
					Image: pulumi.String("debian-cloud/debian-11"),
				},
			},
			NetworkInterfaces: compute.InstanceNetworkInterfaceArray{
				&compute.InstanceNetworkInterfaceArgs{
					Network: pulumi.String("default"),
				},
			},
		})
		if err != nil {
			return err
		}
		keyRing, err := kms.NewKeyRing(ctx, "key_ring", &kms.KeyRingArgs{
			Name:     pulumi.String("keyring"),
			Location: pulumi.String("us"),
		})
		if err != nil {
			return err
		}
		cryptoKey, err := kms.NewCryptoKey(ctx, "crypto_key", &kms.CryptoKeyArgs{
			Name:    pulumi.String("key"),
			KeyRing: keyRing.ID(),
		})
		if err != nil {
			return err
		}
		_, err = compute.NewMachineImage(ctx, "image", &compute.MachineImageArgs{
			Name:           pulumi.String("my-image"),
			SourceInstance: vm.SelfLink,
			MachineImageEncryptionKey: &compute.MachineImageMachineImageEncryptionKeyArgs{
				KmsKeyName: cryptoKey.ID(),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Gcp = Pulumi.Gcp;

return await Deployment.RunAsync(() => 
{
    var vm = new Gcp.Compute.Instance("vm", new()
    {
        Name = "my-vm",
        MachineType = "e2-medium",
        BootDisk = new Gcp.Compute.Inputs.InstanceBootDiskArgs
        {
            InitializeParams = new Gcp.Compute.Inputs.InstanceBootDiskInitializeParamsArgs
            {
                Image = "debian-cloud/debian-11",
            },
        },
        NetworkInterfaces = new[]
        {
            new Gcp.Compute.Inputs.InstanceNetworkInterfaceArgs
            {
                Network = "default",
            },
        },
    });

    var keyRing = new Gcp.Kms.KeyRing("key_ring", new()
    {
        Name = "keyring",
        Location = "us",
    });

    var cryptoKey = new Gcp.Kms.CryptoKey("crypto_key", new()
    {
        Name = "key",
        KeyRing = keyRing.Id,
    });

    var image = new Gcp.Compute.MachineImage("image", new()
    {
        Name = "my-image",
        SourceInstance = vm.SelfLink,
        MachineImageEncryptionKey = new Gcp.Compute.Inputs.MachineImageMachineImageEncryptionKeyArgs
        {
            KmsKeyName = cryptoKey.Id,
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
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 com.pulumi.gcp.kms.KeyRing;
import com.pulumi.gcp.kms.KeyRingArgs;
import com.pulumi.gcp.kms.CryptoKey;
import com.pulumi.gcp.kms.CryptoKeyArgs;
import com.pulumi.gcp.compute.MachineImage;
import com.pulumi.gcp.compute.MachineImageArgs;
import com.pulumi.gcp.compute.inputs.MachineImageMachineImageEncryptionKeyArgs;
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) {
        var vm = new Instance("vm", InstanceArgs.builder()
            .name("my-vm")
            .machineType("e2-medium")
            .bootDisk(InstanceBootDiskArgs.builder()
                .initializeParams(InstanceBootDiskInitializeParamsArgs.builder()
                    .image("debian-cloud/debian-11")
                    .build())
                .build())
            .networkInterfaces(InstanceNetworkInterfaceArgs.builder()
                .network("default")
                .build())
            .build());

        var keyRing = new KeyRing("keyRing", KeyRingArgs.builder()
            .name("keyring")
            .location("us")
            .build());

        var cryptoKey = new CryptoKey("cryptoKey", CryptoKeyArgs.builder()
            .name("key")
            .keyRing(keyRing.id())
            .build());

        var image = new MachineImage("image", MachineImageArgs.builder()
            .name("my-image")
            .sourceInstance(vm.selfLink())
            .machineImageEncryptionKey(MachineImageMachineImageEncryptionKeyArgs.builder()
                .kmsKeyName(cryptoKey.id())
                .build())
            .build());

    }
}
Copy
resources:
  vm:
    type: gcp:compute:Instance
    properties:
      name: my-vm
      machineType: e2-medium
      bootDisk:
        initializeParams:
          image: debian-cloud/debian-11
      networkInterfaces:
        - network: default
  image:
    type: gcp:compute:MachineImage
    properties:
      name: my-image
      sourceInstance: ${vm.selfLink}
      machineImageEncryptionKey:
        kmsKeyName: ${cryptoKey.id}
  cryptoKey:
    type: gcp:kms:CryptoKey
    name: crypto_key
    properties:
      name: key
      keyRing: ${keyRing.id}
  keyRing:
    type: gcp:kms:KeyRing
    name: key_ring
    properties:
      name: keyring
      location: us
Copy

Create MachineImage Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new MachineImage(name: string, args: MachineImageArgs, opts?: CustomResourceOptions);
@overload
def MachineImage(resource_name: str,
                 args: MachineImageArgs,
                 opts: Optional[ResourceOptions] = None)

@overload
def MachineImage(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 source_instance: Optional[str] = None,
                 description: Optional[str] = None,
                 guest_flush: Optional[bool] = None,
                 machine_image_encryption_key: Optional[MachineImageMachineImageEncryptionKeyArgs] = None,
                 name: Optional[str] = None,
                 project: Optional[str] = None)
func NewMachineImage(ctx *Context, name string, args MachineImageArgs, opts ...ResourceOption) (*MachineImage, error)
public MachineImage(string name, MachineImageArgs args, CustomResourceOptions? opts = null)
public MachineImage(String name, MachineImageArgs args)
public MachineImage(String name, MachineImageArgs args, CustomResourceOptions options)
type: gcp:compute:MachineImage
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. MachineImageArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. MachineImageArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. MachineImageArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. MachineImageArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. MachineImageArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var machineImageResource = new Gcp.Compute.MachineImage("machineImageResource", new()
{
    SourceInstance = "string",
    Description = "string",
    GuestFlush = false,
    MachineImageEncryptionKey = new Gcp.Compute.Inputs.MachineImageMachineImageEncryptionKeyArgs
    {
        KmsKeyName = "string",
        KmsKeyServiceAccount = "string",
        RawKey = "string",
        Sha256 = "string",
    },
    Name = "string",
    Project = "string",
});
Copy
example, err := compute.NewMachineImage(ctx, "machineImageResource", &compute.MachineImageArgs{
	SourceInstance: pulumi.String("string"),
	Description:    pulumi.String("string"),
	GuestFlush:     pulumi.Bool(false),
	MachineImageEncryptionKey: &compute.MachineImageMachineImageEncryptionKeyArgs{
		KmsKeyName:           pulumi.String("string"),
		KmsKeyServiceAccount: pulumi.String("string"),
		RawKey:               pulumi.String("string"),
		Sha256:               pulumi.String("string"),
	},
	Name:    pulumi.String("string"),
	Project: pulumi.String("string"),
})
Copy
var machineImageResource = new MachineImage("machineImageResource", MachineImageArgs.builder()
    .sourceInstance("string")
    .description("string")
    .guestFlush(false)
    .machineImageEncryptionKey(MachineImageMachineImageEncryptionKeyArgs.builder()
        .kmsKeyName("string")
        .kmsKeyServiceAccount("string")
        .rawKey("string")
        .sha256("string")
        .build())
    .name("string")
    .project("string")
    .build());
Copy
machine_image_resource = gcp.compute.MachineImage("machineImageResource",
    source_instance="string",
    description="string",
    guest_flush=False,
    machine_image_encryption_key={
        "kms_key_name": "string",
        "kms_key_service_account": "string",
        "raw_key": "string",
        "sha256": "string",
    },
    name="string",
    project="string")
Copy
const machineImageResource = new gcp.compute.MachineImage("machineImageResource", {
    sourceInstance: "string",
    description: "string",
    guestFlush: false,
    machineImageEncryptionKey: {
        kmsKeyName: "string",
        kmsKeyServiceAccount: "string",
        rawKey: "string",
        sha256: "string",
    },
    name: "string",
    project: "string",
});
Copy
type: gcp:compute:MachineImage
properties:
    description: string
    guestFlush: false
    machineImageEncryptionKey:
        kmsKeyName: string
        kmsKeyServiceAccount: string
        rawKey: string
        sha256: string
    name: string
    project: string
    sourceInstance: string
Copy

MachineImage Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The MachineImage resource accepts the following input properties:

SourceInstance
This property is required.
Changes to this property will trigger replacement.
string
The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


Description Changes to this property will trigger replacement. string
A text description of the resource.
GuestFlush Changes to this property will trigger replacement. bool
Specify this to create an application consistent machine image by informing the OS to prepare for the snapshot process. Currently only supported on Windows instances using the Volume Shadow Copy Service (VSS).
MachineImageEncryptionKey Changes to this property will trigger replacement. MachineImageMachineImageEncryptionKey
Encrypts the machine image using a customer-supplied encryption key. After you encrypt a machine image with a customer-supplied key, you must provide the same key if you use the machine image later (e.g. to create a instance from the image) Structure is documented below.
Name Changes to this property will trigger replacement. string
Name of the resource.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
SourceInstance
This property is required.
Changes to this property will trigger replacement.
string
The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


Description Changes to this property will trigger replacement. string
A text description of the resource.
GuestFlush Changes to this property will trigger replacement. bool
Specify this to create an application consistent machine image by informing the OS to prepare for the snapshot process. Currently only supported on Windows instances using the Volume Shadow Copy Service (VSS).
MachineImageEncryptionKey Changes to this property will trigger replacement. MachineImageMachineImageEncryptionKeyArgs
Encrypts the machine image using a customer-supplied encryption key. After you encrypt a machine image with a customer-supplied key, you must provide the same key if you use the machine image later (e.g. to create a instance from the image) Structure is documented below.
Name Changes to this property will trigger replacement. string
Name of the resource.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
sourceInstance
This property is required.
Changes to this property will trigger replacement.
String
The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


description Changes to this property will trigger replacement. String
A text description of the resource.
guestFlush Changes to this property will trigger replacement. Boolean
Specify this to create an application consistent machine image by informing the OS to prepare for the snapshot process. Currently only supported on Windows instances using the Volume Shadow Copy Service (VSS).
machineImageEncryptionKey Changes to this property will trigger replacement. MachineImageMachineImageEncryptionKey
Encrypts the machine image using a customer-supplied encryption key. After you encrypt a machine image with a customer-supplied key, you must provide the same key if you use the machine image later (e.g. to create a instance from the image) Structure is documented below.
name Changes to this property will trigger replacement. String
Name of the resource.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
sourceInstance
This property is required.
Changes to this property will trigger replacement.
string
The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


description Changes to this property will trigger replacement. string
A text description of the resource.
guestFlush Changes to this property will trigger replacement. boolean
Specify this to create an application consistent machine image by informing the OS to prepare for the snapshot process. Currently only supported on Windows instances using the Volume Shadow Copy Service (VSS).
machineImageEncryptionKey Changes to this property will trigger replacement. MachineImageMachineImageEncryptionKey
Encrypts the machine image using a customer-supplied encryption key. After you encrypt a machine image with a customer-supplied key, you must provide the same key if you use the machine image later (e.g. to create a instance from the image) Structure is documented below.
name Changes to this property will trigger replacement. string
Name of the resource.
project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
source_instance
This property is required.
Changes to this property will trigger replacement.
str
The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


description Changes to this property will trigger replacement. str
A text description of the resource.
guest_flush Changes to this property will trigger replacement. bool
Specify this to create an application consistent machine image by informing the OS to prepare for the snapshot process. Currently only supported on Windows instances using the Volume Shadow Copy Service (VSS).
machine_image_encryption_key Changes to this property will trigger replacement. MachineImageMachineImageEncryptionKeyArgs
Encrypts the machine image using a customer-supplied encryption key. After you encrypt a machine image with a customer-supplied key, you must provide the same key if you use the machine image later (e.g. to create a instance from the image) Structure is documented below.
name Changes to this property will trigger replacement. str
Name of the resource.
project Changes to this property will trigger replacement. str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
sourceInstance
This property is required.
Changes to this property will trigger replacement.
String
The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


description Changes to this property will trigger replacement. String
A text description of the resource.
guestFlush Changes to this property will trigger replacement. Boolean
Specify this to create an application consistent machine image by informing the OS to prepare for the snapshot process. Currently only supported on Windows instances using the Volume Shadow Copy Service (VSS).
machineImageEncryptionKey Changes to this property will trigger replacement. Property Map
Encrypts the machine image using a customer-supplied encryption key. After you encrypt a machine image with a customer-supplied key, you must provide the same key if you use the machine image later (e.g. to create a instance from the image) Structure is documented below.
name Changes to this property will trigger replacement. String
Name of the resource.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.

Outputs

All input properties are implicitly available as output properties. Additionally, the MachineImage resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
SelfLink string
The URI of the created resource.
StorageLocations List<string>
The regional or multi-regional Cloud Storage bucket location where the machine image is stored.
Id string
The provider-assigned unique ID for this managed resource.
SelfLink string
The URI of the created resource.
StorageLocations []string
The regional or multi-regional Cloud Storage bucket location where the machine image is stored.
id String
The provider-assigned unique ID for this managed resource.
selfLink String
The URI of the created resource.
storageLocations List<String>
The regional or multi-regional Cloud Storage bucket location where the machine image is stored.
id string
The provider-assigned unique ID for this managed resource.
selfLink string
The URI of the created resource.
storageLocations string[]
The regional or multi-regional Cloud Storage bucket location where the machine image is stored.
id str
The provider-assigned unique ID for this managed resource.
self_link str
The URI of the created resource.
storage_locations Sequence[str]
The regional or multi-regional Cloud Storage bucket location where the machine image is stored.
id String
The provider-assigned unique ID for this managed resource.
selfLink String
The URI of the created resource.
storageLocations List<String>
The regional or multi-regional Cloud Storage bucket location where the machine image is stored.

Look up Existing MachineImage Resource

Get an existing MachineImage resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: MachineImageState, opts?: CustomResourceOptions): MachineImage
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        description: Optional[str] = None,
        guest_flush: Optional[bool] = None,
        machine_image_encryption_key: Optional[MachineImageMachineImageEncryptionKeyArgs] = None,
        name: Optional[str] = None,
        project: Optional[str] = None,
        self_link: Optional[str] = None,
        source_instance: Optional[str] = None,
        storage_locations: Optional[Sequence[str]] = None) -> MachineImage
func GetMachineImage(ctx *Context, name string, id IDInput, state *MachineImageState, opts ...ResourceOption) (*MachineImage, error)
public static MachineImage Get(string name, Input<string> id, MachineImageState? state, CustomResourceOptions? opts = null)
public static MachineImage get(String name, Output<String> id, MachineImageState state, CustomResourceOptions options)
resources:  _:    type: gcp:compute:MachineImage    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Description Changes to this property will trigger replacement. string
A text description of the resource.
GuestFlush Changes to this property will trigger replacement. bool
Specify this to create an application consistent machine image by informing the OS to prepare for the snapshot process. Currently only supported on Windows instances using the Volume Shadow Copy Service (VSS).
MachineImageEncryptionKey Changes to this property will trigger replacement. MachineImageMachineImageEncryptionKey
Encrypts the machine image using a customer-supplied encryption key. After you encrypt a machine image with a customer-supplied key, you must provide the same key if you use the machine image later (e.g. to create a instance from the image) Structure is documented below.
Name Changes to this property will trigger replacement. string
Name of the resource.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
SelfLink string
The URI of the created resource.
SourceInstance Changes to this property will trigger replacement. string
The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


StorageLocations List<string>
The regional or multi-regional Cloud Storage bucket location where the machine image is stored.
Description Changes to this property will trigger replacement. string
A text description of the resource.
GuestFlush Changes to this property will trigger replacement. bool
Specify this to create an application consistent machine image by informing the OS to prepare for the snapshot process. Currently only supported on Windows instances using the Volume Shadow Copy Service (VSS).
MachineImageEncryptionKey Changes to this property will trigger replacement. MachineImageMachineImageEncryptionKeyArgs
Encrypts the machine image using a customer-supplied encryption key. After you encrypt a machine image with a customer-supplied key, you must provide the same key if you use the machine image later (e.g. to create a instance from the image) Structure is documented below.
Name Changes to this property will trigger replacement. string
Name of the resource.
Project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
SelfLink string
The URI of the created resource.
SourceInstance Changes to this property will trigger replacement. string
The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


StorageLocations []string
The regional or multi-regional Cloud Storage bucket location where the machine image is stored.
description Changes to this property will trigger replacement. String
A text description of the resource.
guestFlush Changes to this property will trigger replacement. Boolean
Specify this to create an application consistent machine image by informing the OS to prepare for the snapshot process. Currently only supported on Windows instances using the Volume Shadow Copy Service (VSS).
machineImageEncryptionKey Changes to this property will trigger replacement. MachineImageMachineImageEncryptionKey
Encrypts the machine image using a customer-supplied encryption key. After you encrypt a machine image with a customer-supplied key, you must provide the same key if you use the machine image later (e.g. to create a instance from the image) Structure is documented below.
name Changes to this property will trigger replacement. String
Name of the resource.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
selfLink String
The URI of the created resource.
sourceInstance Changes to this property will trigger replacement. String
The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


storageLocations List<String>
The regional or multi-regional Cloud Storage bucket location where the machine image is stored.
description Changes to this property will trigger replacement. string
A text description of the resource.
guestFlush Changes to this property will trigger replacement. boolean
Specify this to create an application consistent machine image by informing the OS to prepare for the snapshot process. Currently only supported on Windows instances using the Volume Shadow Copy Service (VSS).
machineImageEncryptionKey Changes to this property will trigger replacement. MachineImageMachineImageEncryptionKey
Encrypts the machine image using a customer-supplied encryption key. After you encrypt a machine image with a customer-supplied key, you must provide the same key if you use the machine image later (e.g. to create a instance from the image) Structure is documented below.
name Changes to this property will trigger replacement. string
Name of the resource.
project Changes to this property will trigger replacement. string
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
selfLink string
The URI of the created resource.
sourceInstance Changes to this property will trigger replacement. string
The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


storageLocations string[]
The regional or multi-regional Cloud Storage bucket location where the machine image is stored.
description Changes to this property will trigger replacement. str
A text description of the resource.
guest_flush Changes to this property will trigger replacement. bool
Specify this to create an application consistent machine image by informing the OS to prepare for the snapshot process. Currently only supported on Windows instances using the Volume Shadow Copy Service (VSS).
machine_image_encryption_key Changes to this property will trigger replacement. MachineImageMachineImageEncryptionKeyArgs
Encrypts the machine image using a customer-supplied encryption key. After you encrypt a machine image with a customer-supplied key, you must provide the same key if you use the machine image later (e.g. to create a instance from the image) Structure is documented below.
name Changes to this property will trigger replacement. str
Name of the resource.
project Changes to this property will trigger replacement. str
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
self_link str
The URI of the created resource.
source_instance Changes to this property will trigger replacement. str
The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


storage_locations Sequence[str]
The regional or multi-regional Cloud Storage bucket location where the machine image is stored.
description Changes to this property will trigger replacement. String
A text description of the resource.
guestFlush Changes to this property will trigger replacement. Boolean
Specify this to create an application consistent machine image by informing the OS to prepare for the snapshot process. Currently only supported on Windows instances using the Volume Shadow Copy Service (VSS).
machineImageEncryptionKey Changes to this property will trigger replacement. Property Map
Encrypts the machine image using a customer-supplied encryption key. After you encrypt a machine image with a customer-supplied key, you must provide the same key if you use the machine image later (e.g. to create a instance from the image) Structure is documented below.
name Changes to this property will trigger replacement. String
Name of the resource.
project Changes to this property will trigger replacement. String
The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
selfLink String
The URI of the created resource.
sourceInstance Changes to this property will trigger replacement. String
The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


storageLocations List<String>
The regional or multi-regional Cloud Storage bucket location where the machine image is stored.

Supporting Types

MachineImageMachineImageEncryptionKey
, MachineImageMachineImageEncryptionKeyArgs

KmsKeyName Changes to this property will trigger replacement. string
The name of the encryption key that is stored in Google Cloud KMS.
KmsKeyServiceAccount Changes to this property will trigger replacement. string
The service account used for the encryption request for the given KMS key. If absent, the Compute Engine Service Agent service account is used.
RawKey Changes to this property will trigger replacement. string
Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource.
Sha256 string
(Output) The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this resource.
KmsKeyName Changes to this property will trigger replacement. string
The name of the encryption key that is stored in Google Cloud KMS.
KmsKeyServiceAccount Changes to this property will trigger replacement. string
The service account used for the encryption request for the given KMS key. If absent, the Compute Engine Service Agent service account is used.
RawKey Changes to this property will trigger replacement. string
Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource.
Sha256 string
(Output) The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this resource.
kmsKeyName Changes to this property will trigger replacement. String
The name of the encryption key that is stored in Google Cloud KMS.
kmsKeyServiceAccount Changes to this property will trigger replacement. String
The service account used for the encryption request for the given KMS key. If absent, the Compute Engine Service Agent service account is used.
rawKey Changes to this property will trigger replacement. String
Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource.
sha256 String
(Output) The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this resource.
kmsKeyName Changes to this property will trigger replacement. string
The name of the encryption key that is stored in Google Cloud KMS.
kmsKeyServiceAccount Changes to this property will trigger replacement. string
The service account used for the encryption request for the given KMS key. If absent, the Compute Engine Service Agent service account is used.
rawKey Changes to this property will trigger replacement. string
Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource.
sha256 string
(Output) The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this resource.
kms_key_name Changes to this property will trigger replacement. str
The name of the encryption key that is stored in Google Cloud KMS.
kms_key_service_account Changes to this property will trigger replacement. str
The service account used for the encryption request for the given KMS key. If absent, the Compute Engine Service Agent service account is used.
raw_key Changes to this property will trigger replacement. str
Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource.
sha256 str
(Output) The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this resource.
kmsKeyName Changes to this property will trigger replacement. String
The name of the encryption key that is stored in Google Cloud KMS.
kmsKeyServiceAccount Changes to this property will trigger replacement. String
The service account used for the encryption request for the given KMS key. If absent, the Compute Engine Service Agent service account is used.
rawKey Changes to this property will trigger replacement. String
Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648 base64 to either encrypt or decrypt this resource.
sha256 String
(Output) The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption key that protects this resource.

Import

MachineImage can be imported using any of these accepted formats:

  • projects/{{project}}/global/machineImages/{{name}}

  • {{project}}/{{name}}

  • {{name}}

When using the pulumi import command, MachineImage can be imported using one of the formats above. For example:

$ pulumi import gcp:compute/machineImage:MachineImage default projects/{{project}}/global/machineImages/{{name}}
Copy
$ pulumi import gcp:compute/machineImage:MachineImage default {{project}}/{{name}}
Copy
$ pulumi import gcp:compute/machineImage:MachineImage default {{name}}
Copy

To learn more about importing existing cloud resources, see Importing resources.

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.