Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bitbucket_deploy_key does not import key #217

Open
gojanpaolo opened this issue Aug 31, 2024 · 1 comment
Open

bitbucket_deploy_key does not import key #217

gojanpaolo opened this issue Aug 31, 2024 · 1 comment

Comments

@gojanpaolo
Copy link

Terraform Version

$ terraform -v
Terraform v1.9.5
on windows_amd64
+ provider registry.terraform.io/drfaust92/bitbucket v2.42.0
+ provider registry.terraform.io/hashicorp/google v6.0.1
+ provider registry.terraform.io/hashicorp/http v3.4.4

Affected Resource(s)

  • bitbucket_deploy_key

Expected Behavior

bitbucket_deploy_key imports key

Actual Behavior

bitbucket_deploy_key does not import key

Steps to Reproduce

  1. Define resource block
resource "bitbucket_deploy_key" "foo" {
  workspace  = local.bitbucket_workspace
  repository = local.terraform_repo
  label      = "foo"
  key        = "ssh-rsa REDACTED"
}

  1. terraform apply

  2. terraform state rm bitbucket_deploy_key.foo

  3. Get the key id curl "$bitbucket_url/repositories/$bitbucket_workspace/$terraform_repo/deploy-keys"

  4. terraform import $bitbucket_workspace/$terraform_repo/$key_id

  5. Check issue

    a. Check terraform state and see that key is not imported

    b. Run terrafrom plan and see that bitbucket_deploy_key must be replaced because key forces replacement. Expected behavior is that there are no changes because we did not change the key in the resource block.

@miklavcic1
Copy link

Same issue here.
The problem seems to be this line:

d.Set("key", d.Get("key").(string))

It reads "key", but the provided value starts with an uppercase, e.g. "Key";
My logs to illustrate the issue:

2025-02-06T10:30:44.667+0100 [INFO] provider.terraform-provider-bitbucket_v2.45.1: 2025/02/06 10:30:44 [DEBUG] Deploy Key Response: bitbucket.DeployKey{Type_:"deploy_key", Key:"ssh-ed25519 foo_bar_baz", Repository:(*bitbucket.Repository)(0xc0005c6400), Comment:"", Label:"playground-CircleCI-checkout-key", AddedOn:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), LastUsed:time.Date(1, time.January, 1, 0, 0, 0, 0, time.UTC), Links:(*interface {})(0xc0000346c0), Owner:(*bitbucket.Account)(nil)}: timestamp="2025-02-06T10:30:44.667+0100" 2025-02-06T10:30:44.669+0100 [TRACE] provider.terraform-provider-bitbucket_v2.45.1: Called downstream: tf_req_id=35017802-5f81-e20f-30d9-93afd9a6f0b1 tf_resource_type=bitbucket_deploy_key tf_provider_addr=DrFaust92/bitbucket tf_rpc=ReadResource @caller=github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:1118 @module=sdk.helper_schema timestamp="2025-02-06T10:30:44.669+0100" 2025-02-06T10:30:44.673+0100 [TRACE] provider.terraform-provider-bitbucket_v2.45.1: Received downstream response: @caller=github.com/hashicorp/[email protected]/tfprotov5/internal/tf5serverlogging/downstream_request.go:42 @module=sdk.proto tf_proto_version=5.7 tf_provider_addr=DrFaust92/bitbucket tf_req_id=35017802-5f81-e20f-30d9-93afd9a6f0b1 diagnostic_error_count=0 diagnostic_warning_count=0 tf_req_duration_ms=374 tf_resource_type=bitbucket_deploy_key tf_rpc=ReadResource timestamp="2025-02-06T10:30:44.673+0100" 2025-02-06T10:30:44.673+0100 [TRACE] provider.terraform-provider-bitbucket_v2.45.1: Served request: tf_rpc=ReadResource @caller=github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:802 tf_provider_addr=DrFaust92/bitbucket tf_req_id=35017802-5f81-e20f-30d9-93afd9a6f0b1 tf_resource_type=bitbucket_deploy_key @module=sdk.proto tf_proto_version=5.7 timestamp="2025-02-06T10:30:44.673+0100" 2025-02-06T10:30:44.680+0100 [WARN] Provider "registry.terraform.io/drfaust92/bitbucket" produced an unexpected new value for module.repository-access["playground"].bitbucket_deploy_key.circleci_checkout_key["some_value"] during refresh. - .label: was null, but now cty.StringVal("(has correct value)") - .repository: was null, but now cty.StringVal("(has correct value)") - .workspace: was null, but now cty.StringVal("(has correct value)") - .comment: was null, but now cty.StringVal("") - .key: was null, but now cty.StringVal("") - .key_id: was null, but now cty.StringVal("(has correct value)")

Please review and fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants