Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terraform v1.3.3 crash: inconsistent map element types #32094

Closed
vladimir-kozyrev opened this issue Oct 27, 2022 · 2 comments
Closed

Terraform v1.3.3 crash: inconsistent map element types #32094

vladimir-kozyrev opened this issue Oct 27, 2022 · 2 comments
Labels
bug duplicate issue closed because another issue already tracks this problem

Comments

@vladimir-kozyrev
Copy link

Terraform Version

v1.3.3

Terraform Configuration Files

variables.tf

variable "developers" {
  type = map(
    object({
      given_name    = string
      family_name   = string
      primary_email = string
      aliases       = optional(list(string), [])
      developer_info = optional(object({
        teams            = optional(list(string), [])
        github_username  = optional(string)
        github_role      = optional(string, "member")
        github_team_role = optional(string)
      }))
      sendgrid = optional(object({
        role = optional(string)
      }))
      phone              = optional(string)
      personal_email     = optional(string)
      unit               = string
      groups             = optional(map(string))
      gcp_permissions    = optional(map(list(string)))
      in_developers_team = optional(bool, true)
      password           = optional(string)
      hash_function      = optional(string)
    })
  )
  default = {
    "Name1_Surname1" = {
      given_name     = "Name1"
      family_name    = "Surname1"
      primary_email  = "email1@test.com"
      personal_email = "email1@personaltest.com"
      unit           = "/general"
      developer_info = {
        "github_username" = "xxx1"
      }
      in_developers_team = false
    }
    "Name2_Surname2" = {
      given_name    = "Name2"
      family_name   = "Surname2"
      primary_email = "email1@test.com"
      unit          = "/developers"
    }
  }
}

main.tf

locals {
  developers_info = flatten(flatten([
    for user, user_config in var.developers : [
      for key, value in user_config : {
        github_username  = value.github_username
        teams            = value.teams
        github_role      = value.github_role
        github_team_role = value.github_role == "admin" ? "maintainer" : "member"
        email            = user_config["primary_email"]
      } if user_config["developer_info"] != null && key == "developer_info"
    ]
  ]))
}

resource "googleworkspace_user" "this" {
  for_each       = var.developers
  primary_email  = each.value.primary_email
  recovery_email = each.value.personal_email
  recovery_phone = each.value.phone
  name {
    family_name = each.value.family_name
    given_name  = each.value.given_name
  }
  aliases       = each.value.aliases
  password      = each.value.password
  hash_function = each.value.hash_function
  org_unit_path = each.value.unit
  organizations {
    department = "/developers"
    type       = "work"
  }
  lifecycle {
    ignore_changes = [
      change_password_at_next_login,
      phones,
      recovery_email,
      recovery_phone,
    ]
  }
}

provider.tf

terraform {
  required_providers {
    googleworkspace = {
      source  = "hashicorp/googleworkspace"
      version = "0.7.0"
    }
  }
}

provider "googleworkspace" {
  # Use GOOGLEWORKSPACE_CREDENTIALS env
  # More settings: https://registry.terraform.io/providers/hashicorp/googleworkspace/latest/docs
  customer_id = "XXX"
}

Debug Output

https://gist.github.com/vladimir-kozyrev/ea6b381a820f369b7a5e6f570285dd52

Expected Behavior

terraform plan should work without crashing

Actual Behavior

terraform plan crashes

Steps to Reproduce

  1. terraform init
  2. terraform plan

Additional Context

I think it may be related to the optional variables because of the diff
image

References

#31962

@vladimir-kozyrev vladimir-kozyrev added bug new new issue not yet triaged labels Oct 27, 2022
@jbardin
Copy link
Member

jbardin commented Oct 27, 2022

Duplicate of #31978

@jbardin jbardin marked this as a duplicate of #31978 Oct 27, 2022
@jbardin jbardin closed this as completed Oct 27, 2022
@crw crw added duplicate issue closed because another issue already tracks this problem and removed new new issue not yet triaged labels Nov 3, 2022
@github-actions
Copy link

github-actions bot commented Dec 3, 2022

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug duplicate issue closed because another issue already tracks this problem
Projects
None yet
Development

No branches or pull requests

3 participants