diff --git a/.changeset/old-phones-rest.md b/.changeset/old-phones-rest.md new file mode 100644 index 0000000000..20edd78d8d --- /dev/null +++ b/.changeset/old-phones-rest.md @@ -0,0 +1,6 @@ +--- +'@techdocs/cli': minor +'@backstage/plugin-techdocs-node': minor +--- + +Allow configurable optional retries for publisher AWS S3 operations. diff --git a/docs/features/techdocs/cli.md b/docs/features/techdocs/cli.md index c824eb7d7d..517b2a3547 100644 --- a/docs/features/techdocs/cli.md +++ b/docs/features/techdocs/cli.md @@ -197,6 +197,7 @@ Options: --awsS3sse Optional AWS S3 Server Side Encryption. --awsS3ForcePathStyle Optional AWS S3 option to force path style. --awsBucketRootPath Optional sub-directory to store files in Amazon S3 + --awsMaxAttempts Optional maximum number of retries for AWS S3 operations. If not specified, default value of 3 is used. --osCredentialId (Required for OpenStack) specify when --publisher-type openStackSwift --osSecret (Required for OpenStack) specify when --publisher-type openStackSwift --osAuthUrl (Required for OpenStack) specify when --publisher-type openStackSwift diff --git a/packages/techdocs-cli/cli-report.md b/packages/techdocs-cli/cli-report.md index 9777b2c4b8..5b0f4c9857 100644 --- a/packages/techdocs-cli/cli-report.md +++ b/packages/techdocs-cli/cli-report.md @@ -83,6 +83,7 @@ Options: --awsS3sse --awsS3ForcePathStyle --awsBucketRootPath + --awsMaxAttempts --osCredentialId --osSecret --osAuthUrl diff --git a/packages/techdocs-cli/src/commands/index.ts b/packages/techdocs-cli/src/commands/index.ts index ac9523e639..955dcca24e 100644 --- a/packages/techdocs-cli/src/commands/index.ts +++ b/packages/techdocs-cli/src/commands/index.ts @@ -196,6 +196,10 @@ export function registerCommands(program: Command) { '--awsBucketRootPath ', 'Optional sub-directory to store files in Amazon S3', ) + .option( + '--awsMaxAttempts ', + 'Optional maximum number of retries for AWS S3 operations. If not specified, default value of 3 is used.', + ) .option( '--osCredentialId ', '(Required for OpenStack) specify when --publisher-type openStackSwift', diff --git a/packages/techdocs-cli/src/lib/PublisherConfig.ts b/packages/techdocs-cli/src/lib/PublisherConfig.ts index 803e40308b..e9ffd25025 100644 --- a/packages/techdocs-cli/src/lib/PublisherConfig.ts +++ b/packages/techdocs-cli/src/lib/PublisherConfig.ts @@ -95,6 +95,9 @@ export class PublisherConfig { ...(opts.awsS3ForcePathStyle && { s3ForcePathStyle: true }), ...(opts.awsS3sse && { sse: opts.awsS3sse }), ...(opts.awsProxy && { httpsProxy: opts.awsProxy }), + ...(opts.awsMaxAttempts && { + maxAttempts: Number(opts.awsMaxAttempts), + }), }, }; } diff --git a/plugins/techdocs-node/src/stages/publish/awsS3.ts b/plugins/techdocs-node/src/stages/publish/awsS3.ts index edbd6da114..395dee3688 100644 --- a/plugins/techdocs-node/src/stages/publish/awsS3.ts +++ b/plugins/techdocs-node/src/stages/publish/awsS3.ts @@ -164,12 +164,18 @@ export class AwsS3Publish implements PublisherBase { 'techdocs.publisher.awsS3.s3ForcePathStyle', ); + // AWS MAX ATTEMPTS is an optional config. If missing, default value of 3 is used + const maxAttempts = config.getOptionalNumber( + 'techdocs.publisher.awsS3.maxAttempts', + ); + const storageClient = new S3Client({ customUserAgent: 'backstage-aws-techdocs-s3-publisher', credentialDefaultProvider: () => sdkCredentialProvider, ...(region && { region }), ...(endpoint && { endpoint }), ...(forcePathStyle && { forcePathStyle }), + ...(maxAttempts && { maxAttempts }), ...(httpsProxy && { requestHandler: new NodeHttpHandler({ httpsAgent: new HttpsProxyAgent({ proxy: httpsProxy }),