Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encryption Settings - Storage Account #658

Closed
hashibot opened this issue Jan 3, 2018 · 14 comments · Fixed by #5668
Closed

Encryption Settings - Storage Account #658

hashibot opened this issue Jan 3, 2018 · 14 comments · Fixed by #5668

Comments

@hashibot
Copy link

hashibot commented Jan 3, 2018

This issue was originally opened by @raghavanr as hashicorp/terraform#17022. It was migrated here as a result of the provider split. The original body of the issue is below.


how to encrypt VM and Storage Account with Microsoft.Keyvault rather than Microsoft.Storage using terraform.
getting the error when trying with the below code..
``
resource "azurerm_storage_account" "sa" {
name = "sa"
resource_group_name = "${azurerm_resource_group.myrg.name}"
location = "${azurerm_resource_group.myrg.location}"
account_tier = "Standard"
account_replication_type = "LRS"
enable_blob_encryption = "true"
enable_file_encryption = "true"
account_encryption_source = "Microsoft.Keyvault"
}

keyvaultpropertieserror

@bg2132332
Copy link

Hi, this was linked to issue #1323, which is now released, but I don't see KeyVaultProperties added. Is that something planned?

@LaurentLesle
Copy link
Contributor

After reviewing the issue, looks like the "KeyVaultProperties" are missing.

this is what I have to do to setup storage encryption with Keyvault from ARM template:

"properties": {
"supportsHttpsTrafficOnly": true,
"encryption": {
"keyvaultproperties": {
"keyvaulturi": "https://kv242342.vault.azure.net",
"keyname": "storage-key-rsa-hsm-2048",
"keyversion": "fad0fdc1011a43108ada5ed51995ccdd"
},

"services": {
"file": {
"enabled": true
},
"blob": {
"enabled": true
}
},
"keySource": "Microsoft.Keyvault"
}
}

@jlucktay
Copy link

@LaurentLesle we're hitting an error in Terraform v0.11.10 and provider.azurerm v1.19.0 with the same template layout to yours:
FeatureNotSupportedForAccount - EncryptionAtRest/Customer Managed Key is not supported for the account.
We have sku.name in the template set to Premium_LRS if relevant.

When sending the same JSON through Azure CLI, we get:
The accountType field is missing from the request.
According to this template accountType is an old name for the sku.name field.

@WodansSon WodansSon self-assigned this Feb 6, 2019
@WodansSon WodansSon added this to the 2.0.0 milestone Mar 7, 2019
@steffencircle
Copy link

steffencircle commented Aug 19, 2019

Hi,

can somebody give me some more insights on this ?
I am trying to deploy a Storage Account with Custom Encryption settings.
Ideally it should point to a Key in a KeyVault that I also deployed.

Looking at the specs of storage_account resource, it seems I can specify a KeyVault as a Source, but not which KeyVault and which Key etc....

Am I missing something here ? What's the point of being able to specify the Source but not to be able to provide further settings ?

Has anybody found a workaround for this ?

Thx in advance

@sean-bailey
Copy link

Hi,

can somebody give me some more insights on this ?
I am trying to deploy a Storage Account with Custom Encryption settings.
Ideally it should point to a Key in a KeyVault that I also deployed.

Looking at the specs of storage_account resource, it seems I can specify a KeyVault as a Source, but not which KeyVault and which Key etc....

Am I missing something here ? What's the point of being able to specify the Source but not to be able to provide further settings ?

Has anybody found a workaround for this ?

Thx in advance

Seconding this. Looking at the documentation, it does appear we can specify Microsoft.KeyVault as a source of our encryption, but it is not clear at all as to which Keyvault/Key/etc is to be specified. Looking above, we can't specify the KeyVault properties. Is there a proper method we should be using with Terraform if we specify KeyVault as our encryption source?

@KevinBrooke
Copy link

The Key vault must have purge protection + soft delete enabled which is not supported by TF as they cannot be disabled, meaning the resource lifecycle cannot be managed. A workaround is to use a null_resource to enable these settings (e.g. with azure cli).

Once that is done, assign an MSI to the storage account, permission the MSI to the Key Vault and use another null_resource to execute the commands to enable key vault encryption (I use azure cli).

@migolfi

This comment has been minimized.

@viswanathareddy04

This comment has been minimized.

@prikesh-patel

This comment has been minimized.

@viswanathareddy04
Copy link

I have taken an another approach with the local-exec provision, created a powershell script and executed that script file using terraform.

@ralarcon

This comment has been minimized.

@ghost
Copy link

ghost commented Feb 24, 2020

This has been released in version 2.0.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.0.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Mar 28, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.