Skip to content

Commit

Permalink
feat: Add the accelerate option for s3 buckets (#7314)
Browse files Browse the repository at this point in the history
  • Loading branch information
lbestftr authored Dec 18, 2022
1 parent b8eb479 commit cc1ddab
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/good-balloons-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"app-builder-lib": minor
"builder-util-runtime": minor
---

added the accelerate option to handle accelerated s3 buckets
4 changes: 4 additions & 0 deletions packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
11 changes: 10 additions & 1 deletion packages/builder-util-runtime/src/publishOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

/**
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit cc1ddab

Please sign in to comment.