import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Manages a Virtual Machine Extension to provide post deployment configuration * and run automated tasks. * * > **Note:** Custom Script Extensions for Linux & Windows require that the `commandToExecute` returns a `0` exit code to be classified as successfully deployed. You can achieve this by appending `exit 0` to the end of your `commandToExecute`. * * > **Note:** Custom Script Extensions require that the Azure Virtual Machine Guest Agent is running on the Virtual Machine. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * import * as std from "@pulumi/std"; * * const example = new azure.core.ResourceGroup("example", { * name: "example-resources", * location: "West Europe", * }); * const exampleVirtualNetwork = new azure.network.VirtualNetwork("example", { * name: "acctvn", * addressSpaces: ["10.0.0.0/16"], * location: example.location, * resourceGroupName: example.name, * }); * const exampleSubnet = new azure.network.Subnet("example", { * name: "acctsub", * resourceGroupName: example.name, * virtualNetworkName: exampleVirtualNetwork.name, * addressPrefixes: ["10.0.2.0/24"], * }); * const exampleNetworkInterface = new azure.network.NetworkInterface("example", { * name: "acctni", * location: example.location, * resourceGroupName: example.name, * ipConfigurations: [{ * name: "testconfiguration1", * subnetId: exampleSubnet.id, * privateIpAddressAllocation: "Dynamic", * }], * }); * const exampleLinuxVirtualMachine = new azure.compute.LinuxVirtualMachine("example", { * name: "example-machine", * resourceGroupName: example.name, * location: example.location, * size: "Standard_F2", * adminUsername: "adminuser", * networkInterfaceIds: [exampleNetworkInterface.id], * adminSshKeys: [{ * username: "adminuser", * publicKey: std.file({ * input: "~/.ssh/id_rsa.pub", * }).then(invoke => invoke.result), * }], * osDisk: { * caching: "ReadWrite", * storageAccountType: "Standard_LRS", * }, * sourceImageReference: { * publisher: "Canonical", * offer: "0001-com-ubuntu-server-jammy", * sku: "22_04-lts", * version: "latest", * }, * }); * const exampleExtension = new azure.compute.Extension("example", { * name: "hostname", * virtualMachineId: exampleLinuxVirtualMachine.id, * publisher: "Microsoft.Azure.Extensions", * type: "CustomScript", * typeHandlerVersion: "2.0", * settings: ` { * \\"commandToExecute\\": \\"hostname && uptime\\" * } * `, * tags: { * environment: "Production", * }, * }); * ``` * * ## API Providers * * * This resource uses the following Azure API Providers: * * * `Microsoft.Compute` - 2024-03-01 * * ## Import * * Virtual Machine Extensions can be imported using the `resource id`, e.g. * * ```sh * $ pulumi import azure:compute/extension:Extension example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachines/myVM/extensions/extensionName * ``` */ export declare class Extension extends pulumi.CustomResource { /** * Get an existing Extension resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name: string, id: pulumi.Input, state?: ExtensionState, opts?: pulumi.CustomResourceOptions): Extension; /** * Returns true if the given object is an instance of Extension. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj: any): obj is Extension; /** * Specifies if the platform deploys the latest minor version update to the `typeHandlerVersion` specified. */ readonly autoUpgradeMinorVersion: pulumi.Output; /** * Should the Extension be automatically updated whenever the Publisher releases a new version of this VM Extension? */ readonly automaticUpgradeEnabled: pulumi.Output; /** * Should failures from the extension be suppressed? Possible values are `true` or `false`. Defaults to `false`. * * > **Note:** Operational failures such as not connecting to the VM will not be suppressed regardless of the `failureSuppressionEnabled` value. */ readonly failureSuppressionEnabled: pulumi.Output; /** * The name of the virtual machine extension peering. Changing this forces a new resource to be created. */ readonly name: pulumi.Output; /** * The protectedSettings passed to the extension, like settings, these are specified as a JSON object in a string. * * > **Note:** Certain VM Extensions require that the keys in the `protectedSettings` block are case sensitive. If you're seeing unhelpful errors, please ensure the keys are consistent with how Azure is expecting them (for instance, for the `JsonADDomainExtension` extension, the keys are expected to be in `TitleCase`.) */ readonly protectedSettings: pulumi.Output; /** * A `protectedSettingsFromKeyVault` block as defined below. * * > **Note:** `protectedSettingsFromKeyVault` cannot be used with `protectedSettings` */ readonly protectedSettingsFromKeyVault: pulumi.Output; /** * Specifies the collection of extension names after which this extension needs to be provisioned. */ readonly provisionAfterExtensions: pulumi.Output; /** * The publisher of the extension, available publishers can be found by using the Azure CLI. Changing this forces a new resource to be created. */ readonly publisher: pulumi.Output; /** * The settings passed to the extension, these are specified as a JSON object in a string. * * > **Note:** Certain VM Extensions require that the keys in the `settings` block are case sensitive. If you're seeing unhelpful errors, please ensure the keys are consistent with how Azure is expecting them (for instance, for the `JsonADDomainExtension` extension, the keys are expected to be in `TitleCase`.) */ readonly settings: pulumi.Output; /** * A mapping of tags to assign to the resource. */ readonly tags: pulumi.Output<{ [key: string]: string; } | undefined>; /** * The type of extension, available types for a publisher can be found using the Azure CLI. * * > **Note:** The `Publisher` and `Type` of Virtual Machine Extensions can be found using the Azure CLI, via: * * ```shell * az vm extension image list --location westus -o table * ``` */ readonly type: pulumi.Output; /** * Specifies the version of the extension to use, available versions can be found using the Azure CLI. */ readonly typeHandlerVersion: pulumi.Output; /** * The ID of the Virtual Machine. Changing this forces a new resource to be created */ readonly virtualMachineId: pulumi.Output; /** * Create a Extension resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ constructor(name: string, args: ExtensionArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering Extension resources. */ export interface ExtensionState { /** * Specifies if the platform deploys the latest minor version update to the `typeHandlerVersion` specified. */ autoUpgradeMinorVersion?: pulumi.Input; /** * Should the Extension be automatically updated whenever the Publisher releases a new version of this VM Extension? */ automaticUpgradeEnabled?: pulumi.Input; /** * Should failures from the extension be suppressed? Possible values are `true` or `false`. Defaults to `false`. * * > **Note:** Operational failures such as not connecting to the VM will not be suppressed regardless of the `failureSuppressionEnabled` value. */ failureSuppressionEnabled?: pulumi.Input; /** * The name of the virtual machine extension peering. Changing this forces a new resource to be created. */ name?: pulumi.Input; /** * The protectedSettings passed to the extension, like settings, these are specified as a JSON object in a string. * * > **Note:** Certain VM Extensions require that the keys in the `protectedSettings` block are case sensitive. If you're seeing unhelpful errors, please ensure the keys are consistent with how Azure is expecting them (for instance, for the `JsonADDomainExtension` extension, the keys are expected to be in `TitleCase`.) */ protectedSettings?: pulumi.Input; /** * A `protectedSettingsFromKeyVault` block as defined below. * * > **Note:** `protectedSettingsFromKeyVault` cannot be used with `protectedSettings` */ protectedSettingsFromKeyVault?: pulumi.Input; /** * Specifies the collection of extension names after which this extension needs to be provisioned. */ provisionAfterExtensions?: pulumi.Input[]>; /** * The publisher of the extension, available publishers can be found by using the Azure CLI. Changing this forces a new resource to be created. */ publisher?: pulumi.Input; /** * The settings passed to the extension, these are specified as a JSON object in a string. * * > **Note:** Certain VM Extensions require that the keys in the `settings` block are case sensitive. If you're seeing unhelpful errors, please ensure the keys are consistent with how Azure is expecting them (for instance, for the `JsonADDomainExtension` extension, the keys are expected to be in `TitleCase`.) */ settings?: pulumi.Input; /** * A mapping of tags to assign to the resource. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * The type of extension, available types for a publisher can be found using the Azure CLI. * * > **Note:** The `Publisher` and `Type` of Virtual Machine Extensions can be found using the Azure CLI, via: * * ```shell * az vm extension image list --location westus -o table * ``` */ type?: pulumi.Input; /** * Specifies the version of the extension to use, available versions can be found using the Azure CLI. */ typeHandlerVersion?: pulumi.Input; /** * The ID of the Virtual Machine. Changing this forces a new resource to be created */ virtualMachineId?: pulumi.Input; } /** * The set of arguments for constructing a Extension resource. */ export interface ExtensionArgs { /** * Specifies if the platform deploys the latest minor version update to the `typeHandlerVersion` specified. */ autoUpgradeMinorVersion?: pulumi.Input; /** * Should the Extension be automatically updated whenever the Publisher releases a new version of this VM Extension? */ automaticUpgradeEnabled?: pulumi.Input; /** * Should failures from the extension be suppressed? Possible values are `true` or `false`. Defaults to `false`. * * > **Note:** Operational failures such as not connecting to the VM will not be suppressed regardless of the `failureSuppressionEnabled` value. */ failureSuppressionEnabled?: pulumi.Input; /** * The name of the virtual machine extension peering. Changing this forces a new resource to be created. */ name?: pulumi.Input; /** * The protectedSettings passed to the extension, like settings, these are specified as a JSON object in a string. * * > **Note:** Certain VM Extensions require that the keys in the `protectedSettings` block are case sensitive. If you're seeing unhelpful errors, please ensure the keys are consistent with how Azure is expecting them (for instance, for the `JsonADDomainExtension` extension, the keys are expected to be in `TitleCase`.) */ protectedSettings?: pulumi.Input; /** * A `protectedSettingsFromKeyVault` block as defined below. * * > **Note:** `protectedSettingsFromKeyVault` cannot be used with `protectedSettings` */ protectedSettingsFromKeyVault?: pulumi.Input; /** * Specifies the collection of extension names after which this extension needs to be provisioned. */ provisionAfterExtensions?: pulumi.Input[]>; /** * The publisher of the extension, available publishers can be found by using the Azure CLI. Changing this forces a new resource to be created. */ publisher: pulumi.Input; /** * The settings passed to the extension, these are specified as a JSON object in a string. * * > **Note:** Certain VM Extensions require that the keys in the `settings` block are case sensitive. If you're seeing unhelpful errors, please ensure the keys are consistent with how Azure is expecting them (for instance, for the `JsonADDomainExtension` extension, the keys are expected to be in `TitleCase`.) */ settings?: pulumi.Input; /** * A mapping of tags to assign to the resource. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * The type of extension, available types for a publisher can be found using the Azure CLI. * * > **Note:** The `Publisher` and `Type` of Virtual Machine Extensions can be found using the Azure CLI, via: * * ```shell * az vm extension image list --location westus -o table * ``` */ type: pulumi.Input; /** * Specifies the version of the extension to use, available versions can be found using the Azure CLI. */ typeHandlerVersion: pulumi.Input; /** * The ID of the Virtual Machine. Changing this forces a new resource to be created */ virtualMachineId: pulumi.Input; }