hashicorp / terraform

Terraform enables you to safely and predictably create, change, and improve infrastructure. It is a source-available tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
https://www.terraform.io/
Other
42.53k stars 9.52k forks source link

Panic on unexpected value passed to validation #22216

Closed marcotesch closed 5 years ago

marcotesch commented 5 years ago

Terraform Version

Terraform v0.12.5

Crash Output

panic: reflect: call of reflect.Value.Type on zero Value
2019-07-26T11:52:48.026+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: 
2019-07-26T11:52:48.026+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: goroutine 66 [running]:
2019-07-26T11:52:48.026+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: reflect.Value.Type(0x0, 0x0, 0x0, 0x38, 0x0)
2019-07-26T11:52:48.026+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/goenv/versions/1.12.6/src/reflect/value.go:1813 +0x169
2019-07-26T11:52:48.026+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.schemaMap.validatePrimitive(0xc00058d4a0, 0xc000cc1f20, 0x18, 0x0, 0x0, 0xc00015cc00, 0xc000ae3350, 0x1, 0x3d0c6e0, 0xc000c50960, ...)
2019-07-26T11:52:48.026+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/schema.go:1694 +0xc8
2019-07-26T11:52:48.026+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.schemaMap.validateType(0xc00058d4a0, 0xc000cc1f20, 0x18, 0x0, 0x0, 0xc00015cc00, 0xc000ae3350, 0x4088cc, 0xc00001e000, 0x4394cc0, ...)
2019-07-26T11:52:48.026+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/schema.go:1779 +0x56f
2019-07-26T11:52:48.026+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.schemaMap.validateList(0xc00058d4a0, 0x4baf375, 0x16, 0x3d0c6e0, 0xc000c50960, 0xc00015ef00, 0xc000ae3350, 0x0, 0x41a7a00, 0xc000ae3380, ...)
2019-07-26T11:52:48.026+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/schema.go:1495 +0x86c
2019-07-26T11:52:48.026+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.schemaMap.validateType(0xc00058d4a0, 0x4baf375, 0x16, 0x3d0c6e0, 0xc000c50960, 0xc00015ef00, 0xc000ae3350, 0x0, 0x0, 0x0, ...)
2019-07-26T11:52:48.026+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/schema.go:1775 +0x9e
2019-07-26T11:52:48.026+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.schemaMap.validate(0xc00058d4a0, 0x4baf375, 0x16, 0xc00015ef00, 0xc000ae3350, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/schema.go:1382 +0x213
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.schemaMap.validateObject(0xc00058d4a0, 0x0, 0x0, 0xc00058d4a0, 0xc000ae3350, 0x4b8d20d, 0xc000cb8b10, 0xf, 0xc000510601, 0x7a0000c000c509e0, ...)
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/schema.go:1661 +0x1c6
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.schemaMap.Validate(...)
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/schema.go:677
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Validate(0xc0004e2b80, 0xc000ae3350, 0xc000cb8b10, 0xf, 0xc0002343c8, 0x1, 0x40, 0x0)
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:357 +0x5e
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).ValidateResource(0xc000230280, 0xc000cb8b10, 0xf, 0xc000ae3350, 0xc000b3ff40, 0xc000ae3350, 0xc00011f7e8, 0x41a7a00, 0xc000ae32f0, 0x0)
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:242 +0x1d8
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/plugin.(*GRPCProviderServer).ValidateResourceTypeConfig(0xc00011ef68, 0x5419c40, 0xc0004fd3e0, 0xc00087eec0, 0xc00011ef68, 0xc0004fd3e0, 0xc0006a1bd0)
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/plugin/grpc_provider.go:206 +0x1d9
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/internal/tfplugin5._Provider_ValidateResourceTypeConfig_Handler(0x4a66240, 0xc00011ef68, 0x5419c40, 0xc0004fd3e0, 0xc000c85680, 0x0, 0x5419c40, 0xc0004fd3e0, 0xc000c92500, 0x4bf)
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/internal/tfplugin5/tfplugin5.pb.go:3109 +0x23e
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001cf800, 0x543b580, 0xc0005a6900, 0xc000012b00, 0xc00059ee10, 0x925da70, 0x0, 0x0, 0x0)
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc/server.go:966 +0x470
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc.(*Server).handleStream(0xc0001cf800, 0x543b580, 0xc0005a6900, 0xc000012b00, 0x0)
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc/server.go:1245 +0xd25
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc00003a4d0, 0xc0001cf800, 0x543b580, 0xc0005a6900, 0xc000012b00)
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc/server.go:685 +0x9f
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: created by github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc.(*Server).serveStreams.func1
2019-07-26T11:52:48.027+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc/server.go:683 +0xa1
2019-07-26T11:52:48.030+0200 [DEBUG] plugin: plugin process exited: path=/home/mtesch/Documents/Kunden/Allianz/a2l-infra-shared-modules/rds/.terraform/plugins/linux_amd64/terraform-provider-aws_v2.21.0_x4 pid=28714 error="exit status 2"
2019/07/26 11:52:48 [ERROR] <root>: eval: *terraform.EvalDiff, err: rpc error: code = Unavailable desc = transport is closing
2019/07/26 11:52:48 [ERROR] <root>: eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2019/07/26 11:52:48 [TRACE] [walkPlan] Exiting eval tree: aws_db_instance.db_instance
2019/07/26 11:52:48 [TRACE] vertex "aws_db_instance.db_instance": visit complete
2019/07/26 11:52:48 [TRACE] vertex "aws_db_instance.db_instance": dynamic subgraph encountered errors
2019/07/26 11:52:48 [TRACE] vertex "aws_db_instance.db_instance": visit complete
2019/07/26 11:52:48 [ERROR] <root>: eval: *terraform.EvalDiff, err: rpc error: code = Unavailable desc = transport is closing
2019/07/26 11:52:48 [ERROR] <root>: eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2019/07/26 11:52:48 [TRACE] [walkPlan] Exiting eval tree: aws_kms_alias.db_kms_key_alias[0]
2019/07/26 11:52:48 [TRACE] dag/walk: upstream of "output.db_instance_endpoint" errored, so skipping
2019/07/26 11:52:48 [TRACE] vertex "aws_kms_alias.db_kms_key_alias[0]": visit complete
2019/07/26 11:52:48 [TRACE] vertex "aws_kms_alias.db_kms_key_alias": dynamic subgraph encountered errors
2019/07/26 11:52:48 [TRACE] vertex "aws_kms_alias.db_kms_key_alias": visit complete
2019/07/26 11:52:48 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2019/07/26 11:52:48 [TRACE] dag/walk: upstream of "provider.aws (close)" errored, so skipping
2019/07/26 11:52:48 [TRACE] dag/walk: upstream of "root" errored, so skipping
2019/07/26 11:52:48 [INFO] backend/local: plan operation completed
2019/07/26 11:52:48 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
2019/07/26 11:52:48 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock
2019-07-26T11:52:48.031+0200 [DEBUG] plugin: plugin exited

Expected Behavior

terraform plan for aws_db_instance should succeed.

Actual Behavior

terraform crashes

Steps to Reproduce

terraform plan with a "aws_db_instance" resource

ghost commented 5 years ago

This issue has been automatically migrated to terraform-providers/terraform-provider-aws#9519 because it looks like an issue with that provider. If you believe this is not an issue with the provider, please reply to terraform-providers/terraform-provider-aws#9519.

teamterraform commented 5 years ago

Hello, apologies for the movement/closure, this is indeed related to core Terraform!

However, we need more information, that is, if could share your config, to determine how an unexpected value was passed through into the Provider SDK validation function.

marcotesch commented 5 years ago
locals {
  create_security_group = var.existing_security_group_id == "" ? true : false
  create_kms_key        = var.existing_kms_key_arn == null ? true : false
  create_subnet_group   = var.db_subnet_group_name == null ? true : false
  skip_final_snapshot   = var.final_snapshot_identifier == null ? true : false
  base_logs_exports     = ["alert", "audit", "error", "general", "listener", "slowquery", "trace"]
  postgres_logs_exports = ["postgresql", "upgrade"]
  enabled_logs_exports  = var.db_engine == "postgres" ? local.base_logs_exports : local.postgres_logs_exports
  logs_exports          = var.enabled_cloudwatch_logs_exports == null ? local.enabled_logs_exports : var.enabled_cloudwatch_logs_exports
}

data "aws_subnet" "provided_subnet" {
  id = var.subnet_ids[0]
}

data "aws_caller_identity" "identity" {}

resource "aws_db_instance" "db_instance" {
  identifier                          = var.db_instance_identifier
  allow_major_version_upgrade         = var.allow_major_version_upgrade
  auto_minor_version_upgrade          = var.auto_minor_version_upgrade
  availability_zone                   = data.aws_subnet.provided_subnet.availability_zone
  engine                              = var.db_engine.engine_name
  engine_version                      = var.db_engine.engine_version
  iam_database_authentication_enabled = var.iam_database_authentication
  instance_class                      = var.db_instance_class
  maintenance_window                  = var.maintenance_window
  multi_az                            = var.multi_az_deployment
  name                                = var.db_name
  option_group_name                   = var.option_group_name
  parameter_group_name                = var.parameter_group_name
  db_subnet_group_name                = local.create_subnet_group ? aws_db_subnet_group.db_subnet_group[0].name : var.db_subnet_group_name
  password                            = var.db_password
  port                                = var.db_port
  publicly_accessible                 = var.publicly_accessible
  snapshot_identifier                 = var.db_snapshot_identifier
  username                            = var.db_username
  vpc_security_group_ids              = [local.create_security_group ? aws_security_group.security_group[0].id : var.existing_security_group_id]

  # Monitoring/Logging options
  enabled_cloudwatch_logs_exports = local.logs_exports
  monitoring_interval             = var.monitoring_interval
  monitoring_role_arn             = var.monitoring_role_arn

  # Backup Options
  backup_retention_period   = var.backup_retention_period
  backup_window             = var.backup_window
  final_snapshot_identifier = var.final_snapshot_identifier
  skip_final_snapshot       = local.skip_final_snapshot

  # Oracle DB specific
  character_set_name = var.character_set_name
  license_model      = var.license_model
  timezone           = var.db_timezone

  # Storage Options / Storage Autoscaling
  # (use max_allocated_storage > allocated_storage to enable storage Autoscaling)
  allocated_storage     = var.allocated_storage
  max_allocated_storage = var.max_allocated_storage
  storage_type          = var.db_storage_type
  iops                  = var.db_storage_iops
  kms_key_id            = local.create_kms_key ? aws_kms_key.db_kms_key[0].arn : var.existing_kms_key_arn
  storage_encrypted     = true

  # AWS Directory Service Configuration
  domain               = var.domain
  domain_iam_role_name = var.domain_iam_role_name

  # Tags and Snapshot Tagging
  tags                  = merge(var.tags, map("Name", var.db_instance_identifier))
  copy_tags_to_snapshot = true

  # Switch to apply changes to configuration immediately,
  # else they will be executed during the next maintenance window,
  # which leads to stale terraform plan and state data
  apply_immediately = var.apply_immediately

  # Activate/Deactivate RDS Deletion Protection for the DB instance
  deletion_protection = var.deletion_protection
}

resource "aws_kms_key" "db_kms_key" {
  count                   = local.create_kms_key ? 1 : 0
  deletion_window_in_days = 30
  description             = "Default/Created KMS Key for DB Instance"
  enable_key_rotation     = true
  policy                  = templatefile("${path.module}/policies/default_kms_key_policy.json", { ACCOUNT_ID = data.aws_caller_identity.identity.account_id })
  tags                    = var.tags
}

resource "aws_kms_alias" "db_kms_key_alias" {
  count         = local.create_kms_key ? 1 : 0
  name_prefix   = "alias/default_rds_kms_key"
  target_key_id = aws_kms_key.db_kms_key[0].id
}

resource "aws_security_group" "security_group" {
  count       = local.create_security_group ? 1 : 0
  name_prefix = var.security_group_name_prefix
  description = "Default/Created Security Group for RDS DB Instance"
  vpc_id      = data.aws_subnet.provided_subnet.vpc_id

  tags = merge(var.tags, map("Name", var.security_group_name_prefix))
}

resource "aws_security_group_rule" "in_src_cidr" {
  count             = local.create_security_group ? length(var.sg_in_cidr_rules) : 0
  type              = "ingress"
  protocol          = var.sg_in_cidr_rules[count.index].protocol
  cidr_blocks       = var.sg_in_cidr_rules[count.index].cidr_blocks
  security_group_id = aws_security_group.security_group[0].id
  from_port         = var.sg_in_cidr_rules[count.index].from_port
  to_port           = var.sg_in_cidr_rules[count.index].to_port
  description       = var.sg_in_cidr_rules[count.index].description
  self              = var.sg_in_cidr_rules[count.index].self
}

resource "aws_security_group_rule" "eg_src_cidr" {
  count             = local.create_security_group ? length(var.sg_eg_cidr_rules) : 0
  type              = "egress"
  protocol          = var.sg_eg_cidr_rules[count.index].protocol
  cidr_blocks       = var.sg_eg_cidr_rules[count.index].cidr_blocks
  security_group_id = aws_security_group.security_group[0].id
  from_port         = var.sg_eg_cidr_rules[count.index].from_port
  to_port           = var.sg_eg_cidr_rules[count.index].to_port
  description       = var.sg_eg_cidr_rules[count.index].description
  self              = var.sg_eg_cidr_rules[count.index].self
}

resource "aws_security_group_rule" "in_src_sgsrc" {
  count                    = local.create_security_group ? length(var.sg_in_sgsrc_rules) : 0
  type                     = "ingress"
  protocol                 = var.sg_in_sgsrc_rules[count.index].protocol
  source_security_group_id = var.sg_in_sgsrc_rules[count.index].source_security_group_id
  security_group_id        = aws_security_group.security_group[0].id
  from_port                = var.sg_in_sgsrc_rules[count.index].from_port
  to_port                  = var.sg_in_sgsrc_rules[count.index].to_port
  description              = var.sg_in_sgsrc_rules[count.index].description
  self                     = var.sg_in_sgsrc_rules[count.index].self
}

resource "aws_security_group_rule" "eg_src_sgsrc" {
  count                    = local.create_security_group ? length(var.sg_eg_sgsrc_rules) : 0
  type                     = "egress"
  protocol                 = var.sg_in_sgsrc_rules[count.index].protocol
  source_security_group_id = var.sg_in_sgsrc_rules[count.index].source_security_group_id
  security_group_id        = aws_security_group.security_group[0].id
  from_port                = var.sg_in_sgsrc_rules[count.index].from_port
  to_port                  = var.sg_in_sgsrc_rules[count.index].to_port
  description              = var.sg_in_sgsrc_rules[count.index].description
  self                     = var.sg_in_sgsrc_rules[count.index].self
}

resource "aws_db_subnet_group" "db_subnet_group" {
  count       = local.create_subnet_group ? 1 : 0
  description = "Default/Created DB Subnet Group for RDS DB instance"
  name_prefix = var.db_subnet_group_name_prefix
  subnet_ids  = var.subnet_ids

  tags = merge(var.tags, map("Name", var.db_subnet_group_name_prefix))
}
 variable "db_instance_identifier" {
  description = "Identifier for the RDS DB Instance"
  type        = string
}

variable "db_name" {
  description = "Name for the initial database to be created, within the DB Instance"
  type        = string
  default     = "defaultdb"
}

variable "db_engine" {
  description = "DB engine for the RDS DB Instance"
  type = object({
    engine_name    = string,
    engine_version = string
  })
}

variable "final_snapshot_identifier" {
  description = "Identifier for a Final DB snapshot (created when DB instance is deleted)"
  type        = string
  default     = null
}

variable "iam_database_authentication" {
  description = "Enables AWS IAM for DB authentication"
  type        = bool
  default     = false
}

variable "db_instance_class" {
  description = "DB Instance class to be used for RDS DB Instance"
  type        = string
}

variable "db_storage_type" {
  description = "AWS storage type for the RDS DB Storage"
  type        = string
  default     = "gp2"
}

variable "db_storage_iops" {
  description = "IOPS for DB Storage (if storage_type = io1)"
  type        = number
  default     = null
}

variable "allocated_storage" {
  description = "Size of the allocated storage for the DB Instance"
  type        = number
}

variable "existing_kms_key_arn" {
  description = "ARN of the KMS Key used for storage at rest encryption"
  type        = string
  default     = null
}

variable "backup_window" {
  description = "Daily backup window for auto DB backups (e.g. 08:00-09:00)"
  type        = string
}

variable "monitoring_interval" {
  description = "Interval in seconds in which to collect enhanced metrics"
  type        = number
  default     = 0 # Enhanced Monitoring Disabled
}

variable "monitoring_role_arn" {
  description = "IAM Role vor RDS to publish enhanced metrics to CloudWatch"
  type        = string
  default     = null
}

variable "multi_az_deployment" {
  description = "Specifies if the RDS DB instance is setup in a HA/Multi AZ deployment"
  type        = bool
}

variable "deletion_protection" {
  description = "Enable deletion protection for the DB Instance"
  type        = bool
}

variable "domain" {
  description = "AWS Directory Service Domain ID to launch the DB Instance in"
  type        = string
  default     = null
}

variable "domain_iam_role_name" {
  description = "IAM Role name to access the AWS Directory Service Domain"
  type        = string
  default     = null
}

variable "max_allocated_storage" {
  description = "Size of the maximal allocated storage for the DB Instance"
  type        = number
  default     = null
}

variable "character_set_name" {
  description = "See RDS for Oracle documentation for valid values"
  type        = string
  default     = null
}

variable "license_model" {
  description = "License model information for this DB instance"
  type        = string
  default     = null
}

variable "maintenance_window" {
  description = "Time window in which to perform maintenance tasks on the DB (e.g. Sun:09:00-Sun:10:00)"
  type        = string
}

variable "allow_major_version_upgrade" {
  description = "Indicator to allow automatical major DB Version upgrades"
  type        = bool
  default     = false
}

variable "enabled_cloudwatch_logs_exports" {
  description = "Exported DB engine logs to CloudWatch Logs"
  type        = list(string)
  default     = null
}

variable "auto_minor_version_upgrade" {
  description = "Indicator to allow automatical minor DB Version upgrades"
  type        = bool
  default     = true
}

variable "apply_immediately" {
  description = "Apply changes to DB instance immediately (might cause downtime)"
  type        = bool
  default     = false
}

variable "backup_retention_period" {
  description = "Retention period in days for RDS auto backups"
  type        = number
  default     = 7
}

variable "option_group_name" {
  description = "Name of a specific AWS RDS Option Group to associate"
  type        = string
  default     = null
}

variable "parameter_group_name" {
  description = "Name of a specific AWS RDS Parameter Group to associate"
  type        = string
  default     = null
}

variable "db_password" {
  description = "Password for the master DB-User (should be changed and stored secretly)"
  type        = string
}

variable "db_snapshot_identifier" {
  description = "RDS snapshot identifier from which to create the RDS DB instance"
  type        = string
  default     = null
}

variable "db_timezone" {
  description = "Timezone for MSSQL DB (s. MSSQL User Guide)"
  type        = string
  default     = null
}

variable "db_username" {
  description = "Name of the master user for the RDS DB instance"
  type        = string
  default     = "masterdbuser"
}

variable "tags" {
  description = "Map containing tags, that are shared between all modules."
  type        = map(string)
}

variable "existing_security_group_id" {
  type        = string
  description = "ID of an (to be used) existing security group"
  default     = null
}

variable "security_group_name_prefix" {
  type        = string
  description = "Name prefix of the Security Group which should be created"
  default     = "tf-sg"
}

variable "sg_in_cidr_rules" {
  type = list(object({
    cidr_blocks = list(string),
    from_port   = number,
    to_port     = number,
    description = string,
    protocol    = string,
    self        = bool
  }))

  description = "Ingress Security Group Rules to be created (CIDR, based)"
  default     = []
}

variable "sg_eg_cidr_rules" {
  type = list(object({
    cidr_blocks = list(string),
    from_port   = number,
    to_port     = number,
    description = string,
    protocol    = string,
    self        = bool
  }))

  description = "Egress Security Group Rules to be created (CIDR, based)"
  default     = []
}

variable "sg_in_sgsrc_rules" {
  type = list(object({
    source_security_group_id = string,
    from_port                = number,
    to_port                  = number,
    description              = string,
    protocol                 = string,
    self                     = bool
  }))

  description = "Ingress Security Group Rules to be created (SG-ID, based)"
  default     = []
}

variable "sg_eg_sgsrc_rules" {
  type = list(object({
    source_security_group_id = string,
    from_port                = number,
    to_port                  = number,
    description              = string,
    protocol                 = string,
    self                     = bool
  }))

  description = "Egress Security Group Rules to be created (SG-ID, based)"
  default     = []
}

variable "db_port" {
  description = "Port on which the RDS instance should provide DB access"
  type        = string
  default     = null
}

variable "publicly_accessible" {
  description = "Enable public access for the RDS DB instance"
  type        = bool
  default     = false
}

variable "region" {
  description = "Region in which to deploy the AWS resources"
  default     = "eu-central-1"
  type        = string
}

variable "subnet_ids" {
  type        = list(string)
  description = "Subnet Ids for the RDS DB instance (First list item is prefered for Master)"
}

variable "db_subnet_group_name" {
  description = "Name of an existing RDS DB subnet group to use for the RDS DB instance"
  type        = string
  default     = null
}

variable "db_subnet_group_name_prefix" {
  description = "Name prefix of the DB Subnet Group which should be created"
  type        = string
  default     = "tf-db-subnet-group"
}
marcotesch commented 5 years ago

Seems that the problem still exists:

Terraform v0.12.6-dev

Shouldn't it be fixed when building terraform from master?

panic: reflect: call of reflect.Value.Type on zero Value
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: 
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: goroutine 48 [running]:
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: reflect.Value.Type(0x0, 0x0, 0x0, 0x38, 0x3)
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/goenv/versions/1.12.6/src/reflect/value.go:1813 +0x169
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.schemaMap.validatePrimitive(0xc0005d3b60, 0xc00087fc20, 0x18, 0x0, 0x0, 0xc0005f0e00, 0xc00037e8a0, 0x1, 0x3d0c6e0, 0xc000be1ec0, ...)
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/schema.go:1694 +0xc8
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.schemaMap.validateType(0xc0005d3b60, 0xc00087fc20, 0x18, 0x0, 0x0, 0xc0005f0e00, 0xc00037e8a0, 0x4088cc, 0xc00001e000, 0x4394cc0, ...)
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/schema.go:1779 +0x56f
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.schemaMap.validateList(0xc0005d3b60, 0x4baf375, 0x16, 0x3d0c6e0, 0xc000be1ec0, 0xc0005f5100, 0xc00037e8a0, 0x0, 0x41a7a00, 0xc00037e8d0, ...)
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/schema.go:1495 +0x86c
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.schemaMap.validateType(0xc0005d3b60, 0x4baf375, 0x16, 0x3d0c6e0, 0xc000be1ec0, 0xc0005f5100, 0xc00037e8a0, 0x0, 0x0, 0x0, ...)
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/schema.go:1775 +0x9e
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.schemaMap.validate(0xc0005d3b60, 0x4baf375, 0x16, 0xc0005f5100, 0xc00037e8a0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/schema.go:1382 +0x213
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.schemaMap.validateObject(0xc0005d3b60, 0x0, 0x0, 0xc0005d3b60, 0xc00037e8a0, 0x4b8d20d, 0xc00087b6c0, 0xf, 0xc000214b01, 0x180000c000be1f00, ...)
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/schema.go:1661 +0x1c6
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.schemaMap.Validate(...)
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/schema.go:677
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.(*Resource).Validate(0xc0005d9b80, 0xc00037e8a0, 0xc00087b6c0, 0xf, 0xc00015d2a0, 0x1, 0x40, 0x0)
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/resource.go:357 +0x5e
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema.(*Provider).ValidateResource(0xc000326400, 0xc00087b6c0, 0xf, 0xc00037e8a0, 0xc000214540, 0xc00037e8a0, 0xc000880468, 0x41a7a00, 0xc00037e840, 0x0)
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/schema/provider.go:242 +0x1d8
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/plugin.(*GRPCProviderServer).ValidateResourceTypeConfig(0xc00000edb8, 0x5419c40, 0xc00020e9c0, 0xc000c30980, 0xc00000edb8, 0xc00020e9c0, 0xc000be7bd0)
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/helper/plugin/grpc_provider.go:206 +0x1d9
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/internal/tfplugin5._Provider_ValidateResourceTypeConfig_Handler(0x4a66240, 0xc00000edb8, 0x5419c40, 0xc00020e9c0, 0xc0008799f0, 0x0, 0x5419c40, 0xc00020e9c0, 0xc000961200, 0x591)
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/github.com/hashicorp/terraform/internal/tfplugin5/tfplugin5.pb.go:3109 +0x23e
2019-07-30T11:58:40.113+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc.(*Server).processUnaryRPC(0xc000608780, 0x543b580, 0xc000609380, 0xc000b4a200, 0xc0004033e0, 0x925da70, 0x0, 0x0, 0x0)
2019-07-30T11:58:40.114+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc/server.go:966 +0x470
2019-07-30T11:58:40.114+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc.(*Server).handleStream(0xc000608780, 0x543b580, 0xc000609380, 0xc000b4a200, 0x0)
2019-07-30T11:58:40.114+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc/server.go:1245 +0xd25
2019-07-30T11:58:40.114+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc00079e140, 0xc000608780, 0x543b580, 0xc000609380, 0xc000b4a200)
2019-07-30T11:58:40.114+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc/server.go:685 +0x9f
2019-07-30T11:58:40.114+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4: created by github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc.(*Server).serveStreams.func1
2019-07-30T11:58:40.114+0200 [DEBUG] plugin.terraform-provider-aws_v2.21.0_x4:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-aws/vendor/google.golang.org/grpc/server.go:683 +0xa1
jbardin commented 5 years ago

@marcotesch, thanks for testing. It does not look like you're using a provider built against the master branch of terraform. That stack trace appears to be from the official aws v2.21.0 release. This change effect providers, not terraform core.

marcotesch commented 5 years ago

@jbardin, you are right I built terraform not the provider. @bflad might help to have an idea if the AWS provider 2.22.0 which is currently in development will fix this when released. Or is a provider-sdk version bump required?

ghost commented 5 years ago

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.