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.
chore(elbv2/ecs): clarify cross-stack ELB usage (aws#4667)
* chore(elbv2/ecs): clarify cross-stack ELB usage Add a note to ELB's and ECS's READMEs to indicate that cross-stack ELB usage will look different from the simple examples, and link to a working example in the `aws-cdk-examples` repository. Move `addTarget()` onto `I***TargetGroup` so that its usage can follow common cross-construct usage patterns, and throw an appropriate error when registration cannot work for imported target groups. Add better validation/messaging around some mistakes I made while putting together the example. Fixes aws#4408. * Update READMEs, restore parameter for backwards compatibility * Fix code introduced in parallel
- Loading branch information
1 parent
9b7d2d0
commit 56bc808
Showing
9 changed files
with
167 additions
and
14 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
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
56 changes: 56 additions & 0 deletions
56
packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/test.target-group.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,56 @@ | ||
import ec2 = require('@aws-cdk/aws-ec2'); | ||
import cdk = require('@aws-cdk/core'); | ||
import { Test } from 'nodeunit'; | ||
import elbv2 = require('../../lib'); | ||
import { InstanceTarget } from '../../lib'; | ||
import { FakeSelfRegisteringTarget } from '../helpers'; | ||
|
||
export = { | ||
'Empty target Group without type still requires a VPC'(test: Test) { | ||
// GIVEN | ||
const app = new cdk.App(); | ||
const stack = new cdk.Stack(app, 'Stack'); | ||
|
||
// WHEN | ||
new elbv2.ApplicationTargetGroup(stack, 'LB', {}); | ||
|
||
// THEN | ||
test.throws(() => { | ||
app.synth(); | ||
}, /'vpc' is required for a non-Lambda TargetGroup/); | ||
|
||
test.done(); | ||
}, | ||
|
||
'Can add self-registering target to imported TargetGroup'(test: Test) { | ||
// GIVEN | ||
const app = new cdk.App(); | ||
const stack = new cdk.Stack(app, 'Stack'); | ||
const vpc = new ec2.Vpc(stack, 'Vpc'); | ||
|
||
// WHEN | ||
const tg = elbv2.ApplicationTargetGroup.fromTargetGroupAttributes(stack, 'TG', { | ||
targetGroupArn: 'arn' | ||
}); | ||
tg.addTarget(new FakeSelfRegisteringTarget(stack, 'Target', vpc)); | ||
|
||
// THEN | ||
test.done(); | ||
}, | ||
|
||
'Cannot add direct target to imported TargetGroup'(test: Test) { | ||
// GIVEN | ||
const app = new cdk.App(); | ||
const stack = new cdk.Stack(app, 'Stack'); | ||
const tg = elbv2.ApplicationTargetGroup.fromTargetGroupAttributes(stack, 'TG', { | ||
targetGroupArn: 'arn' | ||
}); | ||
|
||
// WHEN | ||
test.throws(() => { | ||
tg.addTarget(new InstanceTarget('i-1234')); | ||
}, /Cannot add a non-self registering target to an imported TargetGroup/); | ||
|
||
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
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