Closed Marquis79 closed 1 year ago
More details about my tests :
commandOptions: '--var-file NPR.AZ.COMMUN.01.tfvars azurerm_route.tr-route["pr-svcpartage-commun-001"] ${{ parameters.resourceId }}' output : /usr/bin/terraform import --var-file NPR.AZ.COMMUN.01.tfvars azurerm_route.tr-route[pr-svcpartage-commun-001] ... Index brackets must contain either a literal number or a literal string.
If I add \" like this : commandOptions: '--var-file NPR.AZ.COMMUN.01.tfvars azurerm_route.tr-route[\"pr-svcpartage-commun-001\"] ${{ parameters.resourceId }}' output: /usr/bin/terraform import --var-file NPR.AZ.COMMUN.01.tfvars azurerm_route.tr-route[\pr-svcpartage-commun-001"] ... The import command expects two arguments. the first " of the index has disappeared and I dont know why
Thanks for reporting, we will look into this and get back to you sooner.
Hi. Have you tried to escape the quotes? like commandOptions: '--var-file myvarfile.tfvars azurerm_route_table.tr-tblroute[\"index\"]
Yes I have tried like this : commandOptions: '--var-file NPR.AZ.COMMUN.01.tfvars azurerm_route.tr-route[\"pr-svcpartage-commun-001\"] ${{ parameters.resourceId }}' and the output is : usr/bin/terraform import --var-file NPR.AZ.COMMUN.01.tfvars azurerm_route.tr-route[\pr-svcpartage-commun-001"] ... the first " of the index has disappeared
ok. that is strange. let me look around and see what I can come up with. I think the issue here is that the extension use string input using another tool lib , azure-pipelines-task-lib/task, to parse the quotes ETC.
Ok found another reported issue on azure-pipelines-task-lib. that stated if you want literal "b" you should escape it like this "\"b\"" that would mean commandOptions: '--var-file myvarfile.tfvars azurerm_route_table.tr-tblroute["\"index\""]
Nice! It works the way you wrote the index: ["\"index\""] Do you plan to correct this problem or I must thinking to write the " the way you indicated to me? Thanks!
As this is not specific to the extension but rather behavior of the azure-pipelines-task-lib we will not fix this. I will however update the documentation on escaping quotes.
Hi,
Have you tried using the terraform plugin with the import command with an index on the resource like this:
Looks like the plugin doesn't allow putting an index on the option line?
Is it a bug?
thanks