Skip to content

Commit

Permalink
fix(aws-elasticloadbalancingv2): 'targetType' on groups (#1174)
Browse files Browse the repository at this point in the history
It's now possible to configure a 'targetType' on empty TargetGroups.
  • Loading branch information
rix0rrr authored Nov 15, 2018
1 parent c1ea944 commit b4293f2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ export interface BaseTargetGroupProps {
* @default No health check
*/
healthCheck?: HealthCheck;

/**
* The type of targets registered to this TargetGroup, either IP or Instance.
*
* All targets registered into the group must be of this type. If you
* register targets to the TargetGroup in the CDK app, the TargetType is
* determined automatically.
*
* @default Determined automatically
*/
targetType?: TargetType;
}

/**
Expand Down Expand Up @@ -179,6 +190,7 @@ export abstract class BaseTargetGroup extends cdk.Construct implements ITargetGr
}

this.healthCheck = baseProps.healthCheck || {};
this.targetType = baseProps.targetType;

this.resource = new cloudformation.TargetGroupResource(this, 'Resource', {
targetGroupName: baseProps.targetGroupName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,26 @@ export = {
test.done();
},

'Can configure targetType on TargetGroups'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
const vpc = new ec2.VpcNetwork(stack, 'Stack');

// WHEN
new elbv2.ApplicationTargetGroup(stack, 'TargetGroup', {
vpc,
port: 80,
targetType: elbv2.TargetType.Ip
});

// THEN
expect(stack).to(haveResource('AWS::ElasticLoadBalancingV2::TargetGroup', {
TargetType: 'ip'
}));

test.done();
},

'Can add target groups with and without conditions'(test: Test) {
// GIVEN
const stack = new cdk.Stack();
Expand Down

0 comments on commit b4293f2

Please sign in to comment.