설명
Azure Storage는 기본적으로 Microsoft 관리형 키로 데이터를 암호화합니다. 진단 로그를 보관하는 조직이 키 권한과 교체 주기를 직접 관리해야 한다면 고객 관리형 키를 연결하세요.
잠재적 영향
계정의 관리 ID가 키를 사용할 수 없게 되면 로그 데이터에도 접근하지 못할 수 있습니다.
해결 방법
일시 삭제와 제거 방지를 켠 Key Vault에 지원되는 RSA 또는 RSA-HSM 키를 준비하세요. 키 복구·교체 절차를 정하고 관리 ID에 get, wrapKey, unwrapKey 권한을 부여하세요. Terraform에서는 customer_managed_key 블록 또는 별도 azurerm_storage_account_customer_managed_key 리소스 중 하나로 연결을 관리하세요. 적용 후 실제 계정에 의도한 키가 연결됐는지 확인하세요.
예시
예시는 사용자 할당 ID와 별도 키 연결 리소스를 사용합니다. 계정에는 lifecycle.ignore_changes로 customer_managed_key를 제외해 두 리소스가 같은 설정을 관리하지 않게 하세요. 수집할 진단 로그 범주도 지정하세요.
변경 전
hcl
resource "azurerm_storage_account" "logs" {
name = "examplediagnosticlogs"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "GRS"
}
resource "azurerm_monitor_diagnostic_setting" "example" {
name = "subscription-diagnostics"
target_resource_id = data.azurerm_subscription.current.id
storage_account_id = azurerm_storage_account.logs.id
}
변경 후
hcl
resource "azurerm_storage_account" "logs" {
name = "examplediagnosticlogs"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
account_tier = "Standard"
account_replication_type = "GRS"
identity {
type = "UserAssigned"
identity_ids = [azurerm_user_assigned_identity.storage.id]
}
}
resource "azurerm_storage_account_customer_managed_key" "logs" {
storage_account_id = azurerm_storage_account.logs.id
key_vault_key_id = azurerm_key_vault_key.storage.id
user_assigned_identity_id = azurerm_user_assigned_identity.storage.id
}
resource "azurerm_monitor_diagnostic_setting" "example" {
name = "subscription-diagnostics"
target_resource_id = data.azurerm_subscription.current.id
storage_account_id = azurerm_storage_account.logs.id
}