1. Packages
  2. Google Cloud (GCP) Classic
  3. API Docs
  4. compute
  5. MachineImage
Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi

gcp.compute.MachineImage

Explore with Pulumi AI

gcp logo
Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi

    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,
    });
    
    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)
    
    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
    	})
    }
    
    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,
        });
    
    });
    
    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());
    
        }
    }
    
    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}
    

    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,
        },
    });
    
    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,
        })
    
    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
    	})
    }
    
    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,
            },
        });
    
    });
    
    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());
    
        }
    }
    
    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
    

    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 string
    The unique name of the resource.
    args MachineImageArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args 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 string
    The unique name of the resource.
    args MachineImageArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args MachineImageArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args 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",
    });
    
    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"),
    })
    
    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());
    
    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")
    
    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",
    });
    
    type: gcp:compute:MachineImage
    properties:
        description: string
        guestFlush: false
        machineImageEncryptionKey:
            kmsKeyName: string
            kmsKeyServiceAccount: string
            rawKey: string
            sha256: string
        name: string
        project: string
        sourceInstance: string
    

    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 string
    The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


    Description string
    A text description of the resource.
    GuestFlush 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 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 string
    Name of the resource.
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    SourceInstance string
    The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


    Description string
    A text description of the resource.
    GuestFlush 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 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 string
    Name of the resource.
    Project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    sourceInstance String
    The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


    description String
    A text description of the resource.
    guestFlush 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 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 String
    Name of the resource.
    project String
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    sourceInstance string
    The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


    description string
    A text description of the resource.
    guestFlush 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 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 string
    Name of the resource.
    project string
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    source_instance str
    The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


    description str
    A text description of the resource.
    guest_flush 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 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 str
    Name of the resource.
    project str
    The ID of the project in which the resource belongs. If it is not provided, the provider project is used.
    sourceInstance String
    The source instance used to create the machine image. You can provide this as a partial or full URL to the resource.


    description String
    A text description of the resource.
    guestFlush 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 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 String
    Name of the resource.
    project 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)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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 string
    A text description of the resource.
    GuestFlush 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 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 string
    Name of the resource.
    Project 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 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 string
    A text description of the resource.
    GuestFlush 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 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 string
    Name of the resource.
    Project 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 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 String
    A text description of the resource.
    guestFlush 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 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 String
    Name of the resource.
    project 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 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 string
    A text description of the resource.
    guestFlush 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 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 string
    Name of the resource.
    project 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 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 str
    A text description of the resource.
    guest_flush 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 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 str
    Name of the resource.
    project 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 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 String
    A text description of the resource.
    guestFlush 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 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 String
    Name of the resource.
    project 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 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 string
    The name of the encryption key that is stored in Google Cloud KMS.
    KmsKeyServiceAccount 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 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 string
    The name of the encryption key that is stored in Google Cloud KMS.
    KmsKeyServiceAccount 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 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 String
    The name of the encryption key that is stored in Google Cloud KMS.
    kmsKeyServiceAccount 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 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 string
    The name of the encryption key that is stored in Google Cloud KMS.
    kmsKeyServiceAccount 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 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 str
    The name of the encryption key that is stored in Google Cloud KMS.
    kms_key_service_account 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 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 String
    The name of the encryption key that is stored in Google Cloud KMS.
    kmsKeyServiceAccount 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 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}}
    
    $ pulumi import gcp:compute/machineImage:MachineImage default {{project}}/{{name}}
    
    $ pulumi import gcp:compute/machineImage:MachineImage default {{name}}
    

    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.
    gcp logo
    Google Cloud Classic v8.9.3 published on Monday, Nov 18, 2024 by Pulumi