DrFaust92 / terraform-provider-bitbucket

Terraform Bitbucket Cloud provider.
https://registry.terraform.io/providers/drfaust92/bitbucket
Mozilla Public License 2.0
38 stars 32 forks source link

API Error: 500 2.0/repositories/<team>/<repository>/src Something went wrong #193

Open gelfandbein opened 11 months ago

gelfandbein commented 11 months ago

Terraform 1.5.5 Bitbucket provider 2.38.0

Can't upload to branch small files (15-20 files), always got 500 error after second file, 1st file uploaded yo branch without problems

terraform.log:

2024-01-01T16:53:24.973+0200 [ERROR] provider.terraform-provider-bitbucket_v2.38.0: Response contains error diagnostic: tf_proto_version=5.4 tf_req_id=2da8da95-5d0a-da69-dbe7-8fc853ced63a @module=sdk.proto diagnostic_detail= diagnostic_severity=ERROR tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.19.0/tfprotov5/internal/diag/diagnostics.go:58 diagnostic_summary="API Error: 500 2.0/repositories/<team>/<repository>/src Something went wrong" tf_provider_addr=DrFaust92/bitbucket tf_resource_type=bitbucket_commit_file timestamp=2024-01-01T16:53:24.973+0200
2024-01-01T16:53:24.976+0200 [ERROR] vertex "bitbucket_commit_file.web_conf" error: API Error: 500 2.0/repositories/<team>/<repository>/src Something went wrong

Terraform resource:

resource "bitbucket_commit_file" "startup_script" {
  filename       = "startup-script.sh"
  content        = data.template_file.startup_script.rendered
  repo_slug      = "config"
  workspace      = data.bitbucket_workspace.current_workspace.slug
  commit_author  = "John Doe <${var.admin1_email}>"
  branch         = "config"
  commit_message = "initial config"
}

Can I commit whole folder not by file?

gelfandbein commented 11 months ago

And for the future I'd like to upload generated files (after 'terraform apply') not only from the repo source

wuetz commented 1 month ago

Hi i have the same issue, first file commit is working, then it crashes..

KevinDeNotariis commented 1 month ago

Did anyone figure out why is that? I'm facing the same issue

wuetz commented 1 month ago

Could you please show your workaround looks like?

gelfandbein commented 1 month ago

Could you please show your workaround looks like? In my approach, i'll create new branch for files and commit these:

resource "null_resource" "prepare_branch" { provisioner "local-exec" { interpreter = ["/bin/bash", "-c"] working_dir = path.module command = <<EOT ... git config --global user.email "${var.cluster}@${var.project}" git config --global user.name "Terraform: ${var.cluster} at ${var.project}" git -C /tmp/${var.cluster}-se-configs add . git -C /tmp/${var.cluster}-se-configs commit -m "Initial '${var.cluster}' cluster config at '${var.project}' project" ... EOT }

or you can zip files, commit it and use .git/hooks/pre-commit bash file to unpack and finally commit to branch