英文:
Terraform list as input variable in Azure DevOps
问题
I am trying to pass list
as variable to Azure DevOps release pipeline.
My variable declaration:
variable "allowed_audiences" {
description = "Allowed audiences"
type = list(string)
default = ["xyz", "abc"]
}
Then, in Azure DevOps, I am trying to pass the value that I am storing in a variable group:
["\"test\""]
In the task, I am passing that variable like this:
-var="allowed_audiences=$(allowed_audience)" -var="environment=$(Release.EnvironmentName)"
But it still fails, no matter what I try.
My question is, how to pass a list of strings as a variable during an Azure DevOps release pipeline?
EDIT:
When I try this format:
-var='allowed_audiences=["\"$(allowed_audience)\""]' -var="environment=$(Release.EnvironmentName)"
I get this error:
Error: Value for undeclared variable
A variable named "allowed_audiences" was assigned on the command line, but
the root module does not declare a variable of that name. To use this
value, add a "variable" block to the configuration.
英文:
I am trying to pass list
as variable to Azure DevOps release pipeline.
My variable declaration:
variable "allowed_audiences" {
description = "Allowed audiences"
type = list(string)
default = ["xyz", "abc"]
}
Then, in azure devops i am trying to pass value that i am storing in variable group:
["\"test\""]
In task, i am passing that variable like that:
-var="allowed_audiences=$(allowed_audience)" -var="environment=$(Release.EnvironmentName)"
But it still failes whatever i tried.
2023-02-06T08:48:17.5412282Z [31m│[0m [0m[1m[31mError: [0m[0m[1mInvalid character[0m
2023-02-06T08:48:17.5412838Z [31m│[0m [0m
2023-02-06T08:48:17.5413184Z [31m│[0m [0m[0m on <value for var.allowed_audiences> line 1:
2023-02-06T08:48:17.5413540Z [31m│[0m [0m (source code not available)
2023-02-06T08:48:17.5413823Z [31m│[0m [0m
2023-02-06T08:48:17.5414269Z [31m│[0m [0mThis character is not used within the language.
2023-02-06T08:48:17.5414588Z [31m╵[0m[0m
2023-02-06T08:48:17.5414821Z [31m╷[0m[0m
2023-02-06T08:48:17.5415132Z [31m│[0m [0m[1m[31mError: [0m[0m[1mInvalid expression[0m
2023-02-06T08:48:17.5415438Z [31m│[0m [0m
2023-02-06T08:48:17.5415998Z [31m│[0m [0m[0m on <value for var.allowed_audiences> line 1:
2023-02-06T08:48:17.5416559Z [31m│[0m [0m (source code not available)
2023-02-06T08:48:17.5416989Z [31m│[0m [0m
2023-02-06T08:48:17.5417537Z [31m│[0m [0mExpected the start of an expression, but found an invalid expression token.
2023-02-06T08:48:17.5418082Z [31m╵[0m[0m
My question is, how to pass list of string as variable during Azure Devops release pipeline?
EDIT:
When i try this form:
-var='allowed_audiences=["\"$(allowed_audience)\""]' -var="environment=$(Release.EnvironmentName)"
I get this error:
2023-02-06T09:28:13.7759253Z [31m╷[0m[0m
2023-02-06T09:28:13.7760165Z [31m│[0m [0m[1m[31mError: [0m[0m[1mValue for undeclared variable[0m
2023-02-06T09:28:13.7760795Z [31m│[0m [0m
2023-02-06T09:28:13.7761315Z [31m│[0m [0m[0mA variable named "'allowed_audiences" was assigned on the command line, but
2023-02-06T09:28:13.7761949Z [31m│[0m [0mthe root module does not declare a variable of that name. To use this
2023-02-06T09:28:13.7762528Z [31m│[0m [0mvalue, add a "variable" block to the configuration.
2023-02-06T09:28:13.7762964Z [31m╵[0m[0m
答案1
得分: 0
I managed to do that. You need to delete quotes from var
area and everything should be fine
-var=allowed_audiences=["$(allowed_audience)"] -var="environment=$(Release.EnvironmentName)"
英文:
I managed to do that. YOu need to delete quotes from var
area and everything should be fine
-var=allowed_audiences=["\"$(allowed_audience)\""] -var="environment=$(Release.EnvironmentName)"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论