-
Notifications
You must be signed in to change notification settings - Fork 513
feat: Implement support for KMS arguments #288
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
Changes from all commits
25c45a7
0d2123c
eda1086
2bb6f10
f61f35c
7012178
07f427e
c4a8bb9
05c1b8e
f13b78a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| data "azurerm_client_config" "current" {} | ||
|
|
||
| resource "random_string" "key_vault_prefix" { | ||
| length = 6 | ||
| special = false | ||
| upper = false | ||
| numeric = false | ||
| } | ||
|
|
||
| data "curl" "public_ip" { | ||
| count = var.key_vault_firewall_bypass_ip_cidr == null ? 1 : 0 | ||
|
|
||
| http_method = "GET" | ||
| uri = "https://api.ipify.org?format=json" | ||
| } | ||
|
|
||
| locals { | ||
| # We cannot use coalesce here because it's not short-circuit and public_ip's index will cause error | ||
| public_ip = var.key_vault_firewall_bypass_ip_cidr == null ? jsondecode(data.curl.public_ip[0].response).ip : var.key_vault_firewall_bypass_ip_cidr | ||
| } | ||
|
|
||
| resource "azurerm_key_vault" "des_vault" { | ||
| location = local.resource_group.location | ||
| name = "${random_string.key_vault_prefix.result}-des-keyvault" | ||
| resource_group_name = local.resource_group.name | ||
| sku_name = "premium" | ||
| tenant_id = data.azurerm_client_config.current.tenant_id | ||
| enabled_for_disk_encryption = true | ||
| purge_protection_enabled = true | ||
| soft_delete_retention_days = 7 | ||
|
|
||
| network_acls { | ||
| bypass = "AzureServices" | ||
| default_action = "Deny" | ||
| ip_rules = [local.public_ip] | ||
| } | ||
| } | ||
|
|
||
| resource "azurerm_key_vault_access_policy" "current_user" { | ||
| key_vault_id = azurerm_key_vault.des_vault.id | ||
| object_id = coalesce(var.managed_identity_principal_id, data.azurerm_client_config.current.object_id) | ||
| tenant_id = data.azurerm_client_config.current.tenant_id | ||
| key_permissions = [ | ||
| "Get", | ||
| "Create", | ||
| "Delete", | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| resource "azurerm_key_vault_key" "kms" { | ||
| key_opts = [ | ||
| "decrypt", | ||
| "encrypt", | ||
| "sign", | ||
| "unwrapKey", | ||
| "verify", | ||
| "wrapKey", | ||
| ] | ||
| key_type = "RSA" | ||
| key_vault_id = azurerm_key_vault.des_vault.id | ||
| name = "etcd-encryption" | ||
| expiration_date = timeadd("${formatdate("YYYY-MM-DD", timestamp())}T00:00:00Z", "168h") | ||
| key_size = 2048 | ||
|
|
||
| depends_on = [ | ||
| azurerm_key_vault_access_policy.current_user | ||
| ] | ||
|
|
||
| lifecycle { | ||
| ignore_changes = [expiration_date] | ||
| } | ||
| } | ||
|
mkilchhofer marked this conversation as resolved.
|
||
|
|
||
| resource "azurerm_key_vault_access_policy" "kms" { | ||
| key_vault_id = azurerm_key_vault.des_vault.id | ||
| object_id = azurerm_user_assigned_identity.test.principal_id | ||
| tenant_id = azurerm_user_assigned_identity.test.tenant_id | ||
| key_permissions = [ | ||
| "Decrypt", | ||
| "Encrypt", | ||
| ] | ||
| } | ||
|
mkilchhofer marked this conversation as resolved.
|
||
|
|
||
| resource "azurerm_role_assignment" "kms" { | ||
| principal_id = azurerm_user_assigned_identity.test.principal_id | ||
| scope = azurerm_key_vault.des_vault.id | ||
| role_definition_name = "Key Vault Contributor" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -77,4 +77,14 @@ module "aks_cluster_name" { | |
| rbac_aad = true | ||
| rbac_aad_managed = true | ||
| role_based_access_control_enabled = true | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need the following line below line 31: service_endpoints = ["Microsoft.KeyVault"]
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Service endpoint is not needed (at least in our scenario). I think its only needed if some part inside the VNET wants to access the keyvault. |
||
| # KMS etcd encryption | ||
| kms_enabled = true | ||
| kms_key_vault_key_id = azurerm_key_vault_key.kms.id | ||
| kms_key_vault_network_access = "Private" | ||
|
|
||
|
lonegunmanb marked this conversation as resolved.
|
||
| depends_on = [ | ||
| azurerm_key_vault_access_policy.kms, | ||
| azurerm_role_assignment.kms | ||
| ] | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.