Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(apigateway): modernize Integration.bind() (#8814)
Currently, the Method construct reaches into the internals of the Integration class to construct itself, via the _props() internal method. Change to a more recent pattern where the bind() returns a result that contains all of the information that the Method class requires to finalize the bind. Motivation for the change This change - #8813 - requires a property returned to the Method that is not user specified. The change already introduces this pattern. This PR takes it a bit further and applies the same logic to existing properties, so that there is now only one way for the Method to get the result of the bind. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
Niranjan Jayakar
committed
Jul 2, 2020
1 parent
4fad9bc
commit 8d41671
Showing
6 changed files
with
116 additions
and
104 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import * as ec2 from '@aws-cdk/aws-ec2'; | ||
import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2'; | ||
import * as iam from '@aws-cdk/aws-iam'; | ||
import * as cdk from '@aws-cdk/core'; | ||
import { Test } from 'nodeunit'; | ||
import * as apigw from '../lib'; | ||
|
||
export = { | ||
'integration "credentialsRole" and "credentialsPassthrough" are mutually exclusive'(test: Test) { | ||
// GIVEN | ||
const stack = new cdk.Stack(); | ||
const role = new iam.Role(stack, 'MyRole', { assumedBy: new iam.ServicePrincipal('foo') }); | ||
|
||
// THEN | ||
test.throws(() => new apigw.Integration({ | ||
type: apigw.IntegrationType.AWS_PROXY, | ||
options: { | ||
credentialsPassthrough: true, | ||
credentialsRole: role, | ||
}, | ||
}), /'credentialsPassthrough' and 'credentialsRole' are mutually exclusive/); | ||
test.done(); | ||
}, | ||
|
||
'integration connectionType VpcLink requires vpcLink to be set'(test: Test) { | ||
test.throws(() => new apigw.Integration({ | ||
type: apigw.IntegrationType.HTTP_PROXY, | ||
integrationHttpMethod: 'ANY', | ||
options: { | ||
connectionType: apigw.ConnectionType.VPC_LINK, | ||
}, | ||
}), /'connectionType' of VPC_LINK requires 'vpcLink' prop to be set/); | ||
test.done(); | ||
}, | ||
|
||
'connectionType of INTERNET and vpcLink are mutually exclusive'(test: Test) { | ||
// GIVEN | ||
const stack = new cdk.Stack(); | ||
const vpc = new ec2.Vpc(stack, 'VPC'); | ||
const nlb = new elbv2.NetworkLoadBalancer(stack, 'NLB', { | ||
vpc, | ||
}); | ||
const link = new apigw.VpcLink(stack, 'link', { | ||
targets: [nlb], | ||
}); | ||
|
||
// THEN | ||
test.throws(() => new apigw.Integration({ | ||
type: apigw.IntegrationType.HTTP_PROXY, | ||
integrationHttpMethod: 'ANY', | ||
options: { | ||
connectionType: apigw.ConnectionType.INTERNET, | ||
vpcLink: link, | ||
}, | ||
}), /cannot set 'vpcLink' where 'connectionType' is INTERNET/); | ||
test.done(); | ||
}, | ||
}; |
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