Skip to content

map() deprecated #18

@Makuziker

Description

@Makuziker

My terraform version:

Terraform v1.3.7
on darwin_arm64
+ provider registry.terraform.io/hashicorp/aws v5.30.0

I'm trying out this awesome looking module and I encountered these errors:

│ Error: Error in function call
│ 
│   on main.tf line 146, in resource "aws_iam_user" "users":
│  146:     map("Name", lookup(each.value, "name")),
│     ├────────────────
│     │ while calling map(vals...)
│ 
│ Call to function "map" failed: the "map" function was deprecated in
│ Terraform v0.12 and is no longer available; use tomap({ ... }) syntax to
│ write a literal map.
╵
╷
│ Error: Error in function call
│ 
│   on main.tf line 246, in resource "aws_iam_role" "roles":
│  246:     map("Name", lookup(each.value, "name")),
│     ├────────────────
│     │ while calling map(vals...)
│ 
│ Call to function "map" failed: the "map" function was deprecated in
│ Terraform v0.12 and is no longer available; use tomap({ ... }) syntax to
│ write a literal map.

This is the page describing the deprecation: https://developer.hashicorp.com/terraform/language/functions/map

I made a local copy of the module and edited those lines to:

tags = merge(
  tomap({ Name = lookup(each.value, "name") }),
  var.tags
)

It looks like it solved the bug on my end. I created a resource with it and got merged tags as I expect. What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions