hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.8k stars 9.15k forks source link

[Bug]: presigned S3 upload URL from aws_devicefarm_upload has wrong signature #30727

Closed martinhelfert closed 8 months ago

martinhelfert commented 1 year ago

Terraform Core Version

1.3.6

AWS Provider Version

4.62.0

Affected Resource(s)

aws_devicefarm_upload

Expected Behavior

aws_devicefarm_upload should return a presigned URL where I can upload a file to using curl.

Actual Behavior

The returned presigned URL seems to be correct, but when uploading to it, it fails with a SignatureDoesNotMatch error. When using the aws cli tool (aws devicefarm create-upload) instead, the returned URL is working.

Relevant Error/Panic Output Snippet

<Error>
<Code>SignatureDoesNotMatch</Code>
<Message>The request signature we calculated does not match the signature you provided. Check your key and signing method.</Message>
....
</Error>

Terraform Configuration Files


terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "4.62.0"
    }
    null = {
      source  = "hashicorp/null"
      version = "3.2.1"
    }
  }

  required_version = "~> 1.2"
}

provider "aws" {
  region = "us-west-2"
}

resource "aws_devicefarm_project" "default" {
  name = "example"
}

resource "aws_devicefarm_upload" "ipa" {
  for_each = fileset(path.module, "*.ipa")

  name         = each.value
  project_arn  = aws_devicefarm_project.default.arn
  type         = "IOS_APP"
}

resource "null_resource" "upload_ipa" {
  for_each = aws_devicefarm_upload.ipa

  provisioner "local-exec" {
    command = "curl -T ${each.value.name} \"${each.value.url}\""
  }

  depends_on = [aws_devicefarm_upload.ipa]
}

Steps to Reproduce

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

Would you like to implement a fix?

None

github-actions[bot] commented 1 year ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

justinretzolk commented 1 year ago

Hey @martinhelfert 👋 Thank you for taking the time to raise this! Am I understanding correctly that if you take the value returned from aws_devicefarm_upload.ipa.url and pass it to the AWS CLI command, it's working properly? It's a bit difficult for me to say without being able to realistically spin up the architecture to test this out, but if my understanding (mentioned before) is correct, this may be a result of the cURL command in the local-exec using ${each.value.name} rather than ${path.module}/${each.value.name}.

justinretzolk commented 8 months ago

Since we haven't heard back, I'm going to close this issue. If you're still having trouble, please feel free to open a new issue, referencing this one for context as needed.

github-actions[bot] commented 7 months 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.