import * as pulumi from "@pulumi/pulumi"; /** * Manages the transparent data encryption configuration for a MSSQL Managed Instance * * > **Note:** Once transparent data encryption(TDE) is enabled on a MS SQL instance, it is not possible to remove TDE. You will be able to switch between 'ServiceManaged' and 'CustomerManaged' keys, but will not be able to remove encryption. For safety when this resource is deleted, the TDE mode will automatically be set to 'ServiceManaged'. As SQL Managed Instance only supports a single configuration for encryption settings, this resource will replace the current encryption settings on the server. * * > **Note:** See [documentation](https://docs.microsoft.com/azure/azure-sql/database/transparent-data-encryption-byok-overview) for important information on how handle lifecycle management of the keys to prevent data lockout. * * ## Example Usage * * ### With Service Managed Key * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * * const example = new azure.core.ResourceGroup("example", { * name: "example-resources", * location: "EastUs", * }); * const exampleVirtualNetwork = new azure.network.VirtualNetwork("example", { * name: "acctest-vnet1-mssql", * resourceGroupName: example.name, * addressSpaces: ["10.0.0.0/16"], * location: test.location, * }); * const exampleSubnet = new azure.network.Subnet("example", { * name: "subnet1-mssql", * resourceGroupName: example.name, * virtualNetworkName: exampleVirtualNetwork.name, * addressPrefixes: ["10.0.0.0/24"], * delegations: [{ * name: "managedinstancedelegation", * serviceDelegation: { * name: "Microsoft.Sql/managedInstances", * actions: [ * "Microsoft.Network/virtualNetworks/subnets/join/action", * "Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action", * "Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action", * ], * }, * }], * }); * const exampleManagedInstance = new azure.mssql.ManagedInstance("example", { * name: "mssqlinstance", * resourceGroupName: example.name, * location: example.location, * licenseType: "BasePrice", * skuName: "GP_Gen5", * storageSizeInGb: 32, * subnetId: exampleSubnet.id, * vcores: 4, * administratorLogin: "missadministrator", * administratorLoginPassword: "NCC-1701-D", * identity: { * type: "SystemAssigned", * }, * }); * const exampleManagedInstanceTransparentDataEncryption = new azure.mssql.ManagedInstanceTransparentDataEncryption("example", {managedInstanceId: exampleManagedInstance.id}); * ``` * * ### With Customer Managed Key * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as azure from "@pulumi/azure"; * * const current = azure.core.getClientConfig({}); * const example = new azure.core.ResourceGroup("example", { * name: "example-resources", * location: "EastUs", * }); * const exampleVirtualNetwork = new azure.network.VirtualNetwork("example", { * name: "acctest-vnet1-mssql", * resourceGroupName: example.name, * addressSpaces: ["10.0.0.0/16"], * location: test.location, * }); * const exampleSubnet = new azure.network.Subnet("example", { * name: "subnet1-mssql", * resourceGroupName: example.name, * virtualNetworkName: exampleVirtualNetwork.name, * addressPrefixes: ["10.0.0.0/24"], * delegations: [{ * name: "managedinstancedelegation", * serviceDelegation: { * name: "Microsoft.Sql/managedInstances", * actions: [ * "Microsoft.Network/virtualNetworks/subnets/join/action", * "Microsoft.Network/virtualNetworks/subnets/prepareNetworkPolicies/action", * "Microsoft.Network/virtualNetworks/subnets/unprepareNetworkPolicies/action", * ], * }, * }], * }); * const exampleManagedInstance = new azure.mssql.ManagedInstance("example", { * name: "mssqlinstance", * resourceGroupName: example.name, * location: example.location, * licenseType: "BasePrice", * skuName: "GP_Gen5", * storageSizeInGb: 32, * subnetId: exampleSubnet.id, * vcores: 4, * administratorLogin: "missadministrator", * administratorLoginPassword: "NCC-1701-D", * identity: { * type: "SystemAssigned", * }, * }); * // Create a key vault with policies for the deployer to create a key & SQL Managed Instance to wrap/unwrap/get key * const exampleKeyVault = new azure.keyvault.KeyVault("example", { * name: "example", * location: example.location, * resourceGroupName: example.name, * enabledForDiskEncryption: true, * tenantId: current.then(current => current.tenantId), * softDeleteRetentionDays: 7, * purgeProtectionEnabled: false, * skuName: "standard", * accessPolicies: [ * { * tenantId: current.then(current => current.tenantId), * objectId: current.then(current => current.objectId), * keyPermissions: [ * "Get", * "List", * "Create", * "Delete", * "Update", * "Recover", * "Purge", * "GetRotationPolicy", * ], * }, * { * tenantId: exampleManagedInstance.identity.apply(identity => identity?.tenantId), * objectId: exampleManagedInstance.identity.apply(identity => identity?.principalId), * keyPermissions: [ * "Get", * "WrapKey", * "UnwrapKey", * ], * }, * ], * }); * const exampleKey = new azure.keyvault.Key("example", { * name: "byok", * keyVaultId: exampleKeyVault.id, * keyType: "RSA", * keySize: 2048, * keyOpts: [ * "unwrapKey", * "wrapKey", * ], * }, { * dependsOn: [exampleKeyVault], * }); * const exampleManagedInstanceTransparentDataEncryption = new azure.mssql.ManagedInstanceTransparentDataEncryption("example", { * managedInstanceId: exampleManagedInstance.id, * keyVaultKeyId: exampleKey.id, * }); * ``` * * ## API Providers * * * This resource uses the following Azure API Providers: * * * `Microsoft.Sql` - 2023-08-01-preview * * ## Import * * > **Note:** This resource does not need to be imported to manage it, however the import will work. * * SQL Managed Instance Transparent Data Encryption can be imported using the resource id, e.g. * * ```sh * $ pulumi import azure:mssql/managedInstanceTransparentDataEncryption:ManagedInstanceTransparentDataEncryption example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Sql/managedInstances/instance1/encryptionProtector/current * ``` */ export declare class ManagedInstanceTransparentDataEncryption extends pulumi.CustomResource { /** * Get an existing ManagedInstanceTransparentDataEncryption 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?: ManagedInstanceTransparentDataEncryptionState, opts?: pulumi.CustomResourceOptions): ManagedInstanceTransparentDataEncryption; /** * Returns true if the given object is an instance of ManagedInstanceTransparentDataEncryption. 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 ManagedInstanceTransparentDataEncryption; /** * When enabled, the SQL Managed Instance will continuously check the key vault for any new versions of the key being used as the TDE protector. If a new version of the key is detected, the TDE protector on the SQL Managed Instance will be automatically rotated to the latest key version within 60 minutes. */ readonly autoRotationEnabled: pulumi.Output; /** * To use customer managed keys from Azure Key Vault, provide the AKV Key ID. To use service managed keys, omit this field. * * > **Note:** In order to use customer managed keys, the identity of the MSSQL Managed Instance must have the following permissions on the key vault: 'get', 'wrapKey' and 'unwrapKey' * * > **Note:** If `managedInstanceId` denotes a secondary instance deployed for disaster recovery purposes, then the `keyVaultKeyId` should be the same key used for the primary instance's transparent data encryption. Both primary and secondary instances should be encrypted with same key material. */ readonly keyVaultKeyId: pulumi.Output; readonly managedHsmKeyId: pulumi.Output; /** * Specifies the name of the MS SQL Managed Instance. Changing this forces a new resource to be created. */ readonly managedInstanceId: pulumi.Output; /** * Create a ManagedInstanceTransparentDataEncryption 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: ManagedInstanceTransparentDataEncryptionArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering ManagedInstanceTransparentDataEncryption resources. */ export interface ManagedInstanceTransparentDataEncryptionState { /** * When enabled, the SQL Managed Instance will continuously check the key vault for any new versions of the key being used as the TDE protector. If a new version of the key is detected, the TDE protector on the SQL Managed Instance will be automatically rotated to the latest key version within 60 minutes. */ autoRotationEnabled?: pulumi.Input; /** * To use customer managed keys from Azure Key Vault, provide the AKV Key ID. To use service managed keys, omit this field. * * > **Note:** In order to use customer managed keys, the identity of the MSSQL Managed Instance must have the following permissions on the key vault: 'get', 'wrapKey' and 'unwrapKey' * * > **Note:** If `managedInstanceId` denotes a secondary instance deployed for disaster recovery purposes, then the `keyVaultKeyId` should be the same key used for the primary instance's transparent data encryption. Both primary and secondary instances should be encrypted with same key material. */ keyVaultKeyId?: pulumi.Input; managedHsmKeyId?: pulumi.Input; /** * Specifies the name of the MS SQL Managed Instance. Changing this forces a new resource to be created. */ managedInstanceId?: pulumi.Input; } /** * The set of arguments for constructing a ManagedInstanceTransparentDataEncryption resource. */ export interface ManagedInstanceTransparentDataEncryptionArgs { /** * When enabled, the SQL Managed Instance will continuously check the key vault for any new versions of the key being used as the TDE protector. If a new version of the key is detected, the TDE protector on the SQL Managed Instance will be automatically rotated to the latest key version within 60 minutes. */ autoRotationEnabled?: pulumi.Input; /** * To use customer managed keys from Azure Key Vault, provide the AKV Key ID. To use service managed keys, omit this field. * * > **Note:** In order to use customer managed keys, the identity of the MSSQL Managed Instance must have the following permissions on the key vault: 'get', 'wrapKey' and 'unwrapKey' * * > **Note:** If `managedInstanceId` denotes a secondary instance deployed for disaster recovery purposes, then the `keyVaultKeyId` should be the same key used for the primary instance's transparent data encryption. Both primary and secondary instances should be encrypted with same key material. */ keyVaultKeyId?: pulumi.Input; managedHsmKeyId?: pulumi.Input; /** * Specifies the name of the MS SQL Managed Instance. Changing this forces a new resource to be created. */ managedInstanceId: pulumi.Input; }