-
Notifications
You must be signed in to change notification settings - Fork 615
feat: migrate and apply bucketEndpointMiddleware #552
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
feat: migrate and apply bucketEndpointMiddleware #552
Conversation
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
packages/middleware-bucket-endpoint/src/bucketEndpointMiddleware.ts
Outdated
Show resolved
Hide resolved
cf33f63
to
e1426dd
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
: false; | ||
const useDualstackEndpoint = input.useDualstackEndpoint | ||
? input.useDualstackEndpoint | ||
: false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these can be change to
const {
bucketEndpoint = false,
forcePathStyle = false,
//others
} = input;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that defaulting only applies if the left-hand side is undefined
- not if it's otherwise falsey like the existing code. May or may not be what you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
preformedBucketEndpoint?: boolean; | ||
useAccelerateEndpoint?: boolean; | ||
useDualstackEndpoint?: boolean; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add document block for each of these configs? They should be documented in API reference
): Promise<BuildHandlerOutput<Output>> => { | ||
const { Bucket: bucketName } = args.input; | ||
let replaceBucketInPath = | ||
options.preformedBucketEndpoint || options.bucketEndpoint; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get the difference of preformedBucketEndpoint
and bucketEndpoint
, we might need to document them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed preformedBucketEndpoint
. only bucketEndpoint
is needed now that we combined the input and config options.
accelerateEndpoint: options.useAccelerateEndpoint, | ||
dualstackEndpoint: options.useDualstackEndpoint, | ||
pathStyleEndpoint: options.forcePathStyle, | ||
sslCompatible: request.protocol === "https:" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This key should be tlsCompatible
as we use tls
everywhere now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to tlsCompatible
request.path = request.path.replace(/^(\/)?[^\/]+/, ""); | ||
if (request.path === "") { | ||
request.path = "/"; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the rationale for removing the path? I think we need more doc/comments on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reading it, it's removing the bucket name from the path as the second-part of transforming from path-style to hostname-style bucket possibly started by bucketHostname()
, e.g. from s3.amazonaws.com/my-bucket/my-key
to my-bucket.s3.amazonaws.com/my-key
, possibly by whatever happened before this middleware.
What's unclear to me at this point is why is the bucket name already in the request path? My understanding was that the path-style was being deprecated, so I would expect the request path to already only be the key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@simonbuchan Even though path-style is deprecated, the API model shipped by S3 service team is still path-style. So SDK needs to do the heavy lifting to move the bucket name from path to the hostname.
e1426dd
to
e5fb3fe
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
e5fb3fe
to
03a8d87
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
feat: migrate and apply middleware feat: remove $ input options fix: remove preformedBucket option
b4ff89c
to
186b6c3
Compare
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Migrates and applies bucketEndpointMiddleware
Enables the following configuration options on S3 Clients:
Applies to all S3 operations except CreateBucket, DeleteBucket and ListBuckets.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.