설명
앱이 관리 ID를 지원하는 Azure 서비스에 연결한다면 자격 증명을 코드나 설정에 저장하지 않고 인증할 수 있습니다. 앱에 로그인하는 사용자는 별도로 인증하세요.
잠재적 영향
앱이 장기 키를 직접 사용하면 저장된 키가 노출될 수 있고, 교체할 때마다 그 키를 사용하는 설정도 갱신해야 합니다.
해결 방법
identity 블록에서 SystemAssigned 또는 UserAssigned를 선택하세요. UserAssigned를 선택하면 연결할 관리 ID의 Azure 리소스 ID를 identity_ids에 넣으세요. 대상 리소스에서 필요한 권한만 부여하고 앱의 연결을 관리 ID 인증으로 바꾸세요. ID로 필요한 작업이 성공하는지 시험한 뒤 기존 비밀값을 제거하고 다른 곳에서도 사용하지 않는 자격 증명은 폐기하세요.
예시
AzureRM 3.x의 azurerm_app_service 예시는 시스템 할당 ID만 추가합니다. 현재 Linux·Windows Web App도 identity 블록을 지원합니다. 다른 리소스에 접근할 필요가 없는 앱에는 이 연결 설정이 필요하지 않습니다.
변경 전
hcl
resource "azurerm_app_service" "example" {
name = "example-app-service"
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_app_service" "example" {
name = "example-app-service"
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"
}
}