import * as pulumi from "@pulumi/pulumi"; /** * Manages the transparent data encryption configuration for a MSSQL Server * * !> **Note:** This resource can be used to configure Transparent Data Encryption for MS SQL instances with Customer Managed Keys. For MS SQL instances that are System Managed, it should only be used with pre-existing MS SQL Instances that are over 3 years old. For new System Managed MS SQL Instances that will be created through the use of the `azure.mssql.Server` resource, please enable Transparent Data Encryption through `azure.mssql.Server` resource itself by configuring an identity block. By default, all new MS SQL Instances are deployed with System Managed Transparent Data Encryption enabled. * * > **Note:** Once transparent data encryption 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 Server 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 exampleServer = new azure.mssql.Server("example", { * name: "mssqlserver", * resourceGroupName: example.name, * location: example.location, * version: "12.0", * administratorLogin: "missadministrator", * administratorLoginPassword: "thisIsKat11", * minimumTlsVersion: "1.2", * azureadAdministrator: { * loginUsername: "AzureAD Admin", * objectId: "00000000-0000-0000-0000-000000000000", * }, * tags: { * environment: "production", * }, * }); * const exampleServerTransparentDataEncryption = new azure.mssql.ServerTransparentDataEncryption("example", {serverId: exampleServer.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 exampleServer = new azure.mssql.Server("example", { * name: "mssqlserver", * resourceGroupName: example.name, * location: example.location, * version: "12.0", * administratorLogin: "missadministrator", * administratorLoginPassword: "thisIsKat11", * minimumTlsVersion: "1.2", * azureadAdministrator: { * loginUsername: "AzureAD Admin", * objectId: "00000000-0000-0000-0000-000000000000", * }, * tags: { * environment: "production", * }, * identity: { * type: "SystemAssigned", * }, * }); * // Create a key vault with policies for the deployer to create a key & SQL Server 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: exampleServer.identity.apply(identity => identity?.tenantId), * objectId: exampleServer.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 exampleServerTransparentDataEncryption = new azure.mssql.ServerTransparentDataEncryption("example", { * serverId: exampleServer.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 Server Transparent Data Encryption can be imported using the resource id, e.g. * * ```sh * $ pulumi import azure:mssql/serverTransparentDataEncryption:ServerTransparentDataEncryption example /subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/encryptionProtector/current * ``` */ export declare class ServerTransparentDataEncryption extends pulumi.CustomResource { /** * Get an existing ServerTransparentDataEncryption 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?: ServerTransparentDataEncryptionState, opts?: pulumi.CustomResourceOptions): ServerTransparentDataEncryption; /** * Returns true if the given object is an instance of ServerTransparentDataEncryption. 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 ServerTransparentDataEncryption; /** * When enabled, the server 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 server 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 server must have the following permissions on the key vault: 'get', 'wrapKey' and 'unwrapKey' * * > **Note:** If `serverId` denotes a secondary server deployed for disaster recovery purposes, then the `keyVaultKeyId` should be the same key used for the primary server's transparent data encryption. Both primary and secondary servers should be encrypted with same key material. */ readonly keyVaultKeyId: pulumi.Output; /** * @deprecated `managedHsmKeyId` has been deprecated in favour of `keyVaultKeyId` and will be removed in v5.0 of the AzureRM provider */ readonly managedHsmKeyId: pulumi.Output; /** * Specifies the name of the MS SQL Server. Changing this forces a new resource to be created. */ readonly serverId: pulumi.Output; /** * Create a ServerTransparentDataEncryption 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: ServerTransparentDataEncryptionArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering ServerTransparentDataEncryption resources. */ export interface ServerTransparentDataEncryptionState { /** * When enabled, the server 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 server 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 server must have the following permissions on the key vault: 'get', 'wrapKey' and 'unwrapKey' * * > **Note:** If `serverId` denotes a secondary server deployed for disaster recovery purposes, then the `keyVaultKeyId` should be the same key used for the primary server's transparent data encryption. Both primary and secondary servers should be encrypted with same key material. */ keyVaultKeyId?: pulumi.Input; /** * @deprecated `managedHsmKeyId` has been deprecated in favour of `keyVaultKeyId` and will be removed in v5.0 of the AzureRM provider */ managedHsmKeyId?: pulumi.Input; /** * Specifies the name of the MS SQL Server. Changing this forces a new resource to be created. */ serverId?: pulumi.Input; } /** * The set of arguments for constructing a ServerTransparentDataEncryption resource. */ export interface ServerTransparentDataEncryptionArgs { /** * When enabled, the server 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 server 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 server must have the following permissions on the key vault: 'get', 'wrapKey' and 'unwrapKey' * * > **Note:** If `serverId` denotes a secondary server deployed for disaster recovery purposes, then the `keyVaultKeyId` should be the same key used for the primary server's transparent data encryption. Both primary and secondary servers should be encrypted with same key material. */ keyVaultKeyId?: pulumi.Input; /** * @deprecated `managedHsmKeyId` has been deprecated in favour of `keyVaultKeyId` and will be removed in v5.0 of the AzureRM provider */ managedHsmKeyId?: pulumi.Input; /** * Specifies the name of the MS SQL Server. Changing this forces a new resource to be created. */ serverId: pulumi.Input; }