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.78k stars 9.56k forks source link

Terraform crash when attempting to connect to OCI and create an IAM user account resource #26708

Closed tylernelsonschuppert closed 4 years ago

tylernelsonschuppert commented 4 years ago

Terraform Version

09:12 $ terraform version
Terraform v0.13.5

A similar issue was experienced for Terraform 0.12.

Terraform Configuration Files

02-credentials.tfvars

tenancy_ocid = "REDACTED"
user_ocid = "REDACTED"
fingerprint = "REDACTED"
private_key_path = "~/.oci/oci_api_key.pem"

02-provider.tf

variable "tenancy_ocid" {
  type = string
}

variable "user_ocid" {
  type = string
}

variable "fingerprint" {
  type = string
}

variable "private_key_path" {
  type = string
}

provider "oci" {
  tenancy_ocid = var.tenancy_ocid
  user_ocid = var.user_ocid
  fingerprint = var.fingerprint
  private_key_path = var.private_key_path
  region = "phx"
}

02-user.tf

resource "oci_identity_user" "foo_user" {
  name           = "foo_user"
  description    = "foo_user"
}

Debug Output

https://gist.github.com/tylernelsonschuppert/225d0b96552662e299d89146c8a26bb9

Crash Output

https://gist.github.com/tylernelsonschuppert/225d0b96552662e299d89146c8a26bb9

Expected Behavior

The expected behavior in this case was a successful connection to OCI and creation of a user resource.

Actual Behavior

The actual behavior was Terraform crashing. Terraform crashes for both version 0.12 and 0.13. I have tried to apply the changes using both a limited access IAM user and also an administrative account but the issue persists regardless of the OCI user account.

Steps to Reproduce

  1. terraform init
  2. terraform plan -var-file=02-credentials.tfvars
  3. terraform apply -var-file=02-credentials.tfvars

Additional Context

Here is the CLI output:

09:46 $ terraform apply -var-file=02-credentials.tfvars 

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # oci_identity_user.foo_user will be created
  + resource "oci_identity_user" "foo_user" {
      + capabilities         = (known after apply)
      + compartment_id       = (known after apply)
      + defined_tags         = (known after apply)
      + description          = "foo_user"
      + email                = (known after apply)
      + external_identifier  = (known after apply)
      + freeform_tags        = (known after apply)
      + id                   = (known after apply)
      + identity_provider_id = (known after apply)
      + inactive_state       = (known after apply)
      + name                 = "foo_user"
      + state                = (known after apply)
      + time_created         = (known after apply)
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

oci_identity_user.foo_user: Creating...

Error: rpc error: code = Unavailable desc = transport is closing

panic: runtime error: invalid memory address or nil pointer dereference
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4: [signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x2b335c7]
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4: 
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4: goroutine 23 [running]:
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4: github.com/terraform-providers/terraform-provider-oci/oci.(*IdentityUserResourceCrud).Create(0xc000fa6c30, 0x3b388c0, 0xc000fa6c30)
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4:   /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-oci/oci/identity_user_resource.go:218 +0x9d7
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4: github.com/terraform-providers/terraform-provider-oci/oci.CreateResource(0xc000f6f7a0, 0x3b388c0, 0xc000fa6c30, 0x0, 0x0)
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4:   /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-oci/oci/crud_helpers.go:337 +0x98
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4: github.com/terraform-providers/terraform-provider-oci/oci.createIdentityUser(0xc000f6f7a0, 0x3563d60, 0xc000a69410, 0x2, 0x537d4c0)
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4:   /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-oci/oci/identity_user_resource.go:142 +0xfc
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc0008757a0, 0xc00056ac80, 0xc000ee2de0, 0x3563d60, 0xc000a69410, 0xc000fa6401, 0xc001302228, 0x305c5c0)
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4:   /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-oci/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/resource.go:310 +0x3b4
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc00059c200, 0xc000de5a60, 0xc00056ac80, 0xc000ee2de0, 0xc000fc7048, 0xc0000d1fd8, 0x3087d00)
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4:   /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-oci/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/provider.go:294 +0x18f
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4: github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc000198578, 0x3b35d80, 0xc00126cae0, 0xc000f6eee0, 0xc000198578, 0xc00126cae0, 0xc000af9bc8)
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4:   /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-oci/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin/grpc_provider.go:885 +0x8b5
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4: github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x34ab9c0, 0xc000198578, 0x3b35d80, 0xc00126cae0, 0xc00009f560, 0x0, 0x3b35d80, 0xc00126cae0, 0xc000b90500, 0x246)
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4:   /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-oci/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5/tfplugin5.pb.go:3305 +0x23e
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4: google.golang.org/grpc.(*Server).processUnaryRPC(0xc000558600, 0x3b47ee0, 0xc000544480, 0xc000dfa100, 0xc000a68720, 0x534e460, 0x0, 0x0, 0x0)
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4:   /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-oci/vendor/google.golang.org/grpc/server.go:1024 +0x4d2
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4: google.golang.org/grpc.(*Server).handleStream(0xc000558600, 0x3b47ee0, 0xc000544480, 0xc000dfa100, 0x0)
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4:   /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-oci/vendor/google.golang.org/grpc/server.go:1313 +0xda6
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4: google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0000dc080, 0xc000558600, 0x3b47ee0, 0xc000544480, 0xc000dfa100)
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4:   /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-oci/vendor/google.golang.org/grpc/server.go:722 +0x9f
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4: created by google.golang.org/grpc.(*Server).serveStreams.func1
2020-10-26T10:42:07.035-0700 [DEBUG] plugin.terraform-provider-oci_v4.0.0_x4:   /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-oci/vendor/google.golang.org/grpc/server.go:720 +0xa1
2020-10-26T10:42:07.038-0700 [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2020/10/26 10:42:07 [DEBUG] oci_identity_user.foo_user: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing
2020/10/26 10:42:07 [TRACE] eval: *terraform.EvalMaybeTainted
2020/10/26 10:42:07 [TRACE] EvalMaybeTainted: oci_identity_user.foo_user encountered an error during creation, so it is now marked as tainted
2020/10/26 10:42:07 [TRACE] eval: *terraform.EvalWriteState
2020/10/26 10:42:07 [TRACE] EvalWriteState: removing state object for oci_identity_user.foo_user
2020/10/26 10:42:07 [TRACE] eval: *terraform.EvalApplyProvisioners
2020/10/26 10:42:07 [TRACE] EvalApplyProvisioners: oci_identity_user.foo_user has no state, so skipping provisioners
2020/10/26 10:42:07 [TRACE] eval: *terraform.EvalMaybeTainted
2020/10/26 10:42:07 [TRACE] EvalMaybeTainted: oci_identity_user.foo_user encountered an error during creation, so it is now marked as tainted
2020/10/26 10:42:07 [TRACE] eval: *terraform.EvalWriteState
2020/10/26 10:42:07 [TRACE] EvalWriteState: removing state object for oci_identity_user.foo_user
2020/10/26 10:42:07 [TRACE] eval: *terraform.EvalIf
2020/10/26 10:42:07 [TRACE] eval: *terraform.EvalIf
2020/10/26 10:42:07 [TRACE] eval: *terraform.EvalWriteDiff
2020/10/26 10:42:07 [TRACE] eval: *terraform.EvalApplyPost
2020/10/26 10:42:07 [ERROR] eval: *terraform.EvalApplyPost, err: rpc error: code = Unavailable desc = transport is closing
2020/10/26 10:42:07 [ERROR] eval: *terraform.EvalSequence, err: rpc error: code = Unavailable desc = transport is closing
2020/10/26 10:42:07 [TRACE] [walkApply] Exiting eval tree: oci_identity_user.foo_user
2020/10/26 10:42:07 [TRACE] vertex "oci_identity_user.foo_user": visit complete
2020/10/26 10:42:07 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2020-10-26T10:42:07.038-0700 [DEBUG] plugin: plugin process exited: path=.terraform/plugins/registry.terraform.io/hashicorp/oci/4.0.0/darwin_amd64/terraform-provider-oci_v4.0.0_x4 pid=38314 error="exit status 2"
2020/10/26 10:42:07 [TRACE] dag/walk: upstream of "provider[\"registry.terraform.io/hashicorp/oci\"] (close)" errored, so skipping
2020/10/26 10:42:07 [TRACE] dag/walk: upstream of "root" errored, so skipping
2020/10/26 10:42:07 [TRACE] statemgr.Filesystem: not making a backup, because the new snapshot is identical to the old
2020/10/26 10:42:07 [TRACE] statemgr.Filesystem: no state changes since last snapshot
2020/10/26 10:42:07 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate
2020/10/26 10:42:07 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
2020/10/26 10:42:07 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock
2020-10-26T10:42:07.050-0700 [DEBUG] plugin: plugin exited

!!!!!!!!!!!!!!!!!!!!!!!!!!! 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 !!!!!!!!!!!!!!!!!!!!!!!!!!!!

References

ghost commented 4 years ago

This issue has been automatically migrated to terraform-providers/terraform-provider-oci#1220 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-oci#1220.

ghost 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.