0
votes

I am trying to manage security center through TF resource, however have been hitting an error.

This is how the code looks like:

resource "azurerm_security_center_subscription_pricing" "example" {
  count         = var.enabled && var.subscription_pricing_enabled ? 1 : 0
  tier          = var.tier
  resource_type = "VirtualMachines, AppServices, ContainerRegistry, KeyVaults, KubernetesService, SqlServers, SqlServerVirtualMachines, StorageAccounts, Arm, Dns"

=========================================================================================================

Error: [0m[0m[1mexpected resource_type to be one of [AppServices ContainerRegistry KeyVaults KubernetesService SqlServers SqlServerVirtualMachines StorageAccounts VirtualMachines], got VirtualMachines, AppServices, ContainerRegistry, KeyVaults, KubernetesService, SqlServers, SqlServerVirtualMachines, StorageAccounts, Arm, Dns[0m
2021-04-03T07:20:07.7838074Z 
2021-04-03T07:20:07.7838690Z [0m  on primary_azure_defender.tf line 54, in resource "azurerm_security_center_subscription_pricing" "example":
2021-04-03T07:20:07.7839390Z   54: resource "azurerm_security_center_subscription_pricing" "example" [4m{[0

Any help on this is greatly appreciated.

Documentation doesn't provide much details on this usage: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/security_center_subscription_pricing

1

1 Answers

0
votes

You have to provide only one value for resource_type, e.g.:

resource "azurerm_security_center_subscription_pricing" "example" {
  count         = var.enabled && var.subscription_pricing_enabled ? 1 : 0
  tier          = var.tier
  resource_type = "VirtualMachines"

The possible value are listed in the docs and in your error message.