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

azurerm_key_vault - add support for enable_rbac_authorization #8670

Merged
merged 2 commits into from
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions azurerm/internal/services/keyvault/key_vault_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ func resourceArmKeyVault() *schema.Resource {
Optional: true,
},

"enable_rbac_authorization": {
Type: schema.TypeBool,
Optional: true,
},

"network_acls": {
Type: schema.TypeList,
Optional: true,
Expand Down Expand Up @@ -244,6 +249,7 @@ func resourceArmKeyVaultCreate(d *schema.ResourceData, meta interface{}) error {
enabledForDeployment := d.Get("enabled_for_deployment").(bool)
enabledForDiskEncryption := d.Get("enabled_for_disk_encryption").(bool)
enabledForTemplateDeployment := d.Get("enabled_for_template_deployment").(bool)
enableRbacAuthorization := d.Get("enable_rbac_authorization").(bool)
t := d.Get("tags").(map[string]interface{})

policies := d.Get("access_policy").([]interface{})
Expand All @@ -269,6 +275,7 @@ func resourceArmKeyVaultCreate(d *schema.ResourceData, meta interface{}) error {
EnabledForDeployment: &enabledForDeployment,
EnabledForDiskEncryption: &enabledForDiskEncryption,
EnabledForTemplateDeployment: &enabledForTemplateDeployment,
EnableRbacAuthorization: &enableRbacAuthorization,
NetworkAcls: networkAcls,
},
Tags: tags.Expand(t),
Expand Down Expand Up @@ -413,6 +420,14 @@ func resourceArmKeyVaultUpdate(d *schema.ResourceData, meta interface{}) error {
update.Properties.EnabledForTemplateDeployment = utils.Bool(d.Get("enabled_for_template_deployment").(bool))
}

if d.HasChange("enable_rbac_authorization") {
if update.Properties == nil {
update.Properties = &keyvault.VaultPatchProperties{}
}

update.Properties.EnableRbacAuthorization = utils.Bool(d.Get("enable_rbac_authorization").(bool))
}

if d.HasChange("network_acls") {
if update.Properties == nil {
update.Properties = &keyvault.VaultPatchProperties{}
Expand Down Expand Up @@ -572,6 +587,7 @@ func resourceArmKeyVaultRead(d *schema.ResourceData, meta interface{}) error {
d.Set("enabled_for_deployment", props.EnabledForDeployment)
d.Set("enabled_for_disk_encryption", props.EnabledForDiskEncryption)
d.Set("enabled_for_template_deployment", props.EnabledForTemplateDeployment)
d.Set("enable_rbac_authorization", props.EnableRbacAuthorization)
d.Set("soft_delete_enabled", props.EnableSoftDelete)
d.Set("soft_delete_retention_days", props.SoftDeleteRetentionInDays)
d.Set("purge_protection_enabled", props.EnablePurgeProtection)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func TestAccAzureRMKeyVault_update(t *testing.T) {
resource.TestCheckResourceAttr(data.ResourceName, "enabled_for_deployment", "true"),
resource.TestCheckResourceAttr(data.ResourceName, "enabled_for_disk_encryption", "true"),
resource.TestCheckResourceAttr(data.ResourceName, "enabled_for_template_deployment", "true"),
resource.TestCheckResourceAttr(data.ResourceName, "enable_rbac_authorization", "true"),
resource.TestCheckResourceAttr(data.ResourceName, "tags.environment", "Staging"),
),
},
Expand Down Expand Up @@ -831,6 +832,7 @@ resource "azurerm_key_vault" "test" {
enabled_for_deployment = true
enabled_for_disk_encryption = true
enabled_for_template_deployment = true
enable_rbac_authorization = true

tags = {
environment = "Staging"
Expand Down Expand Up @@ -864,6 +866,7 @@ resource "azurerm_key_vault" "test" {
enabled_for_deployment = true
enabled_for_disk_encryption = true
enabled_for_template_deployment = true
enable_rbac_authorization = true

tags = {
environment = "Staging"
Expand Down Expand Up @@ -899,6 +902,7 @@ resource "azurerm_key_vault" "test" {
enabled_for_deployment = true
enabled_for_disk_encryption = true
enabled_for_template_deployment = true
enable_rbac_authorization = true

tags = {
environment = "Staging"
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/key_vault.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ The following arguments are supported:

* `enabled_for_template_deployment` - (Optional) Boolean flag to specify whether Azure Resource Manager is permitted to retrieve secrets from the key vault. Defaults to `false`.

* `enable_rbac_authorization` - (Optional) Boolean flag to specify whether Azure Key Vault uses Role Based Access Control (RBAC) for authorization of data actions. Defaults to `false`.

* `network_acls` - (Optional) A `network_acls` block as defined below.

* `purge_protection_enabled` - (Optional) Is Purge Protection enabled for this Key Vault? Defaults to `false`.
Expand Down