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

r\hpc_cache: Add support for encryption key #16972

Merged
merged 5 commits into from
Jun 8, 2022

Conversation

myc2h6o
Copy link
Contributor

@myc2h6o myc2h6o commented May 26, 2022

  • This feature internally uses Disk Encryption Set so validations for Key Vault are same as it here
    keyVaultDetails, err := diskEncryptionSetRetrieveKeyVault(ctx, keyVaultsClient, resourcesClient, keyVaultKeyId)
  • When updating key_vault_key_id, auto_key_rotation_enabled will be set to false at backend, have confirmed with service team that this is by design, so added validation to enforce auto_key_rotation_enabled to be false when changing key_vault_key_id

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @myc2h6o

Thanks for this PR - I've taken a look through and left a few comments inline, if we can fix those comments up then we should be able to take another look.

Thanks!

Comment on lines 1107 to 1132
"identity": {
Type: pluginsdk.TypeList,
Optional: true,
ForceNew: true,
MaxItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"type": {
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
// System-assigned Managed Identity requires manual operation on Portal
string(storagecache.CacheIdentityTypeUserAssigned),
}, false),
},
"identity_ids": {
Type: pluginsdk.TypeSet,
Optional: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
ValidateFunc: msivalidate.UserAssignedIdentityID,
},
},
},
},
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have updated to commonschema.UserAssignedIdentityOptionalForceNew()


* `identity` - (Optional) An `identity` block as defined below.

* `key_vault_key_id` - (Optional) Specifies the URL to a Key Vault Key.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the Resource Manager or Data Plane Key ID?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is Resource Managed ID, which is azurerm_key_vault_key.id, have updated the description to be clear


* `key_vault_key_id` - (Optional) Specifies the URL to a Key Vault Key.

~> **NOTE:** `auto_key_rotation_enabled` must be set to `false` when updating `key_vault_key_id`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that'd be a provider behaviour we're missing, to disable this, then re-enable it during the update?

Copy link
Contributor Author

@myc2h6o myc2h6o May 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes make sense, I've updated the code to trigger another update when the key is updated and auto key rotation is enabled

@@ -83,7 +83,15 @@ The following arguments are supported:
* `directory_ldap` - (Optional) A `directory_ldap` block as defined below.

~> **Note:** Only one of `directory_active_directory`, `directory_flat_file` and `directory_ldap` can be set.


* `identity` - (Optional) An `identity` block as defined below.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is ForceNew

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the forceNew description

Comment on lines 187 to 189
* `type` - (Required) Specifies the type of Managed Service Identity that should be configured on this HPC Cache. Possible value is `UserAssigned`.

* `identity_ids` - (Optional) Specifies a list of User Assigned Managed Identity IDs to be assigned to this HPC Cache.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's common phrasing for these now, can we pull these from another resource

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have updated to use the common phrasing

@myc2h6o
Copy link
Contributor Author

myc2h6o commented May 27, 2022

Hi @tombuildsstuff thanks for reviewing the change! I've resolved the comment, could you please take another look?

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Jun 1, 2022

Updated test result: (Failed test TestAccHPCCache_directoryLDAP fails intermittently on main, to be fixed by #17060)

image

Comment on lines 338 to 342
autoKeyRotationEnabled = *props.RotationToLatestKeyVersionEnabled
}
}
d.Set("key_vault_key_id", keyVaultKeyId)
d.Set("auto_key_rotation_enabled", autoKeyRotationEnabled)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given the name of the property

Suggested change
autoKeyRotationEnabled = *props.RotationToLatestKeyVersionEnabled
}
}
d.Set("key_vault_key_id", keyVaultKeyId)
d.Set("auto_key_rotation_enabled", autoKeyRotationEnabled)
autoKeyRotationEnabled = *props.RotationToLatestKeyVersionEnabled
}
}
d.Set("key_vault_key_id", keyVaultKeyId)
d.Set("automatically_rotate_key_to_latest_enabled", autoKeyRotationEnabled)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@katbyte I've renamed the property name.

@myc2h6o
Copy link
Contributor Author

myc2h6o commented Jun 6, 2022

Updated test result
image

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @myc2h6o - LGTM 🌻

@katbyte katbyte merged commit 9dbbc27 into hashicorp:main Jun 8, 2022
katbyte added a commit that referenced this pull request Jun 8, 2022
@github-actions github-actions bot added this to the v3.10.0 milestone Jun 8, 2022
@myc2h6o myc2h6o deleted the hpccache_encryption branch June 9, 2022 03:14
@github-actions
Copy link

This functionality has been released in v3.10.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants