-
Notifications
You must be signed in to change notification settings - Fork 335
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from pauldotyu/modular_terraform
feat: modularize tf deployment
- Loading branch information
Showing
15 changed files
with
377 additions
and
132 deletions.
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,126 @@ | ||
resource "azurerm_key_vault" "example" { | ||
name = "akv-${local.name}" | ||
location = azurerm_resource_group.example.location | ||
resource_group_name = azurerm_resource_group.example.name | ||
enabled_for_disk_encryption = true | ||
tenant_id = data.azurerm_client_config.current.tenant_id | ||
sku_name = "standard" | ||
enable_rbac_authorization = true | ||
name = "akv-${local.name}" | ||
location = azurerm_resource_group.example.location | ||
resource_group_name = azurerm_resource_group.example.name | ||
enabled_for_disk_encryption = true | ||
tenant_id = data.azurerm_client_config.current.tenant_id | ||
sku_name = "standard" | ||
enable_rbac_authorization = var.kv_rbac_enabled | ||
|
||
dynamic "access_policy" { | ||
for_each = var.kv_rbac_enabled ? [] : [1] | ||
content { | ||
tenant_id = data.azurerm_client_config.current.tenant_id | ||
object_id = data.azurerm_client_config.current.object_id | ||
|
||
certificate_permissions = [ | ||
"Backup", | ||
"Create", | ||
"Delete", | ||
"DeleteIssuers", | ||
"Get", | ||
"GetIssuers", | ||
"Import", | ||
"List", | ||
"ListIssuers", | ||
"ManageContacts", | ||
"ManageIssuers", | ||
"Purge", | ||
"Recover", | ||
"Restore", | ||
"SetIssuers", | ||
"Update" | ||
] | ||
|
||
key_permissions = [ | ||
"Backup", | ||
"Create", | ||
"Decrypt", | ||
"Delete", | ||
"Encrypt", | ||
"Get", | ||
"Import", | ||
"List", | ||
"Purge", | ||
"Recover", | ||
"Restore", | ||
"Sign", | ||
"UnwrapKey", | ||
"Update", | ||
"Verify", | ||
"WrapKey", | ||
"Release", | ||
"Rotate", | ||
"GetRotationPolicy", | ||
"SetRotationPolicy" | ||
] | ||
|
||
secret_permissions = [ | ||
"Backup", | ||
"Delete", | ||
"Get", | ||
"List", | ||
"Purge", | ||
"Recover", | ||
"Restore", | ||
"Set" | ||
] | ||
|
||
storage_permissions = [ | ||
"Backup", | ||
"Delete", | ||
"DeleteSAS", | ||
"Get", | ||
"GetSAS", | ||
"List", | ||
"ListSAS", | ||
"Purge", | ||
"Recover", | ||
"RegenerateKey", | ||
"Restore", | ||
"Set", | ||
"SetSAS", | ||
"Update" | ||
] | ||
} | ||
} | ||
} | ||
|
||
resource "azurerm_role_assignment" "example_akv_rbac" { | ||
principal_id = data.azurerm_client_config.current.object_id | ||
role_definition_name = "Key Vault Administrator" | ||
scope = azurerm_key_vault.example.id | ||
count = var.kv_rbac_enabled ? 1 : 0 | ||
principal_id = data.azurerm_client_config.current.object_id | ||
role_definition_name = "Key Vault Administrator" | ||
scope = azurerm_key_vault.example.id | ||
} | ||
|
||
resource "azurerm_key_vault_secret" "openai_key" { | ||
name = "AZURE-OPENAI-KEY" | ||
value = azurerm_cognitive_account.example.primary_access_key | ||
key_vault_id = azurerm_key_vault.example.id | ||
depends_on = [ azurerm_role_assignment.example_akv_rbac ] | ||
count = local.deploy_azure_openai ? 1 : 0 | ||
name = "AZURE-OPENAI-KEY" | ||
value = azurerm_cognitive_account.example[0].primary_access_key | ||
key_vault_id = azurerm_key_vault.example.id | ||
depends_on = [azurerm_role_assignment.example_akv_rbac] | ||
} | ||
|
||
resource "azurerm_key_vault_secret" "cosmosdb_key" { | ||
name = "AZURE-COSMOS-KEY" | ||
value = azurerm_cosmosdb_account.example.primary_key | ||
key_vault_id = azurerm_key_vault.example.id | ||
depends_on = [ azurerm_role_assignment.example_akv_rbac ] | ||
count = local.deploy_azure_cosmosdb ? 1 : 0 | ||
name = "AZURE-COSMOS-KEY" | ||
value = azurerm_cosmosdb_account.example[0].primary_key | ||
key_vault_id = azurerm_key_vault.example.id | ||
depends_on = [azurerm_role_assignment.example_akv_rbac] | ||
} | ||
|
||
resource "azurerm_key_vault_secret" "listener_key" { | ||
name = "AZURE-SERVICE-BUS-LISTENER-KEY" | ||
value = azurerm_servicebus_namespace_authorization_rule.example.primary_key | ||
key_vault_id = azurerm_key_vault.example.id | ||
depends_on = [ azurerm_role_assignment.example_akv_rbac ] | ||
count = local.deploy_azure_servicebus ? 1 : 0 | ||
name = "AZURE-SERVICE-BUS-LISTENER-KEY" | ||
value = azurerm_servicebus_namespace_authorization_rule.example[0].primary_key | ||
key_vault_id = azurerm_key_vault.example.id | ||
depends_on = [azurerm_role_assignment.example_akv_rbac] | ||
} | ||
|
||
resource "azurerm_key_vault_secret" "sender_key" { | ||
name = "AZURE-SERVICE-BUS-SENDER-KEY" | ||
value = azurerm_servicebus_queue_authorization_rule.example.primary_key | ||
key_vault_id = azurerm_key_vault.example.id | ||
depends_on = [ azurerm_role_assignment.example_akv_rbac ] | ||
count = local.deploy_azure_servicebus ? 1 : 0 | ||
name = "AZURE-SERVICE-BUS-SENDER-KEY" | ||
value = azurerm_servicebus_queue_authorization_rule.example[0].primary_key | ||
key_vault_id = azurerm_key_vault.example.id | ||
depends_on = [azurerm_role_assignment.example_akv_rbac] | ||
} |
Oops, something went wrong.