Lagot
Lagot

Reputation: 765

how to construct name on terraform v0.12

previously on v0.11 these works on my deployment

resource "aws_alb_target_group" "my_tg" {
name  = "${var.SCHOOL}-${var.DEPT}-${var.ID}-tg"

However on v0.12 I'm kinda lost how to adjust with thier update, I'm trying these however gives me error

resource "aws_alb_target_group" "my_tg" {
name  = "{"var.SCHOOL"}-{"var.DEPT"}-{"var.ID"}-tg"

ERROR

on alb-tg.tf line 2, in resource "aws_alb_target_group" "my_tg":
2:   name       = "{"var.SCHOOL"}-{"var.DEPT"}-{"var.ID"}-tg"
An argument definition must end with a newline.

Upvotes: 0

Views: 3769

Answers (1)

Mihai Stancu
Mihai Stancu

Reputation: 434

In terraform v0.12 the way you interpolate variables in a string did not change.

The example you provided is still valid.

resource "aws_alb_target_group" "my_tg" {
name  = "${var.SCHOOL}-${var.DEPT}-${var.ID}-tg"

The only change in v0.12 is when you are passing only a variable as the name. So the previous name = ”${var.name}” changed in name = var.name. But seeing that you are adding the dash between variables the first example you provided is a valid string and should work.

Upvotes: 1

Related Questions