Skip to content

Commit

Permalink
update to v6.2.1 open-source release (#501)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonkrol authored Aug 4, 2023
1 parent 3ca58b4 commit 3c98d1f
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 25 deletions.
26 changes: 19 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,28 @@ 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.2.0] - 2023-04-24
## [6.2.1] - 2023-08-03

### Fixed

- Template fails to deploy unless demo UI is enabled [#499](https://github.com/aws-solutions/serverless-image-handler/issues/499)
- Thumbor requests of images without a file extension would fail
- CloudFormation template description was not being generated

### Changed

- Upgraded build requirement to Node 16

## [6.2.0] - 2023-08-01

### Added

+ Add `cdk-helper` module to help with packaging cdk generated assets in solutions internal pipelines
+ Use [DefaultStackSynthesizer](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.DefaultStackSynthesizer.html) with different configurations to generate template for `cdk deploy` and on internal solutions pipeline
+ Add esbuild bundler for lambda functions using `NodejsFunction`, reference [aws_lambda_nodejs](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda_nodejs-readme.html)
+ Refactor pipeline scripts
+ Changes semver dependency version to 7.5.2 for github reported vulnerability CVE-2022-25883
+ Changes word-wrap dependency version to aashutoshrathi/word-wrap for github reported vulnerability CVE-2023-26115
- Add `cdk-helper` module to help with packaging cdk generated assets in solutions internal pipelines
- Use [DefaultStackSynthesizer](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.DefaultStackSynthesizer.html) with different configurations to generate template for `cdk deploy` and on internal solutions pipeline
- Add esbuild bundler for lambda functions using `NodejsFunction`, reference [aws_lambda_nodejs](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda_nodejs-readme.html)
- Refactor pipeline scripts
- Changes semver dependency version to 7.5.2 for github reported vulnerability CVE-2022-25883
- Changes word-wrap dependency version to aashutoshrathi/word-wrap for github reported vulnerability CVE-2023-26115

## [6.1.2] - 2023-04-14

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ In addition to the AWS Solutions Constructs, the solution uses AWS CDK directly
## Prerequisites for Customization

- [AWS Command Line Interface](https://aws.amazon.com/cli/)
- Node.js 14.x
- Node.js 16.x or later

### 1. Clone the repository

Expand Down
3 changes: 3 additions & 0 deletions source/constructs/bin/constructs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ if (DIST_OUTPUT_BUCKET && SOLUTION_NAME && VERSION)
});

const app = new App();
const solutionDisplayName = "Serverless Image Handler";
const description = `(${app.node.tryGetContext("solutionId")}) - ${solutionDisplayName}. Version ${VERSION ?? app.node.tryGetContext("solutionVersion")}`;
// eslint-disable-next-line no-new
new ServerlessImageHandlerStack(app, "ServerlessImageHandlerStack", {
synthesizer: synthesizer,
description: description,
solutionId: app.node.tryGetContext("solutionId"),
solutionVersion: app.node.tryGetContext("solutionVersion"),
solutionName: app.node.tryGetContext("solutionName"),
Expand Down
2 changes: 1 addition & 1 deletion source/constructs/cdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"app": "npx ts-node --prefer-ts-exts bin/constructs.ts",
"context": {
"solutionId": "SO0023",
"solutionVersion": "custom-6.2.0",
"solutionVersion": "custom-v6.2.1",
"solutionName": "serverless-image-handler"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { Function as LambdaFunction, Runtime } from "aws-cdk-lib/aws-lambda";
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
import { Bucket, IBucket } from "aws-cdk-lib/aws-s3";
import { BucketDeployment, Source as S3Source } from "aws-cdk-lib/aws-s3-deployment";
import { ArnFormat, Aws, CfnCondition, CfnResource, CustomResource, Duration, Lazy, Stack } from "aws-cdk-lib";
import { ArnFormat, Aspects, Aws, CfnCondition, CfnResource, CustomResource, Duration, Lazy, Stack } from "aws-cdk-lib";
import { Construct } from "constructs";
import { addCfnSuppressRules } from "../../../utils/utils";

import { SolutionConstructProps } from "../../types";
import { CommonResourcesProps, Conditions } from "../common-resources-construct";
import { ConditionAspect } from "../../../utils/aspects";

export interface CustomResourcesConstructProps extends CommonResourcesProps {
readonly conditions: Conditions;
Expand Down Expand Up @@ -179,10 +180,11 @@ export class CustomResourcesConstruct extends Construct {
public setupCopyWebsiteCustomResource(props: SetupCopyWebsiteCustomResourceProps) {
// Stage static assets for the front-end from the local
/* eslint-disable no-new */
new BucketDeployment(this, "DeployWebsite", {
const bucketDeployment = new BucketDeployment(this, "DeployWebsite", {
sources: [S3Source.asset(path.join(__dirname, "../../../../demo-ui"))],
destinationBucket: props.hostingBucket,
});
Aspects.of(bucketDeployment).add(new ConditionAspect(this.conditions.deployUICondition));
}

public setupPutWebsiteConfigCustomResource(props: SetupPutWebsiteConfigCustomResourceProps) {
Expand Down
4 changes: 3 additions & 1 deletion source/constructs/lib/serverless-image-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { PriceClass } from "aws-cdk-lib/aws-cloudfront";
import { Aspects, CfnMapping, CfnOutput, CfnParameter, Stack, StackProps, Tags } from "aws-cdk-lib";
import { Construct } from "constructs";
import { SuppressLambdaFunctionCfnRulesAspect } from "../utils/aspects";
import { ConditionAspect, SuppressLambdaFunctionCfnRulesAspect } from "../utils/aspects";
import { BackEnd } from "./back-end/back-end-construct";
import { CommonResources } from "./common-resources/common-resources-construct";
import { FrontEndConstruct as FrontEnd } from "./front-end/front-end-construct";
Expand Down Expand Up @@ -199,6 +199,8 @@ export class ServerlessImageHandlerStack extends Stack {
commonResources.customResources.setupCopyWebsiteCustomResource({
hostingBucket: frontEnd.websiteHostingBucket,
});
const singletonFunction = this.node.findChild("Custom::CDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C");
Aspects.of(singletonFunction).add(new ConditionAspect(commonResources.conditions.deployUICondition));

commonResources.customResources.setupPutWebsiteConfigCustomResource({
hostingBucket: frontEnd.websiteHostingBucket,
Expand Down
2 changes: 1 addition & 1 deletion source/constructs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "constructs",
"version": "6.2.0",
"version": "6.2.1",
"description": "Serverless Image Handler Constructs",
"license": "Apache-2.0",
"bin": {
Expand Down
17 changes: 11 additions & 6 deletions source/constructs/test/__snapshots__/constructs.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = `
"Solutions:ApplicationType": "AWS-Solutions",
"Solutions:SolutionID": "S0ABC",
"Solutions:SolutionName": "sih",
"Solutions:SolutionVersion": "v6.2.0",
"Solutions:SolutionVersion": "v6.2.1",
},
},
"Type": "AWS::ServiceCatalogAppRegistry::Application",
Expand Down Expand Up @@ -1150,9 +1150,9 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = `
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
},
"S3Key": "a0b1a27ff795cbf91cf437968a83823da180d2a071ab88a08eaadde821211f8a.zip",
"S3Key": "82f1ba8dc3b6177b733d951f282f5451925f6fb067ddd9626328d91468b7c9fc.zip",
},
"Description": "sih (v6.2.0): Performs image edits and manipulations",
"Description": "sih (v6.2.1): Performs image edits and manipulations",
"Environment": {
"Variables": {
"AUTO_WEBP": {
Expand Down Expand Up @@ -1419,13 +1419,13 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = `
},
"S3Key": "1d9c0f7ba21ae4df4d9f33af092ffe6bf4c806ea06398e947419c4e7f091d52b.zip",
},
"Description": "sih (v6.2.0): Custom resource",
"Description": "sih (v6.2.1): Custom resource",
"Environment": {
"Variables": {
"AWS_NODEJS_CONNECTION_REUSE_ENABLED": "1",
"RETRY_SECONDS": "5",
"SOLUTION_ID": "S0ABC",
"SOLUTION_VERSION": "v6.2.0",
"SOLUTION_VERSION": "v6.2.1",
},
},
"Handler": "index.handler",
Expand Down Expand Up @@ -1575,6 +1575,7 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = `
"UpdateReplacePolicy": "Delete",
},
"CommonResourcesCustomResourcesDeployWebsiteAwsCliLayerBC025F39": {
"Condition": "CommonResourcesDeployDemoUICondition308D3B09",
"Properties": {
"Content": {
"S3Bucket": {
Expand All @@ -1587,6 +1588,7 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = `
"Type": "AWS::Lambda::LayerVersion",
},
"CommonResourcesCustomResourcesDeployWebsiteCustomResourceECB9B136": {
"Condition": "CommonResourcesDeployDemoUICondition308D3B09",
"DeletionPolicy": "Delete",
"Properties": {
"DestinationBucketName": {
Expand Down Expand Up @@ -1730,6 +1732,7 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = `
"Type": "AWS::IAM::Policy",
},
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756C81C01536": {
"Condition": "CommonResourcesDeployDemoUICondition308D3B09",
"DependsOn": [
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF",
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265",
Expand Down Expand Up @@ -1788,6 +1791,7 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = `
"Type": "AWS::Lambda::Function",
},
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRole89A01265": {
"Condition": "CommonResourcesDeployDemoUICondition308D3B09",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
Expand Down Expand Up @@ -1825,6 +1829,7 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = `
"Type": "AWS::IAM::Role",
},
"CustomCDKBucketDeployment8693BB64968944B69AAFB0CC9EB8756CServiceRoleDefaultPolicy88902FDF": {
"Condition": "CommonResourcesDeployDemoUICondition308D3B09",
"Properties": {
"PolicyDocument": {
"Statement": [
Expand Down Expand Up @@ -1924,7 +1929,7 @@ exports[`Serverless Image Handler Stack Snapshot 1`] = `
"applicationType": "AWS-Solutions",
"solutionID": "S0ABC",
"solutionName": "sih",
"version": "v6.2.0",
"version": "v6.2.1",
},
"Description": "Attribute group for solution information",
"Name": {
Expand Down
2 changes: 1 addition & 1 deletion source/constructs/test/constructs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test("Serverless Image Handler Stack Snapshot", () => {
const stack = new ServerlessImageHandlerStack(app, "TestStack", {
solutionId: "S0ABC",
solutionName: "sih",
solutionVersion: "v6.2.0",
solutionVersion: "v6.2.1",
});

const template = Template.fromStack(stack);
Expand Down
2 changes: 1 addition & 1 deletion source/custom-resource/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "custom-resource",
"version": "6.2.0",
"version": "6.2.1",
"private": true,
"description": "Serverless Image Handler custom resource",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion source/image-handler/image-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ export class ImageRequest {
} else if (definedEnvironmentVariables) {
// use rewrite function then thumbor mappings
return RequestTypes.CUSTOM;
} else if (matchThumbor1.test(path) && matchThumbor2.test(path) && matchThumbor3.test(path)) {
} else if (matchThumbor1.test(path) && (matchThumbor2.test(path) || matchThumbor3.test(path))) {
// use thumbor mappings
return RequestTypes.THUMBOR;
} else {
Expand Down
2 changes: 1 addition & 1 deletion source/image-handler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "image-handler",
"version": "6.2.0",
"version": "6.2.1",
"private": true,
"description": "A Lambda function for performing on-demand image edits and manipulations.",
"license": "Apache-2.0",
Expand Down
13 changes: 13 additions & 0 deletions source/image-handler/test/image-request/parse-request-type.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,17 @@ describe("parseRequestType", () => {
});
}
});

it("Should pass if a path is provided without an extension", () => {
// Arrange
const event = { path: "/image" };

// Act
const imageRequest = new ImageRequest(s3Client, secretProvider);
const result = imageRequest.parseRequestType(event);

// Assert
const expectedResult = RequestTypes.THUMBOR;
expect(result).toEqual(expectedResult);
});
});
2 changes: 1 addition & 1 deletion source/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "source",
"version": "6.2.0",
"version": "6.2.1",
"private": true,
"description": "ESLint and prettier dependencies to be used within the solution",
"license": "Apache-2.0",
Expand Down
2 changes: 1 addition & 1 deletion source/solution-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "solution-utils",
"version": "6.2.0",
"version": "6.2.1",
"private": true,
"description": "Utilities to be used within this solution",
"license": "Apache-2.0",
Expand Down

0 comments on commit 3c98d1f

Please sign in to comment.