Попытка создания идентификатора управляемой системы для виртуальной машины с использованием Terraform.Ошибка из-за состояния = 404 Code = "MissingSubscription"
Попытка создания удостоверения управляемой системы для виртуальной машины.Вот фрагмент кода:
###############################################################################
# Create Managed System Identity for VMs
###############################################################################
data "azurerm_subscription" "primary" {}
data "azurerm_builtin_role_definition" "contributor" {
name = "Contributor"
}
resource "azurerm_role_assignment" "contributor" {
name = "[${element(azurerm_virtual_machine.consul.*.id, count.index + 1)}]"
scope = "${var.subscription_id}"
#scope = "${data.azurerm_subscription.primary.id}"
principal_id = "${var.tenant_object_id}"
role_definition_id = "${var.subscription_id}${data.azurerm_builtin_role_definition.contributor.id}"
}
Запуск terraform apply
выдает следующую ошибку:
Ошибка:
Error: Error applying plan:
1 error(s) occurred:
* azurerm_role_assignment.contributor: 1 error(s) occurred:
* azurerm_role_assignment.contributor: authorization.RoleAssignmentsClient#Create: Failure responding to request: StatusCode=404 -- Original Error: autorest/azure: Service returned an error. Status=404 Code="MissingSubscription" Message="The request did not have a subscription or a valid tenant level resource provider."
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
Я пыталсяследуйте примеру, описанному здесь - https://www.terraform.io/docs/providers/azurerm/r/role_assignment.html,, но похоже, что если я снова изменю свою область видимости на scope = "${data.azurerm_subscription.primary.id}"
, он выдаст ошибку:
* azurerm_role_assignment.contributor: 1 error(s) occurred:
* azurerm_role_assignment.contributor: authorization.RoleAssignmentsClient#Create: Failure responding to request: StatusCode=405 -- Original Error: autorest/azure: Service returned an error. Status=405 Code="" Message="The requested resource does not support http method 'PUT'."