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

Cannot use type any in object() #24801

Closed
yves-vogl opened this issue Apr 29, 2020 · 6 comments
Closed

Cannot use type any in object() #24801

yves-vogl opened this issue Apr 29, 2020 · 6 comments
Labels
bug confirmed a Terraform Core team member has reproduced this issue crash v0.12 Issues (primarily bugs) reported against v0.12 releases
Milestone

Comments

@yves-vogl
Copy link

yves-vogl commented Apr 29, 2020

Terraform Version

Terraform v0.12.24
+ provider.aws v2.58.0

Terraform Configuration Files

variable "users" {
  type = map(object(
    {
      mail           = string
      pgp_public_key = any # null or string
      policies       = any # null or list(string)
    }
  ))

 default = {
  "A" = {
    mail           = "[email protected]"
    pgp_public_key = "758EE76C"
    policies = [
      "IAMFullAccess",
      "Billing",
      "AWSCloudTrailReadOnlyAccess"
    ]
  },

  "B" = {
    mail           = "[email protected]"
    pgp_public_key = null
    policies = null
  }
}
}

resource "aws_iam_user" "main" {
  for_each = var.users

  name     = each.key
  path     = var.path
  tags     = merge(var.tags,
    map("Mail", each.value["mail"]),
    lookup(each.value, "pgp_public_key", false) ? map("PGP", each.value["pgp_public_key"]) : {}
  )
}


...

Debug Output

TF_LOG=trace terraform validate                                                                                                                                                                                                      ✔  itacs Managed CSP ﴃ
❯ TF_LOG=trace terraform validate
2020/04/29 14:27:41 [INFO] Terraform version: 0.12.24
2020/04/29 14:27:41 [INFO] Go runtime version: go1.13.8
2020/04/29 14:27:41 [INFO] CLI args: []string{"/usr/local/bin/terraform", "validate"}
2020/04/29 14:27:41 [DEBUG] Attempting to open CLI config file: /Users/yves/.terraformrc
2020/04/29 14:27:41 Loading CLI configuration from /Users/yves/.terraformrc
2020/04/29 14:27:41 [INFO] CLI command args: []string{"validate"}
panic: inconsistent map element types (cty.Object(map[string]cty.Type{"mail":cty.String, "pgp_public_key":cty.String, "policies":cty.Tuple([]cty.Type{cty.String})}) then cty.Object(map[string]cty.Type{"mail":cty.String, "pgp_public_key":cty.String, "policies":cty.Tuple([]cty.Type{cty.String, cty.String, cty.String, cty.String, cty.String, cty.String, cty.String, cty.String, cty.String})}))

goroutine 1 [running]:
github.com/zclconf/go-cty/cty.MapVal(0xc000536cd0, 0xc000536c00, 0xc00047f6e0, 0x12, 0xc000536dc8)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/value_init.go:207 +0x4b3
github.com/zclconf/go-cty/cty/convert.conversionObjectToMap.func2(0x2eeabe0, 0xc00001c1b0, 0x26ed360, 0xc0004678c0, 0xc00024afe0, 0x1, 0x1, 0xc000538000, 0x10, 0x10, ...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion_collection.go:338 +0x552
github.com/zclconf/go-cty/cty/convert.getConversion.func1(0x2eeabe0, 0xc00001c1b0, 0x26ed360, 0xc0004678c0, 0x0, 0x0, 0x0, 0xc000467b90, 0xc00024afd0, 0x2eeaba0, ...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion.go:46 +0x1ab
github.com/zclconf/go-cty/cty/convert.retConversion.func1(0x2eeabe0, 0xc00001c1b0, 0x26ed360, 0xc0004678c0, 0xc00024afd0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion.go:179 +0x6b
github.com/zclconf/go-cty/cty/convert.Convert(0x2eeabe0, 0xc00001c1b0, 0x26ed360, 0xc0004678c0, 0x2eeaba0, 0xc00024ad60, 0x0, 0x0, 0x0, 0xc00024ad10, ...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/convert/public.go:51 +0x1aa
github.com/hashicorp/terraform/configs.decodeVariableBlock(0xc0001d4750, 0x0, 0x2a41a7d, 0x8, 0x1, 0xc00001c188)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/named_values.go:109 +0x8c0
github.com/hashicorp/terraform/configs.(*Parser).loadConfigFile(0xc00027ebe0, 0xc0000b6c40, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/parser_config.go:96 +0x1c24
github.com/hashicorp/terraform/configs.(*Parser).LoadConfigFile(...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/parser_config.go:22
github.com/hashicorp/terraform/configs.(*Parser).loadFiles(0xc00027ebe0, 0xc000470280, 0x8, 0x8, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, ...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/parser_config_dir.go:77 +0x342
github.com/hashicorp/terraform/configs.(*Parser).LoadConfigDir(0xc00027ebe0, 0x2a3a08d, 0x1, 0x12, 0xc000537798, 0x2490f55, 0xc000537760)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/parser_config_dir.go:37 +0x121
github.com/hashicorp/terraform/configs/configload.(*Loader).LoadConfig(0xc0000ba820, 0x2a3a08d, 0x1, 0x0, 0x1, 0x2eab020, 0x3d04a48)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/configload/loader_load.go:22 +0x5d
github.com/hashicorp/terraform/command.(*Meta).loadConfig(0xc0001049c0, 0x2a3a08d, 0x1, 0x115c9cd, 0xc00047e160, 0x16, 0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/command/meta_config.go:66 +0x132
github.com/hashicorp/terraform/command.(*ValidateCommand).validate(0xc0001049c0, 0xc00003c1c0, 0x37, 0x0, 0x0, 0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/command/validate.go:92 +0x5f
github.com/hashicorp/terraform/command.(*ValidateCommand).Run(0xc0001049c0, 0xc0000a8030, 0x0, 0x0, 0xc000091e80)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/command/validate.go:83 +0x689
github.com/mitchellh/cli.(*CLI).Run(0xc0000e0640, 0xc0000e0640, 0xc000537cc0, 0x1)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/mitchellh/[email protected]/cli.go:255 +0x1da
main.wrappedMain(0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/main.go:239 +0xc43
main.realMain(0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/main.go:103 +0xb4
main.main()
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/main.go:39 +0x3a
panic: inconsistent map element types (cty.Object(map[string]cty.Type{"mail":cty.String, "pgp_public_key":cty.String, "policies":cty.Tuple([]cty.Type{cty.String})}) then cty.Object(map[string]cty.Type{"mail":cty.String, "pgp_public_key":cty.String, "policies":cty.Tuple([]cty.Type{cty.String, cty.String, cty.String, cty.String, cty.String, cty.String, cty.String, cty.String, cty.String})}))

goroutine 1 [running]:
github.com/zclconf/go-cty/cty.MapVal(0xc000536cd0, 0xc000536c00, 0xc00047f6e0, 0x12, 0xc000536dc8)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/value_init.go:207 +0x4b3
github.com/zclconf/go-cty/cty/convert.conversionObjectToMap.func2(0x2eeabe0, 0xc00001c1b0, 0x26ed360, 0xc0004678c0, 0xc00024afe0, 0x1, 0x1, 0xc000538000, 0x10, 0x10, ...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion_collection.go:338 +0x552
github.com/zclconf/go-cty/cty/convert.getConversion.func1(0x2eeabe0, 0xc00001c1b0, 0x26ed360, 0xc0004678c0, 0x0, 0x0, 0x0, 0xc000467b90, 0xc00024afd0, 0x2eeaba0, ...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion.go:46 +0x1ab
github.com/zclconf/go-cty/cty/convert.retConversion.func1(0x2eeabe0, 0xc00001c1b0, 0x26ed360, 0xc0004678c0, 0xc00024afd0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion.go:179 +0x6b
github.com/zclconf/go-cty/cty/convert.Convert(0x2eeabe0, 0xc00001c1b0, 0x26ed360, 0xc0004678c0, 0x2eeaba0, 0xc00024ad60, 0x0, 0x0, 0x0, 0xc00024ad10, ...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/convert/public.go:51 +0x1aa
github.com/hashicorp/terraform/configs.decodeVariableBlock(0xc0001d4750, 0x0, 0x2a41a7d, 0x8, 0x1, 0xc00001c188)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/named_values.go:109 +0x8c0
github.com/hashicorp/terraform/configs.(*Parser).loadConfigFile(0xc00027ebe0, 0xc0000b6c40, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/parser_config.go:96 +0x1c24
github.com/hashicorp/terraform/configs.(*Parser).LoadConfigFile(...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/parser_config.go:22
github.com/hashicorp/terraform/configs.(*Parser).loadFiles(0xc00027ebe0, 0xc000470280, 0x8, 0x8, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, ...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/parser_config_dir.go:77 +0x342
github.com/hashicorp/terraform/configs.(*Parser).LoadConfigDir(0xc00027ebe0, 0x2a3a08d, 0x1, 0x12, 0xc000537798, 0x2490f55, 0xc000537760)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/parser_config_dir.go:37 +0x121
github.com/hashicorp/terraform/configs/configload.(*Loader).LoadConfig(0xc0000ba820, 0x2a3a08d, 0x1, 0x0, 0x1, 0x2eab020, 0x3d04a48)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/configload/loader_load.go:22 +0x5d
github.com/hashicorp/terraform/command.(*Meta).loadConfig(0xc0001049c0, 0x2a3a08d, 0x1, 0x115c9cd, 0xc00047e160, 0x16, 0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/command/meta_config.go:66 +0x132
github.com/hashicorp/terraform/command.(*ValidateCommand).validate(0xc0001049c0, 0xc00003c1c0, 0x37, 0x0, 0x0, 0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/command/validate.go:92 +0x5f
github.com/hashicorp/terraform/command.(*ValidateCommand).Run(0xc0001049c0, 0xc0000a8030, 0x0, 0x0, 0xc000091e80)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/command/validate.go:83 +0x689
github.com/mitchellh/cli.(*CLI).Run(0xc0000e0640, 0xc0000e0640, 0xc000537cc0, 0x1)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/mitchellh/[email protected]/cli.go:255 +0x1da
main.wrappedMain(0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/main.go:239 +0xc43
main.realMain(0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/main.go:103 +0xb4
main.main()
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/main.go:39 +0x3a



!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

SECURITY WARNING: the "crash.log" file that was created may contain
sensitive information that must be redacted before it is safe to share
on the issue tracker.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Crash Output

2020/04/29 14:27:41 [INFO] Terraform version: 0.12.24  
2020/04/29 14:27:41 [INFO] Go runtime version: go1.13.8
2020/04/29 14:27:41 [INFO] CLI args: []string{"/usr/local/bin/terraform", "validate"}
2020/04/29 14:27:41 [DEBUG] Attempting to open CLI config file: /Users/yves/.terraformrc
2020/04/29 14:27:41 Loading CLI configuration from /Users/yves/.terraformrc
2020/04/29 14:27:41 [INFO] CLI command args: []string{"validate"}
panic: inconsistent map element types (cty.Object(map[string]cty.Type{"mail":cty.String, "pgp_public_key":cty.String, "policies":cty.Tuple([]cty.Type{cty.String})}) then cty.Object(map[string]cty.Type{"mail":cty.String, "pgp_public_key":cty.String, "policies":cty.Tuple([]cty.Type{cty.String, cty.String, cty.String, cty.String, cty.String, cty.String, cty.String, cty.String, cty.String})}))

goroutine 1 [running]:
github.com/zclconf/go-cty/cty.MapVal(0xc000536cd0, 0xc000536c00, 0xc00047f6e0, 0x12, 0xc000536dc8)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/value_init.go:207 +0x4b3
github.com/zclconf/go-cty/cty/convert.conversionObjectToMap.func2(0x2eeabe0, 0xc00001c1b0, 0x26ed360, 0xc0004678c0, 0xc00024afe0, 0x1, 0x1, 0xc000538000, 0x10, 0x10, ...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion_collection.go:338 +0x552
github.com/zclconf/go-cty/cty/convert.getConversion.func1(0x2eeabe0, 0xc00001c1b0, 0x26ed360, 0xc0004678c0, 0x0, 0x0, 0x0, 0xc000467b90, 0xc00024afd0, 0x2eeaba0, ...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion.go:46 +0x1ab
github.com/zclconf/go-cty/cty/convert.retConversion.func1(0x2eeabe0, 0xc00001c1b0, 0x26ed360, 0xc0004678c0, 0xc00024afd0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion.go:179 +0x6b
github.com/zclconf/go-cty/cty/convert.Convert(0x2eeabe0, 0xc00001c1b0, 0x26ed360, 0xc0004678c0, 0x2eeaba0, 0xc00024ad60, 0x0, 0x0, 0x0, 0xc00024ad10, ...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/zclconf/[email protected]/cty/convert/public.go:51 +0x1aa
github.com/hashicorp/terraform/configs.decodeVariableBlock(0xc0001d4750, 0x0, 0x2a41a7d, 0x8, 0x1, 0xc00001c188)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/named_values.go:109 +0x8c0
github.com/hashicorp/terraform/configs.(*Parser).loadConfigFile(0xc00027ebe0, 0xc0000b6c40, 0xc, 0x0, 0x0, 0x0, 0x0, 0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/parser_config.go:96 +0x1c24
github.com/hashicorp/terraform/configs.(*Parser).LoadConfigFile(...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/parser_config.go:22
github.com/hashicorp/terraform/configs.(*Parser).loadFiles(0xc00027ebe0, 0xc000470280, 0x8, 0x8, 0x0, 0x8, 0x0, 0x0, 0x0, 0x0, ...)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/parser_config_dir.go:77 +0x342
github.com/hashicorp/terraform/configs.(*Parser).LoadConfigDir(0xc00027ebe0, 0x2a3a08d, 0x1, 0x12, 0xc000537798, 0x2490f55, 0xc000537760)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/parser_config_dir.go:37 +0x121
github.com/hashicorp/terraform/configs/configload.(*Loader).LoadConfig(0xc0000ba820, 0x2a3a08d, 0x1, 0x0, 0x1, 0x2eab020, 0x3d04a48)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/configs/configload/loader_load.go:22 +0x5d
github.com/hashicorp/terraform/command.(*Meta).loadConfig(0xc0001049c0, 0x2a3a08d, 0x1, 0x115c9cd, 0xc00047e160, 0x16, 0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/command/meta_config.go:66 +0x132
github.com/hashicorp/terraform/command.(*ValidateCommand).validate(0xc0001049c0, 0xc00003c1c0, 0x37, 0x0, 0x0, 0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/command/validate.go:92 +0x5f
github.com/hashicorp/terraform/command.(*ValidateCommand).Run(0xc0001049c0, 0xc0000a8030, 0x0, 0x0, 0xc000091e80)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/command/validate.go:83 +0x689
github.com/mitchellh/cli.(*CLI).Run(0xc0000e0640, 0xc0000e0640, 0xc000537cc0, 0x1)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/pkg/mod/github.com/mitchellh/[email protected]/cli.go:255 +0x1da
main.wrappedMain(0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/main.go:239 +0xc43
main.realMain(0x0)
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/main.go:103 +0xb4
main.main()
	/private/tmp/terraform-20200319-2773-d1flw8/terraform-0.12.24/src/github.com/hashicorp/terraform/main.go:39 +0x3a

Expected Behavior

Should not crash.

Actual Behavior

Crashed.

Steps to Reproduce

  1. terraform validate

Additional Context

variable "users" {
  type = map(object(
    {
      mail = string
      pgp_public_key = string
      policies       = list(string)
    }
  ))

This does not crash.

References

N/A

@ghost ghost added bug crash labels Apr 29, 2020
@danieldreier
Copy link
Contributor

@yves-vogl thanks for reporting this! I have reproduced a simplified version of this:

variable "example" {
  type = map(object(
    {
      pgp_public_key = any
    }
  ))

   default = {
    "A" = {
      pgp_public_key = "758EE76C"
    },

    "B" = {
      pgp_public_key = null
    }
  }
}

This produces:

panic: inconsistent map element types (cty.Object(map[string]cty.Type{"pgp_public_key":cty.String}) then cty.Object(map[string]cty.Type{"pgp_public_key":cty.DynamicPseudoType}))

Can you help me understand how much impact this is having on you, how big of a problem it's causing for you? We're planning on doing a big sweep later to fix a bunch of panics, but are currently pretty focused on 0.13 feature work so I want to understand the impact for you in order to prioritize our work.

@danieldreier danieldreier added the v0.12 Issues (primarily bugs) reported against v0.12 releases label Apr 29, 2020
@throwaway8787
Copy link

Since I can't have defaults on an object in a list, I've got:

variable "security_group_rules" {
  description = "A list of security group rules"
  type = list(map(any))
}

I pass it:

    {
      type              = "ingress"
      from_port         = 443
      to_port           = 443
      protocol          = "tcp"
      cidr_blocks       = ["0.0.0.0/0"]
      security_group_id = module.ecs_alb.security_group_id
      description       = "Allow all internet traffic to hit the ALB on 443"
    },
    {
      type                     = "egress"
      from_port                = 80
      to_port                  = 80
      protocol                 = "tcp"
      security_group_id = module.ecs_alb.security_group_id
      source_security_group_id = aws_security_group.security_group.id
      description              = "Allow the ALB to talk to the instance on 80"
    }
````


And I get the following crash:
````
anic: inconsistent map element types (cty.Number then cty.String)

goroutine 295 [running]:
github.com/zclconf/go-cty/cty.MapVal(0xc000759278, 0xc000759200, 0xc0004a4048, 0x4, 0xc0007593f0)
        /opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/[email protected]/cty/value_init.go:207 +0x538
github.com/zclconf/go-cty/cty/convert.conversionObjectToMap.func2(0x236fce0, 0xc000b97b00, 0x1b45b80, 0xc0018aeab0, 0xc0018ad020, 0x2, 0x2, 0xc000056f00, 0xc0007594c0, 0x4136f5, ...)
        /opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion_collection.go:338 +0x555
github.com/zclconf/go-cty/cty/convert.getConversion.func1(0x236fce0, 0xc000b97b00, 0x1b45b80, 0xc0018aeab0, 0xc000707ff0, 0x1, 0x1, 0x1b45b80, 0xc0018aeab0, 0x786057, ...)
        /opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion.go:46 +0x1ad
github.com/zclconf/go-cty/cty/convert.conversionTupleToList.func2(0x236fd60, 0xc0018aca80, 0x1a78780, 0xc0018acaa0, 0xc000707ff0, 0x1, 0x1, 0xc000066700, 0x10, 0x10, ...)
        /opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion_collection.go:257 +0x45c
github.com/zclconf/go-cty/cty/convert.getConversion.func1(0x236fd60, 0xc0018aca80, 0x1a78780, 0xc0018acaa0, 0x0, 0x0, 0x0, 0xc0018afec0, 0xc000707fe0, 0x236fc60, ...)
        /opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion.go:46 +0x1ad
github.com/zclconf/go-cty/cty/convert.retConversion.func1(0x236fd60, 0xc0018aca80, 0x1a78780, 0xc0018acaa0, 0xc000707fe0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/[email protected]/cty/convert/conversion.go:179 +0x6b
github.com/zclconf/go-cty/cty/convert.Convert(0x236fd60, 0xc0018aca80, 0x1a78780, 0xc0018acaa0, 0x236fc60, 0xc00055b7a0, 0x0, 0x236fd60, 0xc0018aca80, 0x1a78780, ...)
        /opt/teamcity-agent/work/9e329aa031982669/pkg/mod/github.com/zclconf/[email protected]/cty/convert/public.go:51 +0x1af
github.com/hashicorp/terraform/terraform.(*EvalModuleCallArgument).Eval(0xc0010693c0, 0x23a4a00, 0xc000ba0000, 0x2, 0x2, 0xc000952000, 0x47)
        /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval_variable.go:77 +0x160
github.com/hashicorp/terraform/terraform.EvalRaw(0x232be80, 0xc0010693c0, 0x23a4a00, 0xc000ba0000, 0x32, 0x0, 0x0, 0x32)
        /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval.go:57 +0x131
github.com/hashicorp/terraform/terraform.(*EvalOpFilter).Eval(0xc0018aec00, 0x23a4a00, 0xc000ba0000, 0x2, 0x2, 0xc000aa6b38, 0x42b8a1)
        /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval_filter_operation.go:37 +0x4c
github.com/hashicorp/terraform/terraform.EvalRaw(0x232bec0, 0xc0018aec00, 0x23a4a00, 0xc000ba0000, 0x14, 0xbfa32e353369eded, 0xcf4f3175, 0x32)
        /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval.go:57 +0x131
github.com/hashicorp/terraform/terraform.(*EvalSequence).Eval(0xc0018acac0, 0x23a4a00, 0xc000ba0000, 0x2, 0x2, 0xef49ed, 0x232c560)
        /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval_sequence.go:20 +0xfd
github.com/hashicorp/terraform/terraform.EvalRaw(0x232c020, 0xc0018acac0, 0x23a4a00, 0xc000ba0000, 0x1b36460, 0x33d75e5, 0x1a9dda0, 0xc000707ca0)
        /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval.go:57 +0x131
github.com/hashicorp/terraform/terraform.Eval(0x232c020, 0xc0018acac0, 0x23a4a00, 0xc000ba0000, 0xc0018acac0, 0x232c020, 0xc0018acac0, 0x0)
        /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/eval.go:35 +0x4d
github.com/hashicorp/terraform/terraform.(*Graph).walk.func1(0x1cf7480, 0xc0001ba8c0, 0x0, 0x0, 0x0)
        /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/graph.go:90 +0xf40
github.com/hashicorp/terraform/dag.(*Walker).walkVertex(0xc0005d5580, 0x1cf7480, 0xc0001ba8c0, 0xc000cd6000)
        /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/dag/walk.go:392 +0x353
created by github.com/hashicorp/terraform/dag.(*Walker).Update
        /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/dag/walk.go:314 +0xa9b
````

Terraform version:
`v0.12.23`

@danieldreier
Copy link
Contributor

I wonder if this is the same issue as #23508. Linking for future review.

@danieldreier danieldreier added the confirmed a Terraform Core team member has reproduced this issue label May 13, 2020
@mildwonkey
Copy link
Contributor

This has been fixed in the upstream library (zclconf/go-cty#47), and the fix will be included in the upcoming 0.13 release. Thank you for reporting it!

@mildwonkey mildwonkey added this to the v0.13.0 milestone May 18, 2020
@yves-vogl
Copy link
Author

Sorry for delayed answer. It worked around this issue but are happy that it's fixed. Thank you!

@ghost
Copy link

ghost commented Jun 18, 2020

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.

@ghost ghost locked and limited conversation to collaborators Jun 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug confirmed a Terraform Core team member has reproduced this issue crash v0.12 Issues (primarily bugs) reported against v0.12 releases
Projects
None yet
Development

No branches or pull requests

4 participants