diff --git a/.changeset/tidy-kangaroos-guess.md b/.changeset/tidy-kangaroos-guess.md new file mode 100644 index 0000000000..019d259736 --- /dev/null +++ b/.changeset/tidy-kangaroos-guess.md @@ -0,0 +1,6 @@ +--- +'@backstage/techdocs-common': patch +'@backstage/plugin-techdocs': patch +--- + +Add an optional configuration option for setting the url endpoint for AWS S3 publisher: `techdocs.publisher.awsS3.endpoint` diff --git a/docs/features/techdocs/configuration.md b/docs/features/techdocs/configuration.md index 20e436d8a4..9bf2c25926 100644 --- a/docs/features/techdocs/configuration.md +++ b/docs/features/techdocs/configuration.md @@ -76,6 +76,12 @@ techdocs: region: $env: AWS_REGION + # (Optional) Endpoint URI to send requests to. + # If not set, the default endpoint is built from the configured region. + # https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property + endpoint: + $env: AWS_ENDPOINT + # Required when techdocs.publisher.type is set to 'azureBlobStorage'. Skip otherwise. azureBlobStorage: diff --git a/packages/techdocs-common/src/stages/publish/awsS3.ts b/packages/techdocs-common/src/stages/publish/awsS3.ts index a1abd5899d..cf950da72f 100644 --- a/packages/techdocs-common/src/stages/publish/awsS3.ts +++ b/packages/techdocs-common/src/stages/publish/awsS3.ts @@ -94,11 +94,16 @@ export class AwsS3Publish implements PublisherBase { // or AWS shared credentials file at ~/.aws/credentials will be used. const region = config.getOptionalString('techdocs.publisher.awsS3.region'); + // AWS endpoint is an optional config. If missing, the default endpoint is built from + // the configured region. + const endpoint = config.getOptionalString( + 'techdocs.publisher.awsS3.endpoint', + ); + const storageClient = new aws.S3({ credentials, - ...(region && { - region, - }), + ...(region && { region }), + ...(endpoint && { endpoint }), }); // Check if the defined bucket exists. Being able to connect means the configuration is good diff --git a/plugins/techdocs/config.d.ts b/plugins/techdocs/config.d.ts index 54d2b8fb69..00d8d2cbbe 100644 --- a/plugins/techdocs/config.d.ts +++ b/plugins/techdocs/config.d.ts @@ -83,6 +83,13 @@ export interface Config { * @visibility secret */ region?: string; + /** + * (Optional) AWS Endpoint. + * The endpoint URI to send requests to. The default endpoint is built from the configured region. + * @see https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property + * @visibility secret + */ + endpoint?: string; }; } | {