-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(aws-apigateway): add optional property to spec-restapi to be able to enable compression #22990
Closed
virajmavani
wants to merge
3
commits into
aws:main
from
virajmavani:feature/minimumCompressionSize_SpecRestApi
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -261,6 +261,18 @@ export interface SpecRestApiProps extends RestApiBaseProps { | |
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-import-api.html | ||
*/ | ||
readonly apiDefinition: ApiDefinition; | ||
|
||
/** | ||
* A nullable integer that is used to enable compression (with non-negative | ||
* between 0 and 10485760 (10M) bytes, inclusive) or disable compression | ||
* (when undefined) on an API. When compression is enabled, compression or | ||
* decompression is not applied on the payload if the payload size is | ||
* smaller than this value. Setting it to zero allows compression for any | ||
* payload size. | ||
* | ||
* @default - Compression is disabled. | ||
*/ | ||
readonly minimumCompressionSize?: number; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm also thinking that this should be moved into the base props instead of adding it individually to both |
||
} | ||
|
||
/** | ||
|
@@ -648,6 +660,7 @@ export class SpecRestApi extends RestApiBase { | |
name: this.restApiName, | ||
policy: props.policy, | ||
failOnWarnings: props.failOnWarnings, | ||
minimumCompressionSize: props.minimumCompressionSize, | ||
body: apiDefConfig.inlineDefinition ?? undefined, | ||
bodyS3Location: apiDefConfig.inlineDefinition ? undefined : apiDefConfig.s3Location, | ||
endpointConfiguration: this._configureEndpoints(props), | ||
|
19 changes: 19 additions & 0 deletions
19
...n.js.snapshot/apigatewayspecrestapicompressionDefaultTestDeployAssert473E8E6B.assets.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"version": "21.0.0", | ||
"files": { | ||
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { | ||
"source": { | ||
"path": "apigatewayspecrestapicompressionDefaultTestDeployAssert473E8E6B.template.json", | ||
"packaging": "file" | ||
}, | ||
"destinations": { | ||
"current_account-current_region": { | ||
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", | ||
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", | ||
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" | ||
} | ||
} | ||
} | ||
}, | ||
"dockerImages": {} | ||
} |
36 changes: 36 additions & 0 deletions
36
...js.snapshot/apigatewayspecrestapicompressionDefaultTestDeployAssert473E8E6B.template.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"Parameters": { | ||
"BootstrapVersion": { | ||
"Type": "AWS::SSM::Parameter::Value<String>", | ||
"Default": "/cdk-bootstrap/hnb659fds/version", | ||
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" | ||
} | ||
}, | ||
"Rules": { | ||
"CheckBootstrapVersion": { | ||
"Assertions": [ | ||
{ | ||
"Assert": { | ||
"Fn::Not": [ | ||
{ | ||
"Fn::Contains": [ | ||
[ | ||
"1", | ||
"2", | ||
"3", | ||
"4", | ||
"5" | ||
], | ||
{ | ||
"Ref": "BootstrapVersion" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." | ||
} | ||
] | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...n.js.snapshot/asset.68497ac876de4e963fc8f7b5f1b28844c18ecc95e3f7c6e9e0bf250e03c037fb.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
openapi: "3.0.2" | ||
info: | ||
version: 1.0.0 | ||
title: Test API for CDK | ||
paths: | ||
/pets: | ||
get: | ||
summary: Test Method | ||
operationId: testMethod | ||
responses: | ||
"200": | ||
description: A paged array of pets | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/Empty" | ||
x-amazon-apigateway-integration: | ||
responses: | ||
default: | ||
statusCode: "200" | ||
requestTemplates: | ||
application/json: "{\"statusCode\": 200}" | ||
passthroughBehavior: when_no_match | ||
type: mock | ||
|
||
components: | ||
schemas: | ||
Empty: | ||
title: Empty Schema | ||
type: object |
1 change: 1 addition & 0 deletions
1
packages/@aws-cdk/aws-apigateway/test/integ.spec-restapi.compression.js.snapshot/cdk.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"version":"21.0.0"} |
12 changes: 12 additions & 0 deletions
12
packages/@aws-cdk/aws-apigateway/test/integ.spec-restapi.compression.js.snapshot/integ.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": "21.0.0", | ||
"testCases": { | ||
"apigateway-spec-restapi-compression/DefaultTest": { | ||
"stacks": [ | ||
"test-apigateway-spec-restapi-compression" | ||
], | ||
"assertionStack": "apigateway-spec-restapi-compression/DefaultTest/DeployAssert", | ||
"assertionStackName": "apigatewayspecrestapicompressionDefaultTestDeployAssert473E8E6B" | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the limitations, could you please add validation that the number provided must be in this range? Please also add unit tests (both in range and out of range) to validate this.