forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api-gateway): SpecRestApi ignores disableExecuteApiEndpoint prope…
…rty (aws#22133) In this [PR](aws#14526) the disableExecuteApiEndpoint property was added to RestApiBaseProps, which is used by both RestApi and SpecRestApi. The property is propagated to the resulting CfnRestApi when specified for a RestApi, but is ignored when specified for a SpecRestApi. Closes aws#21295. ---- ### All Submissions: * [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
1 parent
5bfff38
commit 903e938
Showing
12 changed files
with
2,431 additions
and
1 deletion.
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
92 changes: 92 additions & 0 deletions
92
packages/@aws-cdk/aws-apigateway/test/integ.spec-restapi.ts
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,92 @@ | ||
import * as path from 'path'; | ||
import * as lambda from '@aws-cdk/aws-lambda'; | ||
import * as cdk from '@aws-cdk/core'; | ||
import { IntegTest } from '@aws-cdk/integ-tests'; | ||
import * as apigateway from '../lib'; | ||
|
||
class Test extends cdk.Stack { | ||
constructor(scope: cdk.App, id: string) { | ||
super(scope, id); | ||
|
||
const api = new apigateway.SpecRestApi(this, 'my-api', { | ||
apiDefinition: apigateway.ApiDefinition.fromAsset(path.join(__dirname, 'sample-definition.yaml')), | ||
disableExecuteApiEndpoint: true, | ||
retainDeployments: true, | ||
cloudWatchRole: true, | ||
deployOptions: { | ||
cacheClusterEnabled: true, | ||
stageName: 'beta', | ||
description: 'beta stage', | ||
loggingLevel: apigateway.MethodLoggingLevel.INFO, | ||
dataTraceEnabled: true, | ||
methodOptions: { | ||
'/api/appliances/GET': { | ||
cachingEnabled: true, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
const handler = new lambda.Function(this, 'MyHandler', { | ||
runtime: lambda.Runtime.NODEJS_14_X, | ||
code: lambda.Code.fromInline(`exports.handler = ${handlerCode}`), | ||
handler: 'index.handler', | ||
}); | ||
|
||
const v1 = api.root.addResource('v1'); | ||
|
||
const integration = new apigateway.LambdaIntegration(handler); | ||
|
||
const toys = v1.addResource('toys'); | ||
const getToysMethod: apigateway.Method = toys.addMethod('GET', integration, { apiKeyRequired: true }); | ||
toys.addMethod('POST'); | ||
toys.addMethod('PUT'); | ||
|
||
const appliances = v1.addResource('appliances'); | ||
appliances.addMethod('GET'); | ||
|
||
const books = v1.addResource('books'); | ||
books.addMethod('GET', integration); | ||
books.addMethod('POST', integration); | ||
|
||
function handlerCode(event: any, _: any, callback: any) { | ||
return callback(undefined, { | ||
isBase64Encoded: false, | ||
statusCode: 200, | ||
headers: { 'content-type': 'application/json' }, | ||
body: JSON.stringify(event), | ||
}); | ||
} | ||
|
||
const key = api.addApiKey('ApiKey'); | ||
const plan = api.addUsagePlan('UsagePlan', { | ||
name: 'Basic', | ||
apiKey: key, | ||
description: 'Free tier monthly usage plan', | ||
throttle: { rateLimit: 5 }, | ||
quota: { | ||
limit: 10000, | ||
period: apigateway.Period.MONTH, | ||
}, | ||
}); | ||
plan.addApiStage({ | ||
stage: api.deploymentStage, | ||
throttle: [ | ||
{ | ||
method: getToysMethod, | ||
throttle: { | ||
rateLimit: 10, | ||
burstLimit: 2, | ||
}, | ||
}, | ||
], | ||
}); | ||
} | ||
} | ||
|
||
const app = new cdk.App(); | ||
|
||
const testCase = new Test(app, 'test-apigateway-spec-restapi'); | ||
new IntegTest(app, 'apigateway-spec-restapi', { | ||
testCases: [testCase], | ||
}); |
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
19 changes: 19 additions & 0 deletions
19
...c-restapi.integ.snapshot/apigatewayspecrestapiDefaultTestDeployAssertD16AA485.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": "apigatewayspecrestapiDefaultTestDeployAssertD16AA485.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
...restapi.integ.snapshot/apigatewayspecrestapiDefaultTestDeployAssertD16AA485.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
...nteg.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/spec-restapi.integ.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/spec-restapi.integ.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/DefaultTest": { | ||
"stacks": [ | ||
"test-apigateway-spec-restapi" | ||
], | ||
"assertionStack": "apigateway-spec-restapi/DefaultTest/DeployAssert", | ||
"assertionStackName": "apigatewayspecrestapiDefaultTestDeployAssertD16AA485" | ||
} | ||
} | ||
} |
Oops, something went wrong.