Skip to content

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

Merged
merged 1 commit into from
Dec 19, 2019

Conversation

srchase
Copy link
Contributor

@srchase srchase commented Dec 12, 2019

Migrates and applies bucketEndpointMiddleware

Enables the following configuration options on S3 Clients:

  • bucketEndpoint
  • forcePathStyle
  • useAccelerateEndpoint
  • useDualstackEndpoint

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.

@srchase srchase added the smithy-codegen Changes regarding supporting smithy model. Will be merged to smithy-codegen branch label Dec 12, 2019
@srchase srchase requested a review from AllanZhengYP December 12, 2019 17:26
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@srchase srchase force-pushed the bucket-endpoint-middleware branch from cf33f63 to e1426dd Compare December 16, 2019 18:49
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@srchase srchase requested a review from AllanZhengYP December 16, 2019 21:00
: false;
const useDualstackEndpoint = input.useDualstackEndpoint
? input.useDualstackEndpoint
: false;
Copy link
Contributor

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;

Copy link
Contributor

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.

Copy link
Contributor Author

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;
}
Copy link
Contributor

@AllanZhengYP AllanZhengYP Dec 18, 2019

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;
Copy link
Contributor

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

Copy link
Contributor Author

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:"
Copy link
Contributor

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

Copy link
Contributor Author

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 = "/";
}
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

@srchase srchase force-pushed the bucket-endpoint-middleware branch from e1426dd to e5fb3fe Compare December 18, 2019 20:20
@srchase srchase requested a review from AllanZhengYP December 18, 2019 20:23
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@srchase srchase force-pushed the bucket-endpoint-middleware branch from e5fb3fe to 03a8d87 Compare December 18, 2019 20:25
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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
@srchase srchase force-pushed the bucket-endpoint-middleware branch from b4ff89c to 186b6c3 Compare December 19, 2019 19:36
@aws-sdk-js-automation
Copy link

AWS CodeBuild CI Report

  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@srchase srchase merged commit 7480f74 into aws:smithy-codegen Dec 19, 2019
@srchase srchase deleted the bucket-endpoint-middleware branch December 19, 2019 19:42
@lock
Copy link

lock bot commented Dec 26, 2019

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.

@lock lock bot locked as resolved and limited conversation to collaborators Dec 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
smithy-codegen Changes regarding supporting smithy model. Will be merged to smithy-codegen branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants