Repository: spotify/backstage
File: plugins/techdocs-node/src/stages/publish/awsS3.ts (TypeScript)

Code before:

    const sse = config.getOptionalString('techdocs.publisher.awsS3.sse') as
      | 'aws:kms'
      | 'AES256'
      | undefined;

    // AWS Region is an optional config. If missing, default AWS env variable AWS_REGION
    // or AWS shared credentials file at ~/.aws/credentials will be used.
    const region = config.getOptionalString('techdocs.publisher.awsS3.region');

    // Credentials can optionally be configured by specifying the AWS account ID, which will retrieve credentials
    // for the account from the 'aws' section of the app config.
    // Credentials can also optionally be directly configured in the techdocs awsS3 config, but this method is
    // deprecated.
    // If no credentials are configured, the AWS SDK V3's default credential chain will be used.
    const accountId = config.getOptionalString(
      'techdocs.publisher.awsS3.accountId',
    );
    const credentialsConfig = config.getOptionalConfig(
      'techdocs.publisher.awsS3.credentials',
    );

    const credsManager = DefaultAwsCredentialsManager.fromConfig(config);

    const awsS3IntegrationConfig =
      config.getOptionalConfigArray('integrations.awsS3');

    const sdkCredentialProvider = await AwsS3Publish.buildCredentials(
      credsManager,
      logger,
      accountId,
      credentialsConfig,
      region,
      awsS3IntegrationConfig,
    );

    // 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',
    );

    // AWS HTTPS proxy is an optional config. If missing, no proxy is used
    const httpsProxy = config.getOptionalString(
      'techdocs.publisher.awsS3.httpsProxy',
    );

    // AWS forcePathStyle is an optional config. If missing, it defaults to false. Needs to be enabled for cases
    // where endpoint url points to locally hosted S3 compatible storage like Localstack
    const forcePathStyle = config.getOptionalBoolean(
      'techdocs.publisher.awsS3.s3ForcePathStyle',

Review comment (suggestion):
You should not try to touch the integrations config directly. [Use `ScmIntegrations.fromConfig` instead](https://github.com/backstage/backstage/blob/f7aef07e509251ce3145d7f502a8e537aa0060c4/packages/integration/src/ScmIntegrations.ts#L65) and then its `.awsS3` API.

Ideally there should be an integrationsServiceRef but that's for the future.

Code after:
    );

    const sse = config.getOptionalString('techdocs.publisher.awsS3.sse') as
      | 'aws:kms'
      | 'AES256'
      | undefined;

    // AWS Region is an optional config. If missing, default AWS env variable AWS_REGION
    // or AWS shared credentials file at ~/.aws/credentials will be used.
    const region = config.getOptionalString('techdocs.publisher.awsS3.region');

    // Credentials can optionally be configured by specifying the AWS account ID, which will retrieve credentials
    // for the account from the 'aws' section of the app config.
    // Credentials can also optionally be directly configured in the techdocs awsS3 config, but this method is
    // deprecated.
    // If no credentials are configured, the AWS SDK V3's default credential chain will be used.
    const accountId = config.getOptionalString(
      'techdocs.publisher.awsS3.accountId',
    );
    const credentialsConfig = config.getOptionalConfig(
      'techdocs.publisher.awsS3.credentials',
    );

    const credsManager = DefaultAwsCredentialsManager.fromConfig(config);

    const scmIntegrations = ScmIntegrations.fromConfig(config);
    const awsS3Integrations = scmIntegrations.awsS3.list();

    const sdkCredentialProvider = await AwsS3Publish.buildCredentials(
      credsManager,
      logger,
      awsS3Integrations,
      accountId,
      credentialsConfig,
      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',
    );

    // AWS HTTPS proxy is an optional config. If missing, no proxy is used
    const httpsProxy = config.getOptionalString(
      'techdocs.publisher.awsS3.httpsProxy',
    );

    // AWS forcePathStyle is an optional config. If missing, it defaults to false. Needs to be enabled for cases
    // where endpoint url points to locally hosted S3 compatible storage like Localstack
    const forcePathStyle = config.getOptionalBoolean(