Started changes from suggestions made on recent PR.

Signed-off-by: Sean Tan <seant@splunk.com>
This commit is contained in:
Sean Tan
2021-07-26 09:47:04 -07:00
parent bb083bea35
commit b8cb120092
5 changed files with 31 additions and 10 deletions
-6
View File
@@ -1,6 +0,0 @@
---
'@backstage/backend-common': minor
'@backstage/integration': minor
---
Add AWS S3 Url Reader
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/backend-common': patch
'@backstage/integration': patch
---
Add AWS S3 URL Reader
@@ -34,8 +34,15 @@ const parseURL = (
): { path: string; bucket: string; region: string } => {
let { host, pathname } = new URL(url);
/**
* Removes the trailing '/' from the pathname to be processed
* by AWS S3 SDK methods.
*/
pathname = pathname.substr(1);
/** *
* This checks that the given URL is a valid S3 object url.
* Format of a Valid URL: https://bucket-name.s3.Region.amazonaws.com/keyname
*/
const validHost = new RegExp(
/^[a-z\d][a-z\d\.-]{1,61}[a-z\d]\.s3\.[a-z\d-]+\.amazonaws.com$/,
);
@@ -64,8 +71,8 @@ export class AwsS3UrlReader implements UrlReader {
);
let s3: S3;
if (!awsS3Config.accessKeyId || !awsS3Config.secretAccessKey) {
logger.info(
'awsS3 credentials not found in config. Using default credentials provider.',
logger.debug(
'integrations.awsS3 not found in app config. AWS S3 integration will use default AWS credentials if set in environment.',
);
s3 = new S3({});
} else {
+14
View File
@@ -163,5 +163,19 @@ export interface Config {
*/
privateKey?: string;
};
/** Integration configuration for AWS S3 Service */
awsS3?: {
/**
* Account access key used to authenticate requests.
* @visibility backend
*/
accessKeyID?: string;
/**
* Account secret key used to authenticate requests.
* @visibility secret
*/
secretAccessKey?: string;
};
};
}
+1 -1
View File
@@ -53,5 +53,5 @@ export function readAwsS3IntegrationConfig(
const secretAccessKey = config.getString('secretAccessKey');
return { accessKeyId: accessKeyId, secretAccessKey: secretAccessKey };
return { accessKeyId, secretAccessKey };
}