Reputation: 301
I have a release pipeline in Azure DevOps with an associated variable group. I am attempting to inject a variable from that variable group into my terraform apply
job however, it appears that variable's value is not being substituted as the job is actually trying to inject the name of the variable. See below where I have created the variable:
Here is where I am attempting to inject the variable (this is done via Additional command arguments of the job):
-var "POTENTIUM_ENVIRONMENT=${POTENTIUM_ENVIRONMENT}"
And then below you can see my terraform apply failing:
Just hoping someone can point out a simple reason for why the variable's value is not being utilised here?
Below is an example of a resource that is failing to get created due to the error above:
resource "aws_lb" "internal_load_balancer" {
name = "${var.environment}-iALB"
internal = true
load_balancer_type = "application"
security_groups = var.ecs_security_group_ILB
subnets = var.subnets
tags = {
Name = "${var.environment}-iALB"
Environment = "${var.environment}"
}
}
resource "aws_alb_listener" "internal_listener" {
load_balancer_arn = aws_lb.internal_load_balancer.arn
port = "80"
protocol = "HTTP"
default_action {
type = "fixed-response"
fixed_response {
content_type = "text/plain"
message_body = "The page you are looking for does not exist."
status_code = "401"
}
}
}
Upvotes: 0
Views: 1138
Reputation: 1
it needs to be passed like this
"-var=POTENTIUM_ENVIRONMENT=$(POTENTIUM_ENVIRONMENT)"
Upvotes: 0
Reputation: 35129
The cause of the issue can be related the way you use the Pipeline variable.
In Azure DevOps Pipeline, you can use the format: $(variablename)
to call the variable.
Here is an example:
-var "POTENTIUM_ENVIRONMENT=$(POTENTIUM_ENVIRONMENT)"
For more detailed info, you can refer to this doc: Runtime expression syntax
Upvotes: 2