Assign variable to tag Name - Terraform 13

My Name tag in AWS comes out to looking like the following:

However, I want it to look like the following:

Here is my file:
locals {
common_tags = {
Name = “var.myname-${random_id.server.hex}”

Here is my
variable “myname” {
description = “Default Name tag for AWS Resources”
default = “craigums”

Here is my resource declaration in
resource “aws_instance” “webserver” {

tags = merge(

		  "Zoo", "AWS Zoofarm",
    "RESOURCE", "webserver AMI",

The documentation for 13 doesn’t provide much guidance.

What am I doing wrong in the or file?


For the value to be interpolated you need to use the ${} mechanism.

So something like "${var.myname}-${random_id.server.hex}"

That worked, thank you!

I guess this is related… now, I need a local variable to refer to the resource_type , for example in a resource aws_instance xxxxx block,
I need the local variable in the file to do something like:
“RSRCtype” = resource_type …
if that exists.
So that the aws_instance will end up with the tag RSRCtype “aws_instance”…

if that makes any sense…