説明
Function App が他の Azure サービスにどう接続しているかを確認します。接続先が対応していれば、接続文字列に長期利用するキーを保存せず、マネージド ID で認証できます。関数の呼び出し元の認証は別途設定します。
想定される影響
コードやアプリ設定に残ったキーは、漏えいや交換・失効漏れにつながるおそれがあります。
対処方法
identity ブロックで SystemAssigned を選ぶか、UserAssigned を選んでマネージド ID の Azure リソース ID を identity_ids に指定します。接続先でその ID に必要な権限だけを付与します。接続設定またはコードをマネージド ID のトークンを使うように変更し、関数を実行して対象の操作が成功することを確認してください。ほかの接続でも不要になった認証情報は削除して失効させます。
例
AzureRM 3.x の azurerm_function_app にシステム割り当て ID を追加する例です。必須のストレージ設定、接続先の権限、トークンを使うコードは省略しています。
変更前
hcl
resource "azurerm_function_app" "example" {
name = "test-azure-functions"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
app_service_plan_id = azurerm_app_service_plan.example.id
}
変更後
hcl
resource "azurerm_function_app" "example" {
name = "test-azure-functions"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
app_service_plan_id = azurerm_app_service_plan.example.id
identity {
type = "SystemAssigned"
}
}