diff --git a/CHANGELOG.md b/CHANGELOG.md index c69ac7cdd..594ede86a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,14 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [6.1.1] - 2022-01-26 +## [6.1.1] - 2023-02-09 ### Added - package-lock.json for all modules [#426](https://github.com/aws-solutions/serverless-image-handler/pull/426) - github workflows for running unit test, eslint and prettier formatting, cdk nag, security scans [#402](https://github.com/aws-solutions/serverless-image-handler/pull/402) - demo-ui unicode support [#416](https://github.com/aws-solutions/serverless-image-handler/issues/416) +- support for multiple cloudformation stack deployments in the same region [#438](https://github.com/aws-solutions/serverless-image-handler/pull/438) ### Changed diff --git a/source/constructs/lib/common-resources/common-resources-construct.ts b/source/constructs/lib/common-resources/common-resources-construct.ts index 5878398e9..20b7e9f70 100644 --- a/source/constructs/lib/common-resources/common-resources-construct.ts +++ b/source/constructs/lib/common-resources/common-resources-construct.ts @@ -93,7 +93,7 @@ export class CommonResources extends Construct { const applicationType = "AWS-Solutions"; const application = new appreg.Application(stack, "AppRegistry", { - applicationName: Fn.join("-", [props.applicationName, Aws.REGION, Aws.ACCOUNT_ID]), + applicationName: Fn.join("-", ["AppRegistry", Aws.STACK_NAME, Aws.REGION, Aws.ACCOUNT_ID]), description: `Service Catalog application to track and manage all your resources for the solution ${props.applicationName}`, }); application.associateStack(stack); @@ -104,7 +104,7 @@ export class CommonResources extends Construct { Tags.of(application).add("Solutions:ApplicationType", applicationType); const attributeGroup = new appreg.AttributeGroup(stack, "DefaultApplicationAttributes", { - attributeGroupName: Aws.STACK_NAME, + attributeGroupName: `AppRegistry-${Aws.STACK_NAME}`, description: "Attribute group for solution information", attributes: { applicationType, diff --git a/source/constructs/test/__snapshots__/constructs.test.ts.snap b/source/constructs/test/__snapshots__/constructs.test.ts.snap index 02bbeaf95..1546e1cc4 100644 --- a/source/constructs/test/__snapshots__/constructs.test.ts.snap +++ b/source/constructs/test/__snapshots__/constructs.test.ts.snap @@ -333,7 +333,10 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = ` "Fn::Join": [ "-", [ - "sih", + "AppRegistry", + { + "Ref": "AWS::StackName", + }, { "Ref": "AWS::Region", }, @@ -1823,7 +1826,15 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = ` }, "Description": "Attribute group for solution information", "Name": { - "Ref": "AWS::StackName", + "Fn::Join": [ + "", + [ + "AppRegistry-", + { + "Ref": "AWS::StackName", + }, + ], + ], }, "Tags": { "SolutionId": "S0ABC", diff --git a/source/demo-ui/scripts.js b/source/demo-ui/scripts.js index dfaa7e622..4966fde6a 100644 --- a/source/demo-ui/scripts.js +++ b/source/demo-ui/scripts.js @@ -18,10 +18,13 @@ function importOriginalImage() { // Assemble the image request const request = { bucket: bucketName, - key: encodeURIComponent(keyName) + key: keyName } const strRequest = JSON.stringify(request); - const encRequest = btoa(strRequest); + const encRequest = btoa(encodeURIComponent(strRequest).replace(/%([0-9A-F]{2})/g, function(match, p1) { + return String.fromCharCode(parseInt(p1, 16)) + })); + // Import the image data into the element $(`#img-original`) .attr(`src`, `${appVariables.apiEndpoint}/${encRequest}`) @@ -77,14 +80,18 @@ function getPreviewImage() { // Set up the request body const request = { bucket: bucketName, - key: encodeURIComponent(keyName), + key: keyName, edits: _edits } if (Object.keys(request.edits).length === 0) { delete request.edits } console.log(request); // Setup encoded request const str = JSON.stringify(request); - const enc = btoa(str); + + const enc = btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) { + return String.fromCharCode(parseInt(p1, 16)) + })); + // Fill the preview image $(`#img-preview`).attr(`src`, `${appVariables.apiEndpoint}/${enc}`); // Fill the request body field diff --git a/source/image-handler/image-handler.ts b/source/image-handler/image-handler.ts index beef93f36..82cd67937 100644 --- a/source/image-handler/image-handler.ts +++ b/source/image-handler/image-handler.ts @@ -443,7 +443,7 @@ export class ImageHandler { alpha: string, sourceImageMetadata: sharp.Metadata ): Promise { - const params = { Bucket: bucket, Key: decodeURIComponent(key) }; + const params = { Bucket: bucket, Key: key }; try { const { width, height } = sourceImageMetadata; const overlayImage: S3.GetObjectOutput = await this.s3Client.getObject(params).promise(); diff --git a/source/image-handler/image-request.ts b/source/image-handler/image-request.ts index d23350d75..f17b25e44 100644 --- a/source/image-handler/image-request.ts +++ b/source/image-handler/image-request.ts @@ -269,7 +269,7 @@ export class ImageRequest { if (requestType === RequestTypes.DEFAULT) { // Decode the image request and return the image key const { key } = this.decodeRequest(event); - return decodeURIComponent(key); + return key; } if (requestType === RequestTypes.THUMBOR || requestType === RequestTypes.CUSTOM) {