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

Unable to upload to gcs via google_storage_bucket_object #6008

Closed
kwri-avongluck opened this issue Mar 30, 2020 · 10 comments
Closed

Unable to upload to gcs via google_storage_bucket_object #6008

kwri-avongluck opened this issue Mar 30, 2020 · 10 comments

Comments

@kwri-avongluck
Copy link

kwri-avongluck commented Mar 30, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

$ terraform -v
Terraform v0.12.24

  • provider.google v3.14.0

Affected Resource(s)

  • google_storage_bucket_object

Terraform Configuration Files

resource "google_storage_bucket" "artifact-bucket" {
  name          = "coolbucket-${var.env}"
  location      = "US"
  force_destroy = true

  bucket_policy_only = true

  cors {
    origin          = ["*"]
    method          = ["GET", "HEAD", "PUT", "POST", "DELETE"]
    response_header = ["*"]
    max_age_seconds = 3600
  }
}


resource "google_storage_bucket_object" "thing" {
  name   = "installer"
  source = "assets/cool.rpm"
  bucket = "image-store"

  depends_on = [google_storage_bucket.artifact-bucket]
}

Debug Output

Error: Error uploading object thing: Post https://www.googleapis.com/upload/storage/v1/b/image-store/o?alt=json&name=thing&prettyPrint=false&uploadType=resumable: unable to copy invalid http.Request for retry: invalid HTTP request for transport, expected request.GetBody for non-empty Body

  on gcs.tf line 16, in resource "google_storage_bucket_object" "thing":
  16: resource "google_storage_bucket_object" "thing" {

Expected Behavior

file uploaded

Actual Behavior

Errored out.

Steps to Reproduce

  1. terraform apply

Important Factoids

service account, all api's enabled

@ghost ghost added the bug label Mar 30, 2020
@kwri-avongluck kwri-avongluck changed the title Unable to upload to gcs via Unable to upload to gcs via google_storage_bucket_object Mar 30, 2020
@edwardmedia edwardmedia self-assigned this Mar 30, 2020
@edwardmedia
Copy link
Contributor

@kwri-avongluck can you try if you replace bucket to something like below? Make sure assets/cool.rpm is in place

bucket = google_storage_bucket.artifact-bucket.name

@kwri-avongluck
Copy link
Author

nice catch, but same error.

Error: Error uploading object coolthing: Post https://www.googleapis.com/upload/storage/v1/b/cool-bucket/o?alt=json&name=coolthing&prettyPrint=false&uploadType=resumable&upload_id=BLAH: net/http: request canceled (Client.Timeout exceeded while awaiting headers)

  on gcs-thing.tf line 24, in resource "google_storage_bucket_object" "coolthing":
  24: resource "google_storage_bucket_object" "coolthing" {

@ghost ghost removed the waiting-response label Mar 30, 2020
@edwardmedia
Copy link
Contributor

@kwri-avongluck did you use the posted code to run? Look at below URL, what is upload_id=BLAH? Again, you might need to double check all the settings.

https://www.googleapis.com/upload/storage/v1/b/cool-bucket/o?alt=json&name=coolthing&prettyPrint=false&uploadType=resumable&upload_id=BLAH

@tswast
Copy link

tswast commented Mar 31, 2020

Shouldn't this module be using the (somewhat new) https://storage.googleapis.com endpoint? https://cloud.google.com/storage/docs/json_api/v1

@ghost ghost removed the waiting-response label Mar 31, 2020
@tswast
Copy link

tswast commented Mar 31, 2020

How large is the file you are trying to upload? I'm having a similar error when trying to upload a 83.6 MB deb package file.

@kwri-avongluck
Copy link
Author

~80 MiB. It seems to be working inconsistently.

"@kwri-avongluck did you use the posted code to run? Look at below URL, what is upload_id=BLAH? Again, you might need to double check all the settings."

Yes. BLAH is me hiding potentially sensitive information.

@edwardmedia
Copy link
Contributor

@tswast regarding the size, we have a fix in #5970

@edwardmedia
Copy link
Contributor

edwardmedia commented Mar 31, 2020

@kwri-avongluck do you have assets/cool.rpm in place?
Without full debug log, It is a little bit difficult to help you debug. I can run your code without a problem

@edwardmedia
Copy link
Contributor

@kwri-avongluck as I am not able to repro this issue, I am closing it. Please feel free to reopen it if this is still an issue with you

@ghost
Copy link

ghost commented Jun 11, 2020

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Jun 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants