-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
feat(apigateway): minCompressionSize on SpecRestApi #24067
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
eb774c1
MinimumCompressionSize prop to SpecRestApi
pattasai d2ce75d
deprecated minimumCompressionSize
pattasai 2ea8ec7
fixed error minimumCompressionSize
pattasai 52884e9
Merge branch 'main' into pattasai-MinimumCompressionSize-SpecRestApi
pattasai 54e254f
Merge branch 'main' into pattasai-MinimumCompressionSize-SpecRestApi
pattasai ac12230
Merge branch 'main' into pattasai-MinimumCompressionSize-SpecRestApi
rix0rrr 6a556a9
Integ-test
pattasai c5d4c58
creating testDeprecated
pattasai ca26883
additional test cases
pattasai 54d9345
newtestcases
pattasai f6f1f12
restapichanges
pattasai 9b9ea6c
Merge branch 'main' into pattasai-MinimumCompressionSize-SpecRestApi
mergify[bot] 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
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,7 +1,7 @@ | ||||||
import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; | ||||||
import { IVpcEndpoint } from '@aws-cdk/aws-ec2'; | ||||||
import * as iam from '@aws-cdk/aws-iam'; | ||||||
import { ArnFormat, CfnOutput, IResource as IResourceBase, Resource, Stack, Token, FeatureFlags, RemovalPolicy } from '@aws-cdk/core'; | ||||||
import { ArnFormat, CfnOutput, IResource as IResourceBase, Resource, Stack, Token, FeatureFlags, RemovalPolicy, Size } from '@aws-cdk/core'; | ||||||
import { APIGATEWAY_DISABLE_CLOUDWATCH_ROLE } from '@aws-cdk/cx-api'; | ||||||
import { Construct } from 'constructs'; | ||||||
import { ApiDefinition } from './api-definition'; | ||||||
|
@@ -225,9 +225,22 @@ export interface RestApiProps extends RestApiOptions { | |||||
* payload size. | ||||||
* | ||||||
* @default - Compression is disabled. | ||||||
* @deprecated - superseded by `minCompressionSize` | ||||||
*/ | ||||||
readonly minimumCompressionSize?: number; | ||||||
|
||||||
/** | ||||||
* A Size(in bytes, kibibytes, mebibytes etc) 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 minCompressionSize?: Size; | ||||||
|
||||||
/** | ||||||
* The ID of the API Gateway RestApi resource that you want to clone. | ||||||
* | ||||||
|
@@ -261,6 +274,18 @@ export interface SpecRestApiProps extends RestApiBaseProps { | |||||
* @see https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-import-api.html | ||||||
*/ | ||||||
readonly apiDefinition: ApiDefinition; | ||||||
|
||||||
/** | ||||||
* A Size(in bytes, kibibytes, mebibytes etc) 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 minCompressionSize?: Size; | ||||||
} | ||||||
|
||||||
/** | ||||||
|
@@ -648,6 +673,7 @@ export class SpecRestApi extends RestApiBase { | |||||
name: this.restApiName, | ||||||
policy: props.policy, | ||||||
failOnWarnings: props.failOnWarnings, | ||||||
minimumCompressionSize: props.minCompressionSize?.toBytes(), | ||||||
body: apiDefConfig.inlineDefinition ?? undefined, | ||||||
bodyS3Location: apiDefConfig.inlineDefinition ? undefined : apiDefConfig.s3Location, | ||||||
endpointConfiguration: this._configureEndpoints(props), | ||||||
|
@@ -758,12 +784,16 @@ export class RestApi extends RestApiBase { | |||||
constructor(scope: Construct, id: string, props: RestApiProps = { }) { | ||||||
super(scope, id, props); | ||||||
|
||||||
if (props.minCompressionSize?.toBytes()! >= 0 && props.minimumCompressionSize! >= 0) { | ||||||
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.
Suggested change
|
||||||
throw new Error('both properties minCompressionSize and minimumCompressionSize cannot be set at once.'); | ||||||
} | ||||||
|
||||||
const resource = new CfnRestApi(this, 'Resource', { | ||||||
name: this.physicalName, | ||||||
description: props.description, | ||||||
policy: props.policy, | ||||||
failOnWarnings: props.failOnWarnings, | ||||||
minimumCompressionSize: props.minimumCompressionSize, | ||||||
rix0rrr marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
minimumCompressionSize: props.minCompressionSize?.toBytes() ?? props.minimumCompressionSize, | ||||||
binaryMediaTypes: props.binaryMediaTypes, | ||||||
endpointConfiguration: this._configureEndpoints(props), | ||||||
apiKeySourceType: props.apiKeySourceType, | ||||||
|
2 changes: 1 addition & 1 deletion
2
...st/integ.restapi.js.snapshot/apigatewayrestapiDefaultTestDeployAssert6A9696A7.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
2 changes: 1 addition & 1 deletion
2
packages/@aws-cdk/aws-apigateway/test/integ.restapi.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 |
---|---|---|
@@ -1 +1 @@ | ||
{"version":"21.0.0"} | ||
{"version":"30.0.0"} |
2 changes: 1 addition & 1 deletion
2
packages/@aws-cdk/aws-apigateway/test/integ.restapi.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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": "21.0.0", | ||
"version": "30.0.0", | ||
"testCases": { | ||
"apigateway-restapi/DefaultTest": { | ||
"stacks": [ | ||
|
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
6 changes: 3 additions & 3 deletions
6
...aws-cdk/aws-apigateway/test/integ.restapi.js.snapshot/test-apigateway-restapi.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
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
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.
👨🍳👌