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

Error when creating / destroying Managed Application - "Error: extracting parameters: unexpected type []interface {}" #23527

Closed
1 task done
chkp-stuartgreen opened this issue Oct 12, 2023 · 6 comments · Fixed by #23754

Comments

@chkp-stuartgreen
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment and review the contribution guide to help.

Terraform Version

1.6.1

AzureRM Provider Version

3.75.0

Affected Resource(s)/Data Source(s)

azurerm_managed_application

Terraform Configuration Files

resource "azurerm_resource_group" "rg-tf-demo-vwan" {
  name     = "rg-tf-demo-vwan"
  location = "UK South"
}

resource "azurerm_virtual_wan" "tf-demo-vwan" {
  name                = "tf-demo-vwan"
  resource_group_name = azurerm_resource_group.rg-tf-demo-vwan.name
  location            = azurerm_resource_group.rg-tf-demo-vwan.location
}

resource "azurerm_virtual_hub" "tf-demo-vwan-hub" {
  name  =   "tf-demo-vwan-hub"
  resource_group_name = azurerm_resource_group.rg-tf-demo-vwan.name
  location = azurerm_resource_group.rg-tf-demo-vwan.location
  address_prefix = "10.120.0.0/24"
  virtual_wan_id = azurerm_virtual_wan.tf-demo-vwan.id
}

resource "azurerm_managed_application" "tf-demo-ma-cpnva" {
  name                        = "tfdemomacpnva"
  location                    = azurerm_resource_group.rg-tf-demo-vwan.location
  resource_group_name         = azurerm_resource_group.rg-tf-demo-vwan.name
  kind                        = "MarketPlace"
  managed_resource_group_name = "rgmatfdemocpnva"
  #application_definition_id   = azurerm_managed_application_definition.example.id
  plan {
    name = "vwan-app"
    product = "azure-vwan"
    publisher = "checkpoint"
    version = "1.0.3"
  }
  parameter_values = jsonencode({
    location = {
      value = azurerm_resource_group.rg-tf-demo-vwan.location
    },
    hubId = {
      value = azurerm_virtual_hub.tf-demo-vwan-hub.id
    },
    cloudGuardVersion = {
      value = "R81.10 - Pay As You Go (NGTP)"
    },
    imageVersion = {
      value = "latest"
    },
    scaleUnit = {
      value = "2"
    },
    bootstrapScript = {
      value = ""
    },
    adminShell = {
      value = "/etc/cli.sh"
    },
    sicKey = {
      value = "testpassword123"
    },
    sshPublicKey = {
      value = ""
    },
    BGP = {
      value = "64512"
    },
    NVA = {
      value = "matfdemocpnva"
    },
    customMetrics = {
      value = "yes"
    },
    hubASN = {
      value = azurerm_virtual_hub.tf-demo-vwan-hub.virtual_router_asn
    },
    hubPeers = {
      value = azurerm_virtual_hub.tf-demo-vwan-hub.virtual_router_ips
    },
    smart1CloudTokenA = {
      value = ""
    },
    smart1CloudTokenB = {
      value = ""
    },
    smart1CloudTokenC = {
      value = ""
    },
    smart1CloudTokenD = {
      value = ""
    }
  })
}

Debug Output/Panic Output

Encrypted output (base64 encoded, GPG encrypted) at https://gist.github.com/chkp-stuartgreen/f15159234e4364a7f5dbaeea376ef7e9#file-debug-gpg-b64

Expected Behaviour

The attached module should create a managed application based on the supplied parameters. There should be no errors and terraform apply / destroy / plan should all complete with the relevant actions.

Actual Behaviour

Error: extracting parameters: unexpected type []interface {}

│ with azurerm_managed_application.tf-demo-ma-cpnva,
│ on main.tf line 20, in resource "azurerm_managed_application" "tf-demo-ma-cpnva":
│ 20: resource "azurerm_managed_application" "tf-demo-ma-cpnva" {

Steps to Reproduce

Using the above module, the vWAN, vWAN hub and Azure Managed application will all deploy successfully according to the Azure portal, but the TF actions will all error (apply, plan and destroy) when trying to process the parameters associated with the managed application.

Important Factoids

No response

References

This issue appears to have a similar set of symptoms - #21541

@neil-yechenwei
Copy link
Contributor

Thanks for raising this issue. Seems I can't repro this issue with below tf config that is similar with yours. Could you try below tf config to see if the issue still exists? Thanks.

tf config:

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "test" {
  name     = "acctestRG-mapp-test04"
  location = "westeurope"
}

resource "azurerm_marketplace_agreement" "test" {
  publisher = "cisco"
  offer     = "cisco-meraki-vmx"
  plan      = "cisco-meraki-vmx"
}

resource "azurerm_managed_application" "test" {
  name                        = "acctestManagedApptest04"
  location                    = azurerm_resource_group.test.location
  resource_group_name         = azurerm_resource_group.test.name
  kind                        = "MarketPlace"
  managed_resource_group_name = "infraGrouptest04"

  plan {
    name      = azurerm_marketplace_agreement.test.plan
    product   = azurerm_marketplace_agreement.test.offer
    publisher = azurerm_marketplace_agreement.test.publisher
    version   = "15.37.1"
  }

  parameter_values = jsonencode({
    zone = {
      value = "0"
    },
    location = {
      value = azurerm_resource_group.test.location
    },
    merakiAuthToken = {
      value = "953517b4-b64a-4aa2-835b-a6eef64a4efe"
    },
    subnetAddressPrefix = {
      value = "10.0.0.0/24"
    },
    subnetName = {
      value = "acctestSubnet"
    },
    virtualMachineSize = {
      value = "Standard_DS12_v2"
    },
    virtualNetworkAddressPrefix = {
      value = "10.0.0.0/16"
    },
    virtualNetworkName = {
      value = "acctestVnet"
    },
    virtualNetworkNewOrExisting = {
      value = "new"
    },
    virtualNetworkResourceGroup = {
      value = "acctestVnetRg"
    },
    vmName = {
      value = "acctestVM"
    }
  })
}

@chkp-stuartgreen
Copy link
Author

chkp-stuartgreen commented Oct 20, 2023

thanks for the reply @neil-yechenwei. The above works ok but looking at the resulting state file it doesn't appear that the properties node of the managed app have any list or objects within the values so it's not really a valid comparison. The parameters for the above app look fairly flat:

- parameters                  = {
          - "location"                    = "westeurope"
          - "merakiAuthToken"             = "xxx"
          - "subnetAddressPrefix"         = "10.0.0.0/24"
          - "subnetName"                  = "acctestSubnet"
          - "virtualMachineSize"          = "Standard_DS12_v2"
          - "virtualNetworkAddressPrefix" = "10.0.0.0/16"
          - "virtualNetworkName"          = "acctestVnet"
          - "virtualNetworkNewOrExisting" = "new"
          - "virtualNetworkResourceGroup" = "acctestVnetRg"
          - "vmName"                      = "acctestVM"
          - "zone"                        = "0"
        } -> null

The same issue is present in the newest 3.77 provider too for my use case above.

@neil-yechenwei
Copy link
Contributor

Suggest to use "parameter_values" since "parameters" is deprecated.

@chkp-stuartgreen
Copy link
Author

Thanks @neil-yechenwei. Just to confirm though - the original example I provided is using parameter_values. The snippet above was from the state file. Looking at the comments above though there is a change in provider 3.79.0 to account for the nested data types so I'll wait for that release and retest. Thanks again.

@chkp-stuartgreen
Copy link
Author

FYI - release 3.79.0 has resolved this. Many thanks!

Copy link

github-actions bot commented May 2, 2024

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 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants