Skip to content

Commit bda56a2

Browse files
simonkroldbambulaks
authored andcommitted
Update to version 6.3.0 (aws-solutions#573)
1 parent bac04c9 commit bda56a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+8562
-167
lines changed

CHANGELOG.md

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,32 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [6.3.0] - 2024-09-09
9+
10+
### Added
11+
12+
- Additional anonymized metrics system to help understand how the solution is being used, identify areas of improvement, and drive future roadmap decisions.
13+
14+
### Changed
15+
16+
- Cdk update to 2.151.0
17+
- Default log retention to 180 days
18+
- Cache-control header on fallback images to use (in order of priority), fallback image metadata, header provided in image request, and default cache control [#563](https://github.com/aws-solutions/serverless-image-handler/issues/563)
19+
20+
### Security
21+
22+
- Upgraded micromatch to v4.0.8 for vulnerability CVE-2024-4067
23+
824
## [6.2.7] - 2024-08-19
925

10-
### Security
11-
- Upgraded axios to v1.7.4 for vulnerability CVE-2024-39338
26+
### Security
1227

28+
- Upgraded axios to v1.7.4 for vulnerability CVE-2024-39338
1329

1430
## [6.2.6] - 2024-06-27
1531

1632
### Added
33+
1734
- StackId tag to CloudFrontLoggingBucket and its bucket name as a CfnOutput [#529](https://github.com/aws-solutions/serverless-image-handler/issues/529)
1835
- Test case to verify UTF-8 support in object key [#320](https://github.com/aws-solutions/serverless-image-handler/pull/320)
1936
- Test cases to verify crop functionality [#459](https://github.com/aws-solutions/serverless-image-handler/pull/459)
@@ -23,6 +40,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2340
- Support for 8-bit depth AVIF image type inference [#360](https://github.com/aws-solutions/serverless-image-handler/issues/360)
2441

2542
### Changed
43+
2644
- Decreased permissions allotted to CustomResource Lambda and ImageHandler Lambda
2745
- cdk update to 2.124.0
2846
- aws-solutions-constructs update to 2.51.0
@@ -32,18 +50,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3250
- Modified JPEG SOI marker parsing to only check first 2 bytes [#429]
3351

3452
### Security
53+
3554
- Upgraded follow-redirects to v1.15.6 for vulnerability CVE-2024-28849
3655
- Upgraded braces to v3.0.3 for vulnerability CVE-2024-4068
3756

3857
### Removed
58+
3959
- Unused CopyS3Assets custom resource
4060

4161
### Fixed
62+
4263
- Some error messages indicating incorrect file types
4364
- Solution version and id not being passed to Backend Lambda
4465
- Thumbor-style URL matching being overly permissive
4566

46-
4767
## [6.2.5] - 2024-01-03
4868

4969
### Fixed

NOTICE

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,13 @@ ts-jest under the Massachusetts Institute of Technology (MIT) license
5555
ts-node under the Massachusetts Institute of Technology (MIT) license
5656
typescript under the Apache License 2.0
5757
uuid under the Massachusetts Institute of Technology (MIT) license
58+
@aws-sdk/client-cloudwatch under the Apache License 2.0
59+
@aws-sdk/client-cloudwatch-logs under the Apache License 2.0
60+
@aws-sdk/client-sqs under the Apache License 2.0
61+
@aws-solutions-constructs/aws-eventbridge-lambda under the Apache License 2.0
62+
@aws-solutions-constructs/aws-lambda-sqs-lambda under the Apache License 2.0
63+
@types/aws-lambda under the Massachusetts Institute of Technology (MIT) license
64+
esbuild under the Massachusetts Institute of Technology (MIT) license
65+
@aws-cdk/aws-servicecatalogappregistry-alpha under the Apache License 2.0
66+
@types/adm-zip under the Massachusetts Institute of Technology (MIT) license
67+
prettier under the Massachusetts Institute of Technology (MIT) license

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ This solution collects anonymous operational metrics to help AWS improve the qua
105105
- [@Fjool](https://github.com/Fjool) for [#489](https://github.com/aws-solutions/serverless-image-handler/pull/489)
106106
- [@fvsnippets](https://github.com/fvsnippets) for [#373](https://github.com/aws-solutions/serverless-image-handler/pull/373), [#380](https://github.com/aws-solutions/serverless-image-handler/pull/380)
107107
- [@ccchapman](https://github.com/ccchapman) for [#490](https://github.com/aws-solutions/serverless-image-handler/pull/490)
108-
- [@bennet-esyoil][https://github.com/bennet-esyoil] for [#521](https://github.com/aws-solutions/serverless-image-handler/pull/521)
109-
- [@vaniyokk][https://github.com/vaniyokk] for [#511](https://github.com/aws-solutions/serverless-image-handler/pull/511)
108+
- [@bennet-esyoil](https://github.com/bennet-esyoil) for [#521](https://github.com/aws-solutions/serverless-image-handler/pull/521)
109+
- [@vaniyokk](https://github.com/vaniyokk) for [#511](https://github.com/aws-solutions/serverless-image-handler/pull/511)
110+
- [@nicolasbuch](https://github.com/nicolasbuch) for [#569](https://github.com/aws-solutions/serverless-image-handler/pull/569)
111+
- [@mrnonz](https://github.com/mrnonz) for [#567](https://github.com/aws-solutions/serverless-image-handler/pull/567)
110112

111113
# License
112114

VERSION.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.2.7
1+
6.3.0

deployment/cdk-solution-helper/asset-packager/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
import { CDKAssetPackager } from "./asset-packager";
7-
import path from "path";
87

98
export async function handler(cdkAssetFolderPath: string | undefined, outputPath: string | undefined) {
109
if (!cdkAssetFolderPath || !outputPath) throw new Error("undefined input path");

deployment/cdk-solution-helper/package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deployment/run-unit-tests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ template_dir="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd
3535
cdk_dir="$template_dir/../source/constructs"
3636
image_handler_dir="$template_dir/../source/image-handler"
3737
custom_resource_dir="$template_dir/../source/custom-resource"
38+
metrics_utils_dir="$template_dir/../source/metrics-utils"
3839
coverage_reports_top_path="$template_dir/../source/test/coverage-reports"
3940

4041
headline "[Tests] Run unit tests"
4142
declare -a packages=(
4243
"$cdk_dir"
4344
"$image_handler_dir"
4445
"$custom_resource_dir"
46+
"$metrics_utils_dir"
4547
)
4648
for package in "${packages[@]}"; do
4749
cd "$package"

source/constructs/cdk.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"app": "npx ts-node --prefer-ts-exts bin/constructs.ts",
33
"context": {
44
"solutionId": "SO0023",
5-
"solutionVersion": "custom-v6.2.7",
5+
"solutionVersion": "custom-v6.3.0",
66
"solutionName": "serverless-image-handler"
77
}
88
}

source/constructs/lib/back-end/back-end-construct.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,21 @@ import { Runtime } from "aws-cdk-lib/aws-lambda";
2121
import { NodejsFunction } from "aws-cdk-lib/aws-lambda-nodejs";
2222
import { LogGroup, RetentionDays } from "aws-cdk-lib/aws-logs";
2323
import { IBucket } from "aws-cdk-lib/aws-s3";
24-
import { ArnFormat, Aws, Duration, Lazy, Stack } from "aws-cdk-lib";
24+
import { ArnFormat, Aspects, Aws, CfnCondition, Duration, Fn, Lazy, Stack } from "aws-cdk-lib";
2525
import { Construct } from "constructs";
2626
import { CloudFrontToApiGatewayToLambda } from "@aws-solutions-constructs/aws-cloudfront-apigateway-lambda";
2727

2828
import { addCfnSuppressRules } from "../../utils/utils";
2929
import { SolutionConstructProps } from "../types";
3030
import * as api from "aws-cdk-lib/aws-apigateway";
31+
import { SolutionsMetrics, ExecutionDay } from "metrics-utils";
32+
import { ConditionAspect } from "../../utils/aspects";
3133

3234
export interface BackEndProps extends SolutionConstructProps {
3335
readonly solutionVersion: string;
3436
readonly solutionId: string;
3537
readonly solutionName: string;
38+
readonly sendAnonymousStatistics: CfnCondition;
3639
readonly secretsManagerPolicy: Policy;
3740
readonly logsBucket: IBucket;
3841
readonly uuid: string;
@@ -231,5 +234,34 @@ export class BackEnd extends Construct {
231234
imageHandlerCloudFrontApiGatewayLambda.apiGateway.node.tryRemoveChild("Endpoint"); // we don't need the RestApi endpoint in the outputs
232235

233236
this.domainName = imageHandlerCloudFrontApiGatewayLambda.cloudFrontWebDistribution.distributionDomainName;
237+
238+
const shortLogRetentionCondition: CfnCondition = new CfnCondition(this, "ShortLogRetentionCondition", {
239+
expression: Fn.conditionOr(
240+
Fn.conditionEquals(props.logRetentionPeriod.toString(), "1"),
241+
Fn.conditionEquals(props.logRetentionPeriod.toString(), "3"),
242+
Fn.conditionEquals(props.logRetentionPeriod.toString(), "5")
243+
),
244+
});
245+
const solutionsMetrics = new SolutionsMetrics(this, "SolutionMetrics", {
246+
uuid: props.uuid,
247+
executionDay: Fn.conditionIf(
248+
shortLogRetentionCondition.logicalId,
249+
ExecutionDay.DAILY,
250+
ExecutionDay.MONDAY
251+
).toString(),
252+
});
253+
solutionsMetrics.addLambdaInvocationCount(imageHandlerLambdaFunction.functionName);
254+
solutionsMetrics.addLambdaBilledDurationMemorySize([imageHandlerLogGroup], "BilledDurationMemorySizeQuery");
255+
solutionsMetrics.addCloudFrontMetric(
256+
imageHandlerCloudFrontApiGatewayLambda.cloudFrontWebDistribution.distributionId,
257+
"Requests"
258+
);
259+
260+
solutionsMetrics.addCloudFrontMetric(
261+
imageHandlerCloudFrontApiGatewayLambda.cloudFrontWebDistribution.distributionId,
262+
"BytesDownloaded"
263+
);
264+
265+
Aspects.of(solutionsMetrics).add(new ConditionAspect(props.sendAnonymousStatistics));
234266
}
235267
}

source/constructs/lib/serverless-image-stack.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
import { PriceClass } from "aws-cdk-lib/aws-cloudfront";
5-
import { Aspects, CfnMapping, CfnOutput, CfnParameter, Stack, StackProps, Tags } from "aws-cdk-lib";
5+
import { Aspects, CfnCondition, CfnMapping, CfnOutput, CfnParameter, Fn, Stack, StackProps, Tags } from "aws-cdk-lib";
66
import { Construct } from "constructs";
77
import { ConditionAspect, SuppressLambdaFunctionCfnRulesAspect } from "../utils/aspects";
88
import { BackEnd } from "./back-end/back-end-construct";
@@ -79,7 +79,7 @@ export class ServerlessImageHandlerStack extends Stack {
7979
"1827",
8080
"3653",
8181
],
82-
default: "1",
82+
default: "180",
8383
});
8484

8585
const autoWebPParameter = new CfnParameter(this, "AutoWebPParameter", {
@@ -145,10 +145,13 @@ export class ServerlessImageHandlerStack extends Stack {
145145
Version: props.solutionVersion,
146146
},
147147
},
148-
lazy: true,
148+
lazy: false,
149149
});
150150

151151
const anonymousUsage = `${solutionMapping.findInMap("Config", "AnonymousUsage")}`;
152+
const sendAnonymousStatistics = new CfnCondition(this, "SendAnonymousStatistics", {
153+
expression: Fn.conditionEquals(anonymousUsage, "Yes"),
154+
});
152155

153156
const solutionConstructProps: SolutionConstructProps = {
154157
corsEnabled: corsEnabledParameter.valueAsString,
@@ -183,6 +186,7 @@ export class ServerlessImageHandlerStack extends Stack {
183186
solutionId: props.solutionId,
184187
solutionName: props.solutionName,
185188
secretsManagerPolicy: commonResources.secretsManagerPolicy,
189+
sendAnonymousStatistics,
186190
logsBucket: commonResources.logsBucket,
187191
uuid: commonResources.customResources.uuid,
188192
cloudFrontPriceClass: cloudFrontPriceClassParameter.valueAsString,
@@ -343,7 +347,7 @@ export class ServerlessImageHandlerStack extends Stack {
343347
new CfnOutput(this, "CloudFrontLoggingBucket", {
344348
value: commonResources.logsBucket.bucketName,
345349
description: "Amazon S3 bucket for storing CloudFront access logs.",
346-
})
350+
});
347351

348352
Aspects.of(this).add(new SuppressLambdaFunctionCfnRulesAspect());
349353
Tags.of(this).add("SolutionId", props.solutionId);

0 commit comments

Comments
 (0)