import * as pulumi from "@pulumi/pulumi"; import * as inputs from "../types/input"; import * as outputs from "../types/output"; /** * Manages a Virtual Machine Run Command. * * ## Example Usage * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * * const exampleResourceGroup = new azure.core.ResourceGroup("example", { * name: "example-resources", * location: "West Europe", * }); * const exampleVirtualNetwork = new azure.network.VirtualNetwork("example", { * name: "example-vnet", * addressSpaces: ["10.0.0.0/16"], * location: exampleResourceGroup.location, * resourceGroupName: exampleResourceGroup.name, * }); * const exampleSubnet = new azure.network.Subnet("example", { * name: "internal", * resourceGroupName: exampleResourceGroup.name, * virtualNetworkName: exampleVirtualNetwork.name, * addressPrefixes: ["10.0.2.0/24"], * }); * const exampleNetworkInterface = new azure.network.NetworkInterface("example", { * name: "example-nic", * location: exampleResourceGroup.location, * resourceGroupName: exampleResourceGroup.name, * ipConfigurations: [{ * name: "internal", * subnetId: exampleSubnet.id, * privateIpAddressAllocation: "Dynamic", * }], * }); * const exampleUserAssignedIdentity = new azure.authorization.UserAssignedIdentity("example", { * name: "example-uai", * resourceGroupName: exampleResourceGroup.name, * location: exampleResourceGroup.location, * }); * const exampleLinuxVirtualMachine = new azure.compute.LinuxVirtualMachine("example", { * name: "example-VM", * resourceGroupName: exampleResourceGroup.name, * location: exampleResourceGroup.location, * size: "Standard_B2s", * adminUsername: "adminuser", * adminPassword: "P@$$w0rd1234!", * disablePasswordAuthentication: false, * networkInterfaceIds: [exampleNetworkInterface.id], * osDisk: { * caching: "ReadWrite", * storageAccountType: "Premium_LRS", * }, * sourceImageReference: { * publisher: "Canonical", * offer: "0001-com-ubuntu-server-jammy", * sku: "22_04-lts", * version: "latest", * }, * identity: { * type: "SystemAssigned, UserAssigned", * identityIds: [exampleUserAssignedIdentity.id], * }, * }); * const exampleAccount = new azure.storage.Account("example", { * name: "exampleaccount", * resourceGroupName: exampleResourceGroup.name, * location: exampleResourceGroup.location, * accountTier: "Standard", * accountReplicationType: "LRS", * }); * const exampleAssignment = new azure.authorization.Assignment("example", { * scope: exampleAccount.id, * roleDefinitionName: "Storage Blob Data Contributor", * principalId: exampleUserAssignedIdentity.principalId, * }); * const exampleContainer = new azure.storage.Container("example", { * name: "example-sc", * storageAccountName: exampleAccount.name, * containerAccessType: "blob", * }); * const example1 = new azure.storage.Blob("example1", { * name: "script1", * storageAccountName: exampleAccount.name, * storageContainerName: exampleContainer.name, * type: "Block", * sourceContent: "echo 'hello world'", * }); * const example2 = new azure.storage.Blob("example2", { * name: "output", * storageAccountName: exampleAccount.name, * storageContainerName: exampleContainer.name, * type: "Append", * }); * const example3 = new azure.storage.Blob("example3", { * name: "error", * storageAccountName: exampleAccount.name, * storageContainerName: exampleContainer.name, * type: "Append", * }); * const example = azure.storage.getAccountSASOutput({ * connectionString: exampleAccount.primaryConnectionString, * httpsOnly: true, * signedVersion: "2019-10-10", * start: "2023-04-01T00:00:00Z", * expiry: "2024-04-01T00:00:00Z", * resourceTypes: { * service: false, * container: false, * object: true, * }, * services: { * blob: true, * queue: false, * table: false, * file: false, * }, * permissions: { * read: true, * write: true, * "delete": false, * list: false, * add: true, * create: true, * update: false, * process: false, * tag: false, * filter: false, * }, * }); * // basic example * const exampleRunCommand = new azure.compute.RunCommand("example", { * name: "example-vmrc", * location: exampleResourceGroup.location, * virtualMachineId: exampleLinuxVirtualMachine.id, * source: { * script: "echo 'hello world'", * }, * }); * // authorize to storage blob using user assigned identity * const example2RunCommand = new azure.compute.RunCommand("example2", { * location: exampleResourceGroup.location, * name: "example2-vmrc", * virtualMachineId: exampleLinuxVirtualMachine.id, * outputBlobUri: example2.id, * errorBlobUri: example3.id, * runAsPassword: "P@$$w0rd1234!", * runAsUser: "adminuser", * source: { * scriptUri: example1.id, * scriptUriManagedIdentity: { * clientId: exampleUserAssignedIdentity.clientId, * }, * }, * errorBlobManagedIdentity: { * clientId: exampleUserAssignedIdentity.clientId, * }, * outputBlobManagedIdentity: { * clientId: exampleUserAssignedIdentity.clientId, * }, * parameters: [{ * name: "examplev1", * value: "val1", * }], * protectedParameters: [{ * name: "examplev2", * value: "val2", * }], * tags: { * environment: "terraform-examples", * some_key: "some-value", * }, * }, { * dependsOn: [exampleAssignment], * }); * // authorize to storage blob using SAS token * const example3RunCommand = new azure.compute.RunCommand("example3", { * location: exampleResourceGroup.location, * name: "example3-vmrc", * virtualMachineId: exampleLinuxVirtualMachine.id, * runAsPassword: "P@$$w0rd1234!", * runAsUser: "adminuser", * errorBlobUri: pulumi.all([example3.id, example]).apply(([id, example]) => `${id}${example.sas}`), * outputBlobUri: pulumi.all([example2.id, example]).apply(([id, example]) => `${id}${example.sas}`), * source: { * scriptUri: pulumi.all([example1.id, example]).apply(([id, example]) => `${id}${example.sas}`), * }, * parameters: [{ * name: "example-vm1", * value: "val1", * }], * tags: { * environment: "terraform-example-s", * some_key: "some-value", * }, * }); * ``` * * ## API Providers * * * This resource uses the following Azure API Providers: * * * `Microsoft.Compute` - 2023-03-01 * * ## Import * * An existing Virtual Machine Run Command can be imported into Pulumi using the `resource id`, e.g. * * ```sh * $ pulumi import azure:compute/runCommand:RunCommand example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Compute/virtualMachines/vm1/runCommands/rc1 * ``` */ export declare class RunCommand extends pulumi.CustomResource { /** * Get an existing RunCommand 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?: RunCommandState, opts?: pulumi.CustomResourceOptions): RunCommand; /** * Returns true if the given object is an instance of RunCommand. 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 RunCommand; /** * An `errorBlobManagedIdentity` block as defined below. User-assigned managed Identity that has access to errorBlobUri storage blob. */ readonly errorBlobManagedIdentity: pulumi.Output; /** * Specifies the Azure storage blob where script error stream will be uploaded. */ readonly errorBlobUri: pulumi.Output; readonly instanceViews: pulumi.Output; /** * The Azure Region where the Virtual Machine Run Command should exist. Changing this forces a new Virtual Machine Run Command to be created. */ readonly location: pulumi.Output; /** * Specifies the name of this Virtual Machine Run Command. Changing this forces a new Virtual Machine Run Command to be created. */ readonly name: pulumi.Output; /** * An `outputBlobManagedIdentity` block as defined below. User-assigned managed Identity that has access to outputBlobUri storage blob. */ readonly outputBlobManagedIdentity: pulumi.Output; /** * Specifies the Azure storage blob where script output stream will be uploaded. It can be basic blob URI with SAS token. */ readonly outputBlobUri: pulumi.Output; /** * A list of `parameter` blocks as defined below. The parameters used by the script. */ readonly parameters: pulumi.Output; /** * A list of `protectedParameter` blocks as defined below. The protected parameters used by the script. */ readonly protectedParameters: pulumi.Output; /** * Specifies the user account password on the VM when executing the Virtual Machine Run Command. */ readonly runAsPassword: pulumi.Output; /** * Specifies the user account on the VM when executing the Virtual Machine Run Command. */ readonly runAsUser: pulumi.Output; /** * A `source` block as defined below. The source of the run command script. */ readonly source: pulumi.Output; /** * A mapping of tags which should be assigned to the Virtual Machine Run Command. */ readonly tags: pulumi.Output<{ [key: string]: string; } | undefined>; /** * Specifies the Virtual Machine ID within which this Virtual Machine Run Command should exist. Changing this forces a new Virtual Machine Run Command to be created. */ readonly virtualMachineId: pulumi.Output; /** * Create a RunCommand 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: RunCommandArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering RunCommand resources. */ export interface RunCommandState { /** * An `errorBlobManagedIdentity` block as defined below. User-assigned managed Identity that has access to errorBlobUri storage blob. */ errorBlobManagedIdentity?: pulumi.Input; /** * Specifies the Azure storage blob where script error stream will be uploaded. */ errorBlobUri?: pulumi.Input; instanceViews?: pulumi.Input[]>; /** * The Azure Region where the Virtual Machine Run Command should exist. Changing this forces a new Virtual Machine Run Command to be created. */ location?: pulumi.Input; /** * Specifies the name of this Virtual Machine Run Command. Changing this forces a new Virtual Machine Run Command to be created. */ name?: pulumi.Input; /** * An `outputBlobManagedIdentity` block as defined below. User-assigned managed Identity that has access to outputBlobUri storage blob. */ outputBlobManagedIdentity?: pulumi.Input; /** * Specifies the Azure storage blob where script output stream will be uploaded. It can be basic blob URI with SAS token. */ outputBlobUri?: pulumi.Input; /** * A list of `parameter` blocks as defined below. The parameters used by the script. */ parameters?: pulumi.Input[]>; /** * A list of `protectedParameter` blocks as defined below. The protected parameters used by the script. */ protectedParameters?: pulumi.Input[]>; /** * Specifies the user account password on the VM when executing the Virtual Machine Run Command. */ runAsPassword?: pulumi.Input; /** * Specifies the user account on the VM when executing the Virtual Machine Run Command. */ runAsUser?: pulumi.Input; /** * A `source` block as defined below. The source of the run command script. */ source?: pulumi.Input; /** * A mapping of tags which should be assigned to the Virtual Machine Run Command. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * Specifies the Virtual Machine ID within which this Virtual Machine Run Command should exist. Changing this forces a new Virtual Machine Run Command to be created. */ virtualMachineId?: pulumi.Input; } /** * The set of arguments for constructing a RunCommand resource. */ export interface RunCommandArgs { /** * An `errorBlobManagedIdentity` block as defined below. User-assigned managed Identity that has access to errorBlobUri storage blob. */ errorBlobManagedIdentity?: pulumi.Input; /** * Specifies the Azure storage blob where script error stream will be uploaded. */ errorBlobUri?: pulumi.Input; /** * The Azure Region where the Virtual Machine Run Command should exist. Changing this forces a new Virtual Machine Run Command to be created. */ location?: pulumi.Input; /** * Specifies the name of this Virtual Machine Run Command. Changing this forces a new Virtual Machine Run Command to be created. */ name?: pulumi.Input; /** * An `outputBlobManagedIdentity` block as defined below. User-assigned managed Identity that has access to outputBlobUri storage blob. */ outputBlobManagedIdentity?: pulumi.Input; /** * Specifies the Azure storage blob where script output stream will be uploaded. It can be basic blob URI with SAS token. */ outputBlobUri?: pulumi.Input; /** * A list of `parameter` blocks as defined below. The parameters used by the script. */ parameters?: pulumi.Input[]>; /** * A list of `protectedParameter` blocks as defined below. The protected parameters used by the script. */ protectedParameters?: pulumi.Input[]>; /** * Specifies the user account password on the VM when executing the Virtual Machine Run Command. */ runAsPassword?: pulumi.Input; /** * Specifies the user account on the VM when executing the Virtual Machine Run Command. */ runAsUser?: pulumi.Input; /** * A `source` block as defined below. The source of the run command script. */ source: pulumi.Input; /** * A mapping of tags which should be assigned to the Virtual Machine Run Command. */ tags?: pulumi.Input<{ [key: string]: pulumi.Input; }>; /** * Specifies the Virtual Machine ID within which this Virtual Machine Run Command should exist. Changing this forces a new Virtual Machine Run Command to be created. */ virtualMachineId: pulumi.Input; }