fourplusone / terraform-provider-jira

Terraform provider to configure JIRA
https://registry.terraform.io/providers/fourplusone/jira/latest
MIT License
180 stars 54 forks source link

Authentication with API Token #5

Open madslyng opened 5 years ago

madslyng commented 5 years ago

I see that it's apparently only possible to authenticate with Username/Password in the current version. This stops me from using terraform-provider-jira, because I will need to use authentication with API token.

https://confluence.atlassian.com/cloud/api-tokens-938839638.html

Because of the authentication my organisation uses (SSO), I get the following error:

After:

export JIRA_URL=<url>
export JIRA_USER=<username>
export JIRA_PASSWORD=<password>

and running:

terraform plan -state=prod.tfstate

I get:

Acquiring state lock. This may take a few moments...
Error: Failed to retrieve schema from provider "jira": rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: authentication handshake failed: write unix @->/tmp/plugin471239770: write: broken pipe"

Releasing state lock. This may take a few moments...
fourplusone commented 5 years ago

Can you try, whether

[...]
export JIRA_USER=<username>
export JIRA_PASSWORD=<my-api-token>

works?

madslyng commented 5 years ago

It seems to work, but it throws an unhandled exception now. I've tested with:

resource "jira_issue" "another_example" {
  issue_type  = "Story"
  summary     = "Story created by terraform"
  project_key = "ALFA"
}

And:

resource "jira_group" "tf_group" {
  name = "JpTerraformGroup"
}

And both throw:

╰─$ terraform apply -state=prod.tfstate                                                                                                                                                                                                                                                                                                                                                                                          1 ↵

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:

  # jira_issue.another_example will be created
  + resource "jira_issue" "another_example" {
      + id          = (known after apply)
      + issue_key   = (known after apply)
      + issue_type  = "Story"
      + project_key = "ALFA"
      + summary     = "Story created by terraform"
    }

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

jira_issue.another_example: Creating...

Error: rpc error: code = Canceled desc = context canceled

panic: runtime error: invalid memory address or nil pointer dereference
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xd6ad46]
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira:
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira: goroutine 50 [running]:
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira: github.com/fourplusone/terraform-provider-jira/jira.resourceIssueCreate(0xc0002300e0, 0xedac80, 0xc00000e318, 0x2, 0x1a7a8e0)
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira:    /home/circleci/project/jira/resource_issue.go:110 +0x996
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira: github.com/hashicorp/terraform/helper/schema.(*Resource).Apply(0xc0003ae380, 0xc0006dd810, 0xc0004131c0, 0xedac80, 0xc00000e318, 0xc0003f7501, 0xc0000870e0, 0xed1dc0)
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira:    /go/pkg/mod/github.com/hashicorp/terraform@v0.12.0/helper/schema/resource.go:286 +0x3b4
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira: github.com/hashicorp/terraform/helper/schema.(*Provider).Apply(0xc0003ae900, 0xc0004f5a58, 0xc0006dd810, 0xc0004131c0, 0xc0002fcbc8, 0xc0003a8420, 0xed3c20)
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira:    /go/pkg/mod/github.com/hashicorp/terraform@v0.12.0/helper/schema/provider.go:285 +0x18f
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira: github.com/hashicorp/terraform/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc0003a8088, 0x127fc20, 0xc0003f6900, 0xc00025b0e0, 0xc0003a8088, 0xc0003f6900, 0xc00020bbd0)
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira:    /go/pkg/mod/github.com/hashicorp/terraform@v0.12.0/helper/plugin/grpc_provider.go:842 +0x894
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira: github.com/hashicorp/terraform/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0xffa640, 0xc0003a8088, 0x127fc20, 0xc0003f6900, 0xc0006dd540, 0x0, 0x127fc20, 0xc0003f6900, 0xc00021e480, 0x17d)
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira:    /go/pkg/mod/github.com/hashicorp/terraform@v0.12.0/internal/tfplugin5/tfplugin5.pb.go:3019 +0x23e
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira: google.golang.org/grpc.(*Server).processUnaryRPC(0xc000001e00, 0x128b5c0, 0xc000236780, 0xc000429000, 0xc0002c1ce0, 0x1a4f600, 0x0, 0x0, 0x0)
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira:    /go/pkg/mod/google.golang.org/grpc@v1.18.0/server.go:966 +0x470
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira: google.golang.org/grpc.(*Server).handleStream(0xc000001e00, 0x128b5c0, 0xc000236780, 0xc000429000, 0x0)
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira:    /go/pkg/mod/google.golang.org/grpc@v1.18.0/server.go:1245 +0xd25
2019-06-07T20:39:24.572+0200 [DEBUG] plugin.terraform-provider-jira: google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0000324b0, 0xc000001e00, 0x128b5c0, 0xc000236780, 0xc000429000)
2019-06-07T20:39:24.573+0200 [DEBUG] plugin.terraform-provider-jira:    /go/pkg/mod/google.golang.org/grpc@v1.18.0/server.go:685 +0x9f
2019-06-07T20:39:24.573+0200 [DEBUG] plugin.terraform-provider-jira: created by google.golang.org/grpc.(*Server).serveStreams.func1
2019-06-07T20:39:24.573+0200 [DEBUG] plugin.terraform-provider-jira:    /go/pkg/mod/google.golang.org/grpc@v1.18.0/server.go:683 +0xa1
2019-06-07T20:39:24.573+0200 [DEBUG] plugin: plugin process exited: path=/home/private/.terraform.d/plugins/terraform-provider-jira pid=581 error="exit status 2"
2019/06/07 20:39:24 [DEBUG] jira_issue.another_example: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Canceled desc = context canceled
2019/06/07 20:39:24 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2019/06/07 20:39:24 [TRACE] EvalMaybeTainted: jira_issue.another_example encountered an error during creation, so it is now marked as tainted
2019/06/07 20:39:24 [TRACE] <root>: eval: *terraform.EvalWriteState
2019/06/07 20:39:24 [TRACE] EvalWriteState: removing state object for jira_issue.another_example
2019/06/07 20:39:24 [TRACE] <root>: eval: *terraform.EvalApplyProvisioners
2019/06/07 20:39:24 [TRACE] EvalApplyProvisioners: jira_issue.another_example has no state, so skipping provisioners
2019/06/07 20:39:24 [TRACE] <root>: eval: *terraform.EvalMaybeTainted
2019/06/07 20:39:24 [TRACE] EvalMaybeTainted: jira_issue.another_example encountered an error during creation, so it is now marked as tainted
2019/06/07 20:39:24 [TRACE] <root>: eval: *terraform.EvalWriteState
2019/06/07 20:39:24 [TRACE] EvalWriteState: removing state object for jira_issue.another_example
2019/06/07 20:39:24 [TRACE] <root>: eval: *terraform.EvalIf
2019/06/07 20:39:24 [TRACE] <root>: eval: *terraform.EvalIf
2019/06/07 20:39:24 [TRACE] <root>: eval: *terraform.EvalWriteDiff
2019/06/07 20:39:24 [TRACE] <root>: eval: *terraform.EvalApplyPost
2019/06/07 20:39:24 [ERROR] <root>: eval: *terraform.EvalApplyPost, err: rpc error: code = Canceled desc = context canceled
2019/06/07 20:39:24 [ERROR] <root>: eval: *terraform.EvalSequence, err: rpc error: code = Canceled desc = context canceled
2019/06/07 20:39:24 [TRACE] [walkApply] Exiting eval tree: jira_issue.another_example
2019/06/07 20:39:24 [TRACE] vertex "jira_issue.another_example": visit complete
2019/06/07 20:39:24 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2019/06/07 20:39:24 [TRACE] dag/walk: upstream of "provider.jira (close)" errored, so skipping
2019/06/07 20:39:24 [TRACE] dag/walk: upstream of "root" errored, so skipping
2019/06/07 20:39:24 [TRACE] statemgr.Filesystem: not making a backup, because the new snapshot is identical to the old
2019/06/07 20:39:24 [TRACE] statemgr.Filesystem: no state changes since last snapshot
2019/06/07 20:39:24 [TRACE] statemgr.Filesystem: writing snapshot at prod.tfstate
2019/06/07 20:39:24 [TRACE] statemgr.Filesystem: removing lock metadata file .prod.tfstate.lock.info
2019/06/07 20:39:24 [TRACE] statemgr.Filesystem: unlocking prod.tfstate using fcntl flock
2019-06-07T20:39:24.577+0200 [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.

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

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!
fourplusone commented 5 years ago

Which version of the plugin causes this error message?

Tensho commented 4 years ago

@fourplusone Hi, I try to run a test against JIRA Cloud development environment with JIRA_URL, JIRA_USER, JIRA_PASSWORD env vars and fail with an authentication error:

Error: getting jira user failed: The 'accountId' query parameter needs to be provided: Request failed. Please analyze the request body for more details. Status code: 404

Do you know the reason of this error?

wanisfahmyDE commented 3 years ago

@fourplusone i get the same error (terraform crash) running against self hosted Jira with plugin version 0.1.14

fourplusone commented 3 years ago

Hi @wanisfahmyDE Which variant (Server or Data Center) and which version of JIRA are you using?

wanisfahmyDE commented 3 years ago

Hi @fourplusone , i am running against a self hosted JIRA v8.2.1 with terraform 0.14.8. when downgrading terraform to version 0.13.0 it didn't crash :)