From cc1ddabd45f239ee06fde9b2d1534467908791fa Mon Sep 17 00:00:00 2001 From: Liam Best <92705162+lbestftr@users.noreply.github.com> Date: Sun, 18 Dec 2022 17:25:11 +1100 Subject: [PATCH] feat: Add the accelerate option for s3 buckets (#7314) --- .changeset/good-balloons-admire.md | 6 ++++++ packages/app-builder-lib/scheme.json | 4 ++++ packages/builder-util-runtime/src/publishOptions.ts | 11 ++++++++++- 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 .changeset/good-balloons-admire.md diff --git a/.changeset/good-balloons-admire.md b/.changeset/good-balloons-admire.md new file mode 100644 index 00000000000..9d5bec49c47 --- /dev/null +++ b/.changeset/good-balloons-admire.md @@ -0,0 +1,6 @@ +--- +"app-builder-lib": minor +"builder-util-runtime": minor +--- + +added the accelerate option to handle accelerated s3 buckets diff --git a/packages/app-builder-lib/scheme.json b/packages/app-builder-lib/scheme.json index 8792c88030a..10da70e37bc 100644 --- a/packages/app-builder-lib/scheme.json +++ b/packages/app-builder-lib/scheme.json @@ -4882,6 +4882,10 @@ "additionalProperties": false, "description": "[Amazon S3](https://aws.amazon.com/s3/) options.\nAWS credentials are required, please see [getting your credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/getting-your-credentials.html).\nDefine `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` [environment variables](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-environment.html).\nOr in the [~/.aws/credentials](http://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/loading-node-credentials-shared.html).\n\nExample configuration:\n\n```json\n{\n\"build\":\n \"publish\": {\n \"provider\": \"s3\",\n \"bucket\": \"bucket-name\"\n }\n}\n}\n```", "properties": { + "accelerate": { + "description": "If set to true, this will enable the s3 accelerated endpoint\nThese endpoints have a particular format of:\n ${bucketname}.s3-accelerate.amazonaws.com", + "type": "boolean" + }, "acl": { "anyOf": [ { diff --git a/packages/builder-util-runtime/src/publishOptions.ts b/packages/builder-util-runtime/src/publishOptions.ts index b3160fa2732..169b322b0b9 100644 --- a/packages/builder-util-runtime/src/publishOptions.ts +++ b/packages/builder-util-runtime/src/publishOptions.ts @@ -349,6 +349,13 @@ export interface S3Options extends BaseS3Options { * The endpoint should be a string like `https://{service}.{region}.amazonaws.com`. */ readonly endpoint?: string | null + + /** + * If set to true, this will enable the s3 accelerated endpoint + * These endpoints have a particular format of: + * ${bucketname}.s3-accelerate.amazonaws.com + */ + readonly accelerate?: boolean } /** @@ -385,7 +392,9 @@ export function getS3LikeProviderBaseUrl(configuration: PublishConfiguration) { function s3Url(options: S3Options) { let url: string - if (options.endpoint != null) { + if (options.accelerate == true) { + url = `https://${options.bucket}.s3-accelerate.amazonaws.com` + } else if (options.endpoint != null) { url = `${options.endpoint}/${options.bucket}` } else if (options.bucket.includes(".")) { if (options.region == null) {