0
votes

I have a question about passing multiple values to a variable in Terraform. I can't find the answer anywhere and I am not sure if this is even possible. In our environment when we create AWS resources such VPC and add a tag name to it like project-environment-VPC e.g. cvs-production-VPC. How would I do the same when I am trying to create the resource using Terraform? I tried the below approach and it didn't work:

resource "aws_vpc" "main" {
  cidr_block           = var.aws_cidr
  instance_tenancy     = "default"
  enable_dns_support   = true
  enable_dns_hostnames = true

  tags = {
    Name = ${var.project}-${var.environment}-${"VPC"}
  }
}

If it is not possible - perhaps there is a workaround? Thanks in advance for any replies.

1

1 Answers

0
votes

The current Name tag value causes Invalid Character error using Terraform 0.14.6. Change the Name tag value as below to resolve the issue.

Name = "${var.project}-${var.environment}-${"VPC"}"