Skip to content
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(elasticloadbalancingv2): add grpc code matcher for alb #13948

Merged
merged 2 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/@aws-cdk/aws-elasticloadbalancingv2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ const tg = new elbv2.ApplicationTargetGroup(stack, 'TG', {
port: 50051,
protocol: elbv2.ApplicationProtocol.HTTP,
protocolVersion: elbv2.ApplicationProtocolVersion.GRPC,
healthCheck: {
enabled: true,
healthyGrpcCodes: '0-99',
},
vpc,
});
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,16 @@ export interface HealthCheck {
*/
readonly unhealthyThresholdCount?: number;

/**
* GRPC code to use when checking for a successful response from a target.
*
* You can specify values between 0 and 99. You can specify multiple values
* (for example, "0,1") or a range of values (for example, "0-5").
*
* @default - 12
*/
readonly healthyGrpcCodes?: string;

/**
* HTTP code to use when checking for a successful response from a target.
*
Expand Down Expand Up @@ -259,7 +269,8 @@ export abstract class TargetGroupBase extends CoreConstruct implements ITargetGr
healthyThresholdCount: cdk.Lazy.number({ produce: () => this.healthCheck?.healthyThresholdCount }),
unhealthyThresholdCount: cdk.Lazy.number({ produce: () => this.healthCheck?.unhealthyThresholdCount }),
matcher: cdk.Lazy.any({
produce: () => this.healthCheck?.healthyHttpCodes !== undefined ? {
produce: () => this.healthCheck?.healthyHttpCodes !== undefined || this.healthCheck?.healthyGrpcCodes !== undefined ? {
grpcCode: this.healthCheck.healthyGrpcCodes,
httpCode: this.healthCheck.healthyHttpCodes,
} : undefined,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,29 @@ describe('tests', () => {
new elbv2.ApplicationTargetGroup(stack, 'TargetGroup', {
vpc,
protocolVersion: elbv2.ApplicationProtocolVersion.GRPC,
healthCheck: {
enabled: true,
healthyGrpcCodes: '0-99',
interval: cdk.Duration.seconds(255),
timeout: cdk.Duration.seconds(192),
healthyThresholdCount: 29,
unhealthyThresholdCount: 27,
path: '/arbitrary',
},
});

// THEN
expect(stack).toHaveResource('AWS::ElasticLoadBalancingV2::TargetGroup', {
ProtocolVersion: 'GRPC',
HealthCheckEnabled: true,
HealthCheckIntervalSeconds: 255,
HealthCheckPath: '/arbitrary',
HealthCheckTimeoutSeconds: 192,
HealthyThresholdCount: 29,
Matcher: {
GrpcCode: '0-99',
},
UnhealthyThresholdCount: 27,
});
});

Expand Down