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

Update presign post URL resolution to use the exact result from EndpointResolverV2 #2842

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Madrigal
Copy link
Contributor

  • Update presign post URL resolution to use the exact result from EndpointResolverV2

Fixes #2827

Discussed offline. Our original approach was to update toBaseURL to fix this edge case. However, this had the pitfall of being hard to capture all corner cases. Instead of coming up with a heuristic to figure out how to best parse the URL from the bucket, use the URI directly from endpointResolverV2. This change does this by:

  1. Adds a new code generator that has a renderPostEndpointResolutionHook, which generates the line on endpoints.go to store the URI on the context
  2. PresigPost uses this value instead of getting the URL from the request object

Tests are copied from a draft PR with the 1st approach

Testing

  1. Ran all unit tests for presign_post_test
  2. Ran integration tests manually (although we don't need this now since they are run by default 🎉 )

@Madrigal Madrigal requested a review from a team as a code owner October 16, 2024 23:41
Copy link
Contributor

@lucix-aws lucix-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixandship

@@ -50,3 +51,14 @@ func GetAttemptSkewContext(ctx context.Context) time.Duration {
x, _ := middleware.GetStackValue(ctx, clockSkew{}).(time.Duration)
return x
}

// SetS3ResolvedURI sets the URI as resolved by the EndpointResolverV2
func SetS3ResolvedURI(ctx context.Context, value string) context.Context {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we only need this in S3 right now then let's just have it unexported in service/s3. We're still committing to a pseudo-API contract by doing this, even though it's under internal/, if we ever wanted to expand it to other services we wouldn't be able to remove it because it could break cross-module compat.

@@ -66,6 +68,23 @@ func TestPresignPutObject(t *testing.T) {
},
expectedURL: "https://mfzwi23gnjvgw.mrap.accesspoint.s3-global.amazonaws.com",
},
"use path style bucket hosting pattern": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also add tests for:

  • bucket and key are the same value
  • custom BaseEndpoint has an arbitrary path segment (e.g. locals3.com/v1)

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

Successfully merging this pull request may close these issues.

PresignedPostObject doesn't map bucket name in URL
3 participants