Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_log_analytics_saved_search string function_parameters not correct format accepted #10989

Closed
pedrinimm opened this issue Mar 16, 2021 · 5 comments

Comments

@pedrinimm
Copy link

Terraform (and AzureRM Provider) Version

Terraform v0.14.7

  • provider registry.terraform.io/hashicorp/azurerm v2.46.0

Your version of Terraform is out of date! The latest version
is 0.14.8. You can update by downloading from https://www.terraform.io/downloads.html

Affected Resource(s)

  • azurerm_log_analytics_saved_search

Terraform Configuration Files

  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "=2.46.0"
    }
  }
}

provider "azurerm" {
  tenant_id       = "xxx"
  subscription_id = "xxxx"
  features {}
}

resource "azurerm_log_analytics_saved_search" "entity_function" {
    name = "getEntityList"
    log_analytics_workspace_id = "/subscriptions/xxxxx/resourceGroups/xxxx/providers/Microsoft.OperationalInsights/workspaces/team-test-workspace"
    category     = "Function"
    display_name = "getEntityList"
    query        = <<EOT
              print typeArg
                EOT
    function_alias = "getEntityList"
    function_parameters = ["typeArg:string=mail","tagsArg:string=dc"]
}

Debug Output

Error: invalid value for function_parameters.1 (Log Analytics Saved Search Function Parameters must be in the following format: param-name1:type1=default_value1)

on config.tf line 16, in resource "azurerm_log_analytics_saved_search" "entity_function":
16: resource "azurerm_log_analytics_saved_search" "entity_function" {

Expected Behaviour

Terraform should accept variables of the following kind when string
function_parameters = ["typeArg:string="mail"","tagsArg:string="dc""]
or
function_parameters = ["typeArg:string='mail'","tagsArg:string='dc'"]

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.

Enter a value: yes

azurerm_log_analytics_saved_search.entity_function: Creating...
azurerm_log_analytics_saved_search.entity_function: Creation complete after 2s [id=subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.OperationalInsights/workspaces/team-test-workspace/savedSearches/getentitylist]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Actual Behaviour

Error: invalid value for function_parameters.1 (Log Analytics Saved Search Function Parameters must be in the following format: param-name1:type1=default_value1)

on config.tf line 16, in resource "azurerm_log_analytics_saved_search" "entity_function":
16: resource "azurerm_log_analytics_saved_search" "entity_function" {

Steps to Reproduce

  1. terraform apply
@pedrinimm pedrinimm reopened this Mar 16, 2021
@nickjacobsen
Copy link

If you want to have the format "typeArg:string="mail""

You'll need to escape the double quote (") around "mail" so like this
"typeArg:string="mail""

Single quotes: "typeArg:string='mail'" also work

@pedrinimm
Copy link
Author

That's the first thing I tried and it was not working then I looked at the validation function which enforces this regex:
^[a-zA-Z0-9!-_]*:[a-zA-Z0-9!_-]+=[a-zA-Z0-9!_-]+
and there if no way this regex allows single or double quotes

@nickjacobsen
Copy link

Apologies; I tried it the other day and it worked, now it's not. I was probably using my build, where I am modifying that regex to accept different parameters definitions to more accurately show what is possibly.

The problem is including tabular definitions and then validating them.

To validate it correctly is convoluted and it needs a lot of work to do it properly.

But you're right it doesn't work and it should.

@rcskosir
Copy link
Contributor

rcskosir commented Aug 1, 2023

Thanks for opening this issue. This was a problem in the 2.x version of the provider which is no longer actively maintained.
If this is still an issue with the 3.x version of the provider please do let us know by opening a new issue, thanks!

@rcskosir rcskosir closed this as not planned Won't fix, can't repro, duplicate, stale Aug 1, 2023
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants