pulumi_wasm_providers_gcp_mini::compute

Module machine_image

source
Expand description

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

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let image = machine_image::create(
        "image",
        MachineImageArgs::builder()
            .name("my-image")
            .source_instance("${vm.selfLink}")
            .build_struct(),
    );
    let vm = instance::create(
        "vm",
        InstanceArgs::builder()
            .boot_disk(
                InstanceBootDisk::builder()
                    .initializeParams(
                        InstanceBootDiskInitializeParams::builder()
                            .image("debian-cloud/debian-11")
                            .build_struct(),
                    )
                    .build_struct(),
            )
            .machine_type("e2-medium")
            .name("my-vm")
            .network_interfaces(
                vec![
                    InstanceNetworkInterface::builder().network("default")
                    .build_struct(),
                ],
            )
            .build_struct(),
    );
}

§Compute Machine Image Kms

use pulumi_wasm_rust::Output;
use pulumi_wasm_rust::{add_export, pulumi_main};
#[pulumi_main]
fn test_main() -> Result<(), Error> {
    let cryptoKey = crypto_key::create(
        "cryptoKey",
        CryptoKeyArgs::builder().key_ring("${keyRing.id}").name("key").build_struct(),
    );
    let image = machine_image::create(
        "image",
        MachineImageArgs::builder()
            .machine_image_encryption_key(
                MachineImageMachineImageEncryptionKey::builder()
                    .kmsKeyName("${cryptoKey.id}")
                    .build_struct(),
            )
            .name("my-image")
            .source_instance("${vm.selfLink}")
            .build_struct(),
    );
    let keyRing = key_ring::create(
        "keyRing",
        KeyRingArgs::builder().location("us").name("keyring").build_struct(),
    );
    let vm = instance::create(
        "vm",
        InstanceArgs::builder()
            .boot_disk(
                InstanceBootDisk::builder()
                    .initializeParams(
                        InstanceBootDiskInitializeParams::builder()
                            .image("debian-cloud/debian-11")
                            .build_struct(),
                    )
                    .build_struct(),
            )
            .machine_type("e2-medium")
            .name("my-vm")
            .network_interfaces(
                vec![
                    InstanceNetworkInterface::builder().network("default")
                    .build_struct(),
                ],
            )
            .build_struct(),
    );
}

§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}}

Structs§

Functions§

  • Registers a new resource with the given unique name and arguments