Search code examples
terraform-provider-azureazure-redis-cache

Is there any way to define allowed values in terraform?


I want to create an Azure Redis Cache and want to give options to select from different SKUs. The allowed values argument is not supported and hence i cannot mention different SKUs. Is there any way to mention it?


Solution

  • This will be available in Terraform 0.13. For your specific use case, this would look as below:

    variable "sku" {
      description = "which SKU do you want (options: Basic,Standard,Premium)"
      type = "string"
      validation {
        condition     = contains(["Basic", "Standard", "Premium"], var.sku)
        error_message = "Argument 'sku' must one of 'Basic', 'Standard', or 'Premium'."
      }
    }