-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
New Resource: azurerm_netapp_account_encryption
#23733
Merged
Merged
Changes from 15 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
048d7fb
Managed Identity Implementation
paulomarquesc 8f1ad7d
WIP: Encryption with CMK
paulomarquesc b18b58f
Changing KeyVersionlessID with NestedItemIdWithOptionalVersion
paulomarquesc 828aed2
Finished fixing key_vault_id validation issues
paulomarquesc e677fc1
Removing forceNew from NetworkFeature
paulomarquesc 0fd91ea
WIP: netapp_account_encryption resource
paulomarquesc df34506
azurerm_netapp_account_encryption implementation
paulomarquesc 8970e43
WIP: Volume encryption
paulomarquesc 65a086f
Completion of CMK-based encryption
paulomarquesc 2387b35
Adding full example
paulomarquesc a630620
Merge branch 'main' into pmarques/cmk
paulomarquesc 7327179
Fixing CI issues
paulomarquesc b714a30
running terrform fmt on example
paulomarquesc d564e69
Final changes
paulomarquesc 135d96f
Merge branch 'main' into pmarques/cmk
paulomarquesc 9d9b0ae
Addressing PR comments
paulomarquesc fb9c39c
Additional test for snapshot directory visible
paulomarquesc d54ad49
fixing linting issues
paulomarquesc d0cbb5e
Making a few properties compute = true due to out of band changes
paulomarquesc 4bed98b
Merge branch 'main' into pmarques/cmk
paulomarquesc 9bb101e
reverting zone being computed
paulomarquesc 28bf745
resolving KeyVaultIDFromBaseUrl function signature change
paulomarquesc bddaa28
Fixing linting issues
paulomarquesc a8bfc0d
Removing required with since it can be microsoft.netapp
paulomarquesc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
## Example: NetApp Files Customer-Managed Keys Volume Encryption | ||
|
||
This example shows how to create an Azure NetApp volume with Customer-Managed Key Encryption enabled. | ||
|
||
For more information, please refer to [Configure customer-managed keys for Azure NetApp Files volume encryption](https://learn.microsoft.com/en-us/azure/azure-netapp-files/configure-customer-managed-keys). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
provider "azurerm" { | ||
features {} | ||
} | ||
|
||
data "azurerm_client_config" "current" { | ||
} | ||
|
||
resource "azurerm_resource_group" "example" { | ||
name = "${var.prefix}-resources" | ||
location = var.location | ||
} | ||
|
||
resource "azurerm_virtual_network" "example" { | ||
name = "${var.prefix}-vnet" | ||
location = azurerm_resource_group.example.location | ||
resource_group_name = azurerm_resource_group.example.name | ||
address_space = ["10.6.0.0/16"] | ||
} | ||
|
||
resource "azurerm_subnet" "example-delegated" { | ||
name = "${var.prefix}-delegated-subnet" | ||
resource_group_name = azurerm_resource_group.example.name | ||
virtual_network_name = azurerm_virtual_network.example.name | ||
address_prefixes = ["10.6.1.0/24"] | ||
|
||
delegation { | ||
name = "exampledelegation" | ||
|
||
service_delegation { | ||
name = "Microsoft.Netapp/volumes" | ||
actions = ["Microsoft.Network/networkinterfaces/*", "Microsoft.Network/virtualNetworks/subnets/join/action"] | ||
} | ||
} | ||
} | ||
|
||
resource "azurerm_subnet" "example-non-delegated" { | ||
name = "${var.prefix}-non-delegated-subnet" | ||
resource_group_name = azurerm_resource_group.example.name | ||
virtual_network_name = azurerm_virtual_network.example.name | ||
address_prefixes = ["10.6.0.0/24"] | ||
} | ||
|
||
resource "azurerm_key_vault" "example" { | ||
name = "${var.prefix}anfakv" | ||
location = azurerm_resource_group.example.location | ||
resource_group_name = azurerm_resource_group.example.name | ||
enabled_for_disk_encryption = true | ||
enabled_for_deployment = true | ||
enabled_for_template_deployment = true | ||
purge_protection_enabled = true | ||
tenant_id = var.tenant_id | ||
|
||
sku_name = "standard" | ||
|
||
access_policy { | ||
tenant_id = var.tenant_id | ||
object_id = data.azurerm_client_config.current.object_id | ||
|
||
key_permissions = [ | ||
"Get", | ||
"Create", | ||
"Delete", | ||
"WrapKey", | ||
"UnwrapKey", | ||
"GetRotationPolicy", | ||
"SetRotationPolicy", | ||
] | ||
} | ||
|
||
access_policy { | ||
tenant_id = var.tenant_id | ||
object_id = azurerm_user_assigned_identity.example.principal_id | ||
|
||
key_permissions = [ | ||
"Get", | ||
"Encrypt", | ||
"Decrypt" | ||
] | ||
} | ||
} | ||
|
||
resource "azurerm_key_vault_key" "example" { | ||
name = "${var.prefix}anfenckey" | ||
key_vault_id = azurerm_key_vault.example.id | ||
key_type = "RSA" | ||
key_size = 2048 | ||
|
||
key_opts = [ | ||
"decrypt", | ||
"encrypt", | ||
"sign", | ||
"unwrapKey", | ||
"verify", | ||
"wrapKey", | ||
] | ||
} | ||
|
||
resource "azurerm_private_endpoint" "example" { | ||
name = "${var.prefix}-pe-akv" | ||
location = azurerm_resource_group.example.location | ||
resource_group_name = azurerm_resource_group.example.name | ||
subnet_id = azurerm_subnet.example-non-delegated.id | ||
|
||
private_service_connection { | ||
name = "${var.prefix}-pe-sc-akv" | ||
private_connection_resource_id = azurerm_key_vault.example.id | ||
is_manual_connection = false | ||
subresource_names = ["Vault"] | ||
} | ||
} | ||
|
||
resource "azurerm_user_assigned_identity" "example" { | ||
name = "${var.prefix}-user-assigned-identity" | ||
location = azurerm_resource_group.example.location | ||
resource_group_name = azurerm_resource_group.example.name | ||
} | ||
|
||
resource "azurerm_netapp_account" "example" { | ||
name = "${var.prefix}-netappaccount" | ||
location = azurerm_resource_group.example.location | ||
resource_group_name = azurerm_resource_group.example.name | ||
|
||
identity { | ||
type = "UserAssigned" | ||
identity_ids = [ | ||
azurerm_user_assigned_identity.example.id | ||
] | ||
} | ||
} | ||
|
||
resource "azurerm_netapp_account_encryption" "example" { | ||
netapp_account_id = azurerm_netapp_account.example.id | ||
|
||
user_assigned_identity_id = azurerm_user_assigned_identity.example.id | ||
|
||
encryption { | ||
key_vault_key_id = azurerm_key_vault_key.example.versionless_id | ||
} | ||
} | ||
|
||
resource "azurerm_netapp_pool" "example" { | ||
name = "${var.prefix}-pool" | ||
location = azurerm_resource_group.example.location | ||
resource_group_name = azurerm_resource_group.example.name | ||
account_name = azurerm_netapp_account.example.name | ||
service_level = "Standard" | ||
size_in_tb = 4 | ||
|
||
depends_on = [ | ||
azurerm_netapp_account_encryption.example | ||
] | ||
} | ||
|
||
resource "azurerm_netapp_volume" "example" { | ||
name = "${var.prefix}-vol" | ||
location = azurerm_resource_group.example.location | ||
resource_group_name = azurerm_resource_group.example.name | ||
account_name = azurerm_netapp_account.example.name | ||
pool_name = azurerm_netapp_pool.example.name | ||
volume_path = "${var.prefix}-my-unique-file-path-vol" | ||
service_level = "Standard" | ||
subnet_id = azurerm_subnet.example-delegated.id | ||
storage_quota_in_gb = 100 | ||
network_features = "Standard" | ||
encryption_key_source = "Microsoft.KeyVault" | ||
key_vault_private_endpoint_id = azurerm_private_endpoint.example.id | ||
|
||
export_policy_rule { | ||
rule_index = 1 | ||
allowed_clients = ["0.0.0.0/0"] | ||
protocols_enabled = ["NFSv3"] | ||
unix_read_only = false | ||
unix_read_write = true | ||
root_access_enabled = true | ||
} | ||
|
||
depends_on = [ | ||
azurerm_netapp_account_encryption.example, | ||
azurerm_private_endpoint.example | ||
] | ||
} |
14 changes: 14 additions & 0 deletions
14
examples/netapp/nfsv3_volume_cmk_userassigned/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Copyright (c) HashiCorp, Inc. | ||
# SPDX-License-Identifier: MPL-2.0 | ||
|
||
variable "location" { | ||
description = "The Azure location where all resources in this example should be created." | ||
} | ||
|
||
variable "prefix" { | ||
description = "The prefix used for all resources used by this NetApp Volume" | ||
} | ||
|
||
variable "tenant_id" { | ||
description = "The Azure tenant ID used to create the user-assigned identity" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file doesn't have an example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completely missed that. I'll update that today.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, it is there:
I was following the format other services are doing, where they add a README.md file with a description similar to what I included and then provide the variables.tf and main.tf with the actual example.
Did that change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦 you are right! Thanks for the follow-up