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.35k stars 9.49k forks source link

Terraform crashes when creating resource #28548

Closed anuradhaarao closed 3 years ago

anuradhaarao commented 3 years ago

Terraform Version

0.15

Terraform Configuration Files

resource "azurerm_app_service_slot" "example" {
  name                = "example"
  app_service_name    = azurerm_app_service.rp.name
  location            = azurerm_resource_group.rg_services.location
  resource_group_name = azurerm_resource_group.rg_services.name
  app_service_plan_id = azurerm_app_service_plan.app-service-plan.id
  https_only          = false

  site_config {
    dotnet_framework_version  = "v4.0"
    always_on                 = true
    use_32_bit_worker_process = false
    cors {
      allowed_origins = ["https://${local.prefix}-ui.${var.basedomain}", "https://${var.basedomain}"]
    }
  }

  app_settings = {
    "VaultClientId"                       = "${var.vault_client_id}"
    "VaultUri"                            = "${azurerm_key_vault.wem-keyvault.vault_uri}"
    "APPINSIGHTS_INSTRUMENTATIONKEY"      = "${azurerm_application_insights.AppServices.instrumentation_key}"
    "APPINSIGHTS_PORTALINFO"              = "ASP.NETCORE"
    "APPINSIGHTS_PROFILERFEATURE_VERSION" = "1.0.0"
    "APPINSIGHTS_SNAPSHOTFEATURE_VERSION" = "1.0.0"
    "InstrumentationKey"                  = "${azurerm_application_insights.AppServices.instrumentation_key}"
    "ShutdownVMToggle"                    = "true"
    "Validate"                            = "true"
    "VMQueueName"                         = "${azurerm_servicebus_queue.powersaving.name}"
    "WEBSITE_DISABLE_MSI"                 = "false"
    "WEBSITE_DYNAMIC_CACHE"               = "0"
  }
  connection_string{}

  lifecycle {
    ignore_changes = all
  }
}

Debug Output

Crash Output

https://gist.github.com/anuradhaarao/938b3a9813aa5108c6d35cd96053c097

Expected Behavior

Resource should have been created

Actual Behavior

panic: value is marked, so must be unmarked first

Steps to Reproduce

terraform apply

Additional Context

References

alisdair commented 3 years ago

Hi @anuradhaarao, thanks for reporting this. Unfortunately this configuration is not complete and self-contained, and we can't use it to reproduce the issue. There is also no sign of a crash in the crash log as far as I can tell. Can you supply a small, complete configuration which crashes for you?

anuradhaarao commented 3 years ago

hi @alisdair - cannot provide the entire configuration since it is sensitive.

The terraform provider crashes at "[TRACE] vertex "azurerm_app_service_slot.rp-staging": visit complete

panic: value is marked, so must be unmarked first"

while creating the resource "azurerm_app_service_slot". It says the value must be unmarked , probably similar to https://github.com/hashicorp/terraform/issues/27220.

meidlinga commented 3 years ago

Hello,

I think I have the same problem. What I did before was setting some output values to sensitive because terraform told it required now. Maybe that is a usable indicator.

The usable part of my crashlog:

2021-04-30T09:53:30.445+0200 [INFO]  Terraform version: 0.15.0
2021-04-30T09:53:30.445+0200 [INFO]  Go runtime version: go1.16.2
2021-04-30T09:53:30.445+0200 [INFO]  CLI args: []string{"/usr/bin/terraform", "apply", "-input=false"}
2021-04-30T09:53:30.445+0200 [TRACE] Stdout is not a terminal
2021-04-30T09:53:30.445+0200 [TRACE] Stderr is not a terminal
2021-04-30T09:53:30.445+0200 [TRACE] Stdin is not a terminal
[...]
2021-04-30T10:10:28.286+0200 [DEBUG] provider.terraform-provider-azurerm_v2.52.0_x5: 
2021-04-30T10:10:28.286+0200 [DEBUG] provider.terraform-provider-azurerm_v2.52.0_x5: 
2021-04-30T10:10:28.286+0200 [WARN]  Provider "provider[\"registry.terraform.io/hashicorp/azurerm\"]" produced an unexpected new value for module.backend_service.azurerm_app_service.worker, but we are tolerating it because it is using the legacy plugin SDK.
    The following problems may be the cause of any confusing errors from downstream operations:
      - .app_settings: inconsistent values for sensitive attribute
      - .logs[0].application_logs[0].azure_blob_storage: block count changed from 1 to 0
      - .site_config[0].python_version: was null, but now cty.StringVal("")
      - .site_config[0].auto_swap_slot_name: was null, but now cty.StringVal("")
      - .site_config[0].java_version: was null, but now cty.StringVal("")
      - .site_config[0].use_32_bit_worker_process: was null, but now cty.False
      - .site_config[0].php_version: was null, but now cty.StringVal("")
      - .site_config[0].app_command_line: was null, but now cty.StringVal("")
      - .site_config[0].java_container_version: was null, but now cty.StringVal("")
      - .site_config[0].java_container: was null, but now cty.StringVal("")
2021-04-30T10:10:28.286+0200 [TRACE] writeResourceInstanceState: writing current state object for module.backend_service.azurerm_app_service.worker
2021-04-30T10:10:28.287+0200 [TRACE] writeResourceInstanceState: writing current state object for module.backend_service.azurerm_app_service.worker
2021-04-30T10:10:28.288+0200 [TRACE] vertex "module.backend_service.azurerm_app_service.worker": visit complete
2021-04-30T10:10:28.288+0200 [TRACE] vertex "module.backend_service.output.app_worker_id (expand)": starting visit (*terraform.nodeExpandOutput)
2021-04-30T10:10:28.288+0200 [TRACE] vertex "module.backend_service.output.app_worker_id (expand)": expanding dynamic subgraph
2021-04-30T10:10:28.288+0200 [TRACE] Expanding output: adding module.backend_service.output.app_worker_id as *terraform.NodeApplyableOutput
2021-04-30T10:10:28.288+0200 [TRACE] vertex "module.backend_service.output.app_worker_id (expand)": entering dynamic subgraph
2021-04-30T10:10:28.288+0200 [TRACE] vertex "module.backend_service.output.app_worker_id": starting visit (*terraform.NodeApplyableOutput)
2021-04-30T10:10:28.289+0200 [TRACE] vertex "module.backend_service.output.app_worker_id": visit complete

panic: value is marked, so must be unmarked first

goroutine 1433 [running]:
github.com/zclconf/go-cty/cty.Value.assertUnmarked(...)
    /go/pkg/mod/github.com/zclconf/go-cty@v1.8.1/cty/marks.go:123
github.com/zclconf/go-cty/cty.Value.LengthInt(0x2c2e7d0, 0xc000f43850, 0x24e3220, 0xc000968c60, 0x2c2e701)
    /go/pkg/mod/github.com/zclconf/go-cty@v1.8.1/cty/value_ops.go:1045 +0x4f
github.com/zclconf/go-cty/cty.transform(0xc000f80bf0, 0x1, 0x1, 0x2c2e7d0, 0xc000f43850, 0x24e3220, 0xc000968c60, 0x2bf8258, 0xc000968db0, 0xc000968c60, ...)
    /go/pkg/mod/github.com/zclconf/go-cty@v1.8.1/cty/walk.go:175 +0x8f9
github.com/zclconf/go-cty/cty.transform(0x0, 0x0, 0x0, 0x2c2e808, 0xc000f80020, 0x23f4a00, 0xc001650c90, 0x2bf8258, 0xc000968db0, 0x0, ...)
    /go/pkg/mod/github.com/zclconf/go-cty@v1.8.1/cty/walk.go:209 +0x10ed
github.com/zclconf/go-cty/cty.TransformWithTransformer(...)
    /go/pkg/mod/github.com/zclconf/go-cty@v1.8.1/cty/walk.go:125
github.com/zclconf/go-cty/cty.Value.MarkWithPaths(0x2c2e808, 0xc000f80020, 0x23f4a00, 0xc001650c90, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /go/pkg/mod/github.com/zclconf/go-cty@v1.8.1/cty/marks.go:215 +0xc5
github.com/hashicorp/terraform/terraform.markProviderSensitiveAttributes(0xc000f268a0, 0x2c2e808, 0xc000f80020, 0x23f4a00, 0xc001650c90, 0x0, 0x13, 0xc000716306, 0x6)
    /home/circleci/project/project/terraform/evaluate.go:960 +0xbe
github.com/hashicorp/terraform/terraform.(*evaluationStateData).GetResource(0xc000bdca20, 0x4d, 0xc0009dd668, 0x13, 0xc000716306, 0x6, 0xc000059c80, 0x28, 0x8, 0x11, ...)
    /home/circleci/project/project/terraform/evaluate.go:787 +0x1333
github.com/hashicorp/terraform/lang.(*Scope).evalContext(0xc000b81d60, 0xc00000e4c0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x901cb7, 0x7fc09cc30bd0)
    /home/circleci/project/project/lang/eval.go:360 +0x206d
github.com/hashicorp/terraform/lang.(*Scope).EvalContext(...)
    /home/circleci/project/project/lang/eval.go:238
github.com/hashicorp/terraform/lang.(*Scope).EvalExpr(0xc000b81d60, 0x2c2d6c0, 0xc0009a2d20, 0x2c2e760, 0x3ce7388, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/circleci/project/project/lang/eval.go:163 +0xb6
github.com/hashicorp/terraform/terraform.(*BuiltinEvalContext).EvaluateExpr(0xc001fc4270, 0x2c2d6c0, 0xc0009a2d20, 0x2c2e760, 0x3ce7388, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /home/circleci/project/project/terraform/eval_context_builtin.go:280 +0xbb
github.com/hashicorp/terraform/terraform.(*NodeApplyableOutput).Execute(0xc0008bdf80, 0x2c64590, 0xc001fc4270, 0xc00010e001, 0xc0016f5d18, 0x40bb05, 0x243e3e0)
    /home/circleci/project/project/terraform/node_output.go:272 +0x8e4
github.com/hashicorp/terraform/terraform.(*ContextGraphWalker).Execute(0xc000c09440, 0x2c64590, 0xc001fc4270, 0x7fc09cd196f8, 0xc0008bdf80, 0x0, 0x0, 0x0)
    /home/circleci/project/project/terraform/graph_walk_context.go:127 +0xbf
github.com/hashicorp/terraform/terraform.(*Graph).walk.func1(0x2610140, 0xc0008bdf80, 0x0, 0x0, 0x0)
    /home/circleci/project/project/terraform/graph.go:59 +0xba2
github.com/hashicorp/terraform/dag.(*Walker).walkVertex(0xc000972180, 0x2610140, 0xc0008bdf80, 0xc000a04580)
    /home/circleci/project/project/dag/walk.go:381 +0x288
created by github.com/hashicorp/terraform/dag.(*Walker).Update
    /home/circleci/project/project/dag/walk.go:304 +0x1246
alisdair commented 3 years ago

cannot provide the entire configuration since it is sensitive

@anuradhaarao I think you misunderstood my request—I'm not asking for your entire original configuration, but a reduced config that we can use as a reproduction case.

@meidlinga Thanks for the additional information. This looks like a duplicate of #28535, which is fixed on the main branch and the fix will be released with 0.15.2. Closing as a result.

github-actions[bot] commented 3 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.