0
votes

I'm running terraform version 0.12.24, on plan I get the following error:

Configuring remote state backend...
Initializing Terraform configuration...
2020/12/08 02:35:21 [DEBUG] Using modified User-Agent: Terraform/0.12.24 TFC/ed5bcca736
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0xdb92be]

goroutine 37 [running]:
github.com/hashicorp/terraform/lang/blocktoattr.walkVariables(0x236eac0, 0xc0016e2420, 0x0, 0xc0000b2001, 0x236eac0, 0xc0016e2420, 0x0, 0x0, 0x0, 0x74)
    /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/lang/blocktoattr/variables.go:34 +0x1ae
github.com/hashicorp/terraform/lang/blocktoattr.ExpandedVariables(...)
    /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/lang/blocktoattr/variables.go:24
github.com/hashicorp/terraform/lang.ReferencesInBlock(0x236eac0, 0xc0016e2420, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc002bb3230)
    /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/lang/references.go:68 +0x66
github.com/hashicorp/terraform/terraform.(*NodeAbstractResource).References(0xc001c41ba0, 0x0, 0x0, 0x0)
    /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/node_resource_abstract.go:195 +0x33d
github.com/hashicorp/terraform/terraform.NewReferenceMap(0xc002260000, 0x86e, 0x86e, 0x86e)
    /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/transform_reference.go:492 +0x24a
github.com/hashicorp/terraform/terraform.(*ReferenceTransformer).Transform(0x3523918, 0xc001274730, 0x14, 0x0)
    /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/transform_reference.go:79 +0x71
github.com/hashicorp/terraform/terraform.(*BasicGraphBuilder).Build(0xc001ddb8e8, 0x0, 0x0, 0x0, 0x3503c40, 0xc002653918, 0x4e57b0, 0xc0000b2000)
    /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/graph_builder.go:50 +0x477
github.com/hashicorp/terraform/terraform.(*PlanGraphBuilder).Build(0xc000359c70, 0x0, 0x0, 0x0, 0x1, 0x1f31e00, 0xc00171d701, 0xc002653978)
    /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/graph_builder_plan.go:65 +0xbc
github.com/hashicorp/terraform/terraform.(*Context).Graph(0xc001be22d0, 0x6, 0xc00265396e, 0xc002be2200, 0x47, 0x14, 0xbfebd77acf8e1043)
    /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/context.go:292 +0x1b8
github.com/hashicorp/terraform/terraform.(*Context).Validate(0xc001be22d0, 0x0, 0x0, 0x0)
    /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/terraform/context.go:675 +0xc9
github.com/hashicorp/terraform/backend/local.(*Local).context(0xc00043a1a0, 0xc0004d6c40, 0x1, 0x1, 0x2, 0xc0006d4180, 0x1, 0x2, 0x0)
    /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/backend/local/backend_local.go:120 +0x974
github.com/hashicorp/terraform/backend/local.(*Local).opPlan(0xc00043a1a0, 0x236e140, 0xc00063a900, 0x236e140, 0xc00063a940, 0xc0004d6c40, 0xc00063a8c0)
    /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/backend/local/backend_plan.go:70 +0x2a3
github.com/hashicorp/terraform/backend/local.(*Local).Operation.func1(0xc0006bbb00, 0xc0006bbb10, 0xc0006bbb30, 0xc0004d6c40, 0xc00043a1a0, 0xc00063a8c0, 0xc0006bbae0, 0x236e140, 0xc00063a900, 0x236e140, ...)
    /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/backend/local/backend.go:350 +0x135
created by github.com/hashicorp/terraform/backend/local.(*Local).Operation
    /opt/teamcity-agent/work/9e329aa031982669/src/github.com/hashicorp/terraform/backend/local/backend.go:334 +0x36b

I've got the following changes in my tf to these resources

  • aws_db_proxy_target
  • aws_db_proxy_default_target_group
  • aws_db_proxy

When i switch the aws provider to 3.20.0 the faults no longer happen. however, the version the rest of the repo requires 2.x.

I try to use multiple providers:

provider "aws" {
  version = "~> 2.60.0"
  region  = "us-west-2"
}

provider "aws" {
  version = "~> 3.20.0"
  region  = "us-west-2"
  alias   = "version_3"
}


module "my-module" 
  ...
  ...
  providers = {
    aws = aws.version_3
  }
}

however running terraform init returns:

No provider "aws" plugins meet the constraint " < 4.0, < 4.0,>= 2.0,>= 2.0,>= 2.25,>= 2.42,>= 2.42,>= 2.49,>= 2.49,>= 2.49,>= 2.49,>= 2.49,~> 2.0,~> 2.0,~> 2.0,~> 2.0,~> 2.0,~> 2.0,~> 2.0,~> 2.0,~> 2.0,~> 2.60.0,~> 3.20.0".

The version constraint is derived from the "version" argument within the
provider "aws" block in configuration. Child modules may also apply
provider version constraints. To view the provider versions requested by each
module in the current configuration, run "terraform providers".

To proceed, the version constraints for this provider must be relaxed by
either adjusting or removing the "version" argument in the provider blocks
throughout the configuration.

- Downloading plugin for provider "template" (hashicorp/template) 2.2.0...

Error: no suitable version is available
1
This seems as tf bug. Are you able to try with newer tf version? - Marcin
the latest version seems to be .29. I've tried that but it seems to have the same issue. - sebastian
There are a bunch of segfaults in 0.12 that are fixed in 0.13 since that was a core objective in the roadmap. I have no idea if upgrading as an option, but try this in parallel with 0.13 and the issue may disappear. - Matt Schuchard
interestingly when i switch the aws provider to 3.20.0 the faults no longer happen. however, the version the rest of the repo requires 2.x. - sebastian

1 Answers

0
votes

I had this issue before with multiple providers. In the end I embedded that second provider block with the alias inside the module itself and it worked. Obviously I would recommend you pass any sensitive or changing values in that module as a variable.

It’s not the most elegant way but it got the job done for me. Hopefully it does the same for you.

Good luck!