-
Notifications
You must be signed in to change notification settings - Fork 4k
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(codedeploy): supporting the creation of deployment groups with multiple load balancers #27474
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks correct, anyway, some changes are needed in my opinion.
Also:
- Can you update the title to specify the module? (eg
feat(codedeploy) ...
) (see guidelines) - Can you update the description of the PR and remove the duplicate reference to the target issue?
Thanks 💪
packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts
Outdated
Show resolved
Hide resolved
packages/aws-cdk-lib/aws-codedeploy/test/server/deployment-group.test.ts
Outdated
Show resolved
Hide resolved
packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts
Outdated
Show resolved
Hide resolved
@@ -22,10 +23,29 @@ elb.addListener({ | |||
externalPort: 80, | |||
}); | |||
|
|||
const alb = new lb2.ApplicationLoadBalancer(stack, 'ALB', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A separate integration test should be added for the new attribute.
packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts
Outdated
Show resolved
Hide resolved
packages/aws-cdk-lib/aws-codedeploy/lib/server/deployment-group.ts
Outdated
Show resolved
Hide resolved
…p.ts Co-authored-by: Luca Pizzini <[email protected]>
Co-authored-by: Luca Pizzini <[email protected]>
Co-authored-by: Luca Pizzini <[email protected]>
Co-authored-by: Luca Pizzini <[email protected]>
…up.test.ts Co-authored-by: Luca Pizzini <[email protected]>
…up.test.ts Co-authored-by: Luca Pizzini <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Just some minor adjustments and a missing test case to be added.
Also, the integration test is failing because it seems that you have not executed it.
You should:
- Rollback changes to the snapshots of
integ.deployment-group
- Execute
integ.deployment-group-multiple-load-balancers
locally (see guidelines) - Push the generated snapshots
@@ -168,9 +168,19 @@ export interface ServerDeploymentGroupProps { | |||
* or an Application Load Balancer / Network Load Balancer Target Group. | |||
* | |||
* @default - Deployment Group will not have a load balancer defined. | |||
* @deprecated - Deprecated in favor of loadBalancers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @deprecated - Deprecated in favor of loadBalancers. | |
* @deprecated - Use `loadBalancers` instead. |
More concise
this.loadBalancers = props.loadBalancers || (props.loadBalancer ? [props.loadBalancer]: undefined); | ||
|
||
if (this.loadBalancers && this.loadBalancers.length === 0) { | ||
throw new Error('Cannot set empty loadBalancers array'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throw new Error('Cannot set empty loadBalancers array'); | |
throw new Error('loadBalancers must be a non-empty array'); |
Formatting. Also, a unit test needs to be added to verify that the error is thrown if loadBalancers: []
.
], | ||
}; | ||
} | ||
return loadBalancers.reduce((accumulator : { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return loadBalancers.reduce((accumulator : { | |
return loadBalancers?.reduce((accumulator : { |
After if
statement removal.
|
||
if (!loadBalancers) { | ||
return undefined; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!loadBalancers) { | |
return undefined; | |
} |
Unnecessary.
@@ -212,6 +213,70 @@ describe('CodeDeploy Server Deployment Group', () => { | |||
}); | |||
}); | |||
|
|||
test('can be created with multiple ALB Target Groups as the load balancers', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test('can be created with multiple ALB Target Groups as the load balancers', () => { | |
test('can be created with multiple Target Groups as the load balancers', () => { |
You can specify also CLBs and NLBs.
@@ -150,6 +150,29 @@ const deploymentGroup = new codedeploy.ServerDeploymentGroup(this, 'DeploymentGr | |||
}); | |||
``` | |||
|
|||
To provide multiple Elastic Load Balancers as target groups use the `loadBalancers` parameter: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To provide multiple Elastic Load Balancers as target groups use the `loadBalancers` parameter: | |
The `loadBalancer` property has been deprecated. To provide multiple Elastic Load Balancers | |
as target groups use the `loadBalancers` parameter: |
Note about deprecation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The build is still failing but I note now that you opened the PR from your main
branch.
Merge requests opened from the main
branch cannot be merged.
You should close this PR and open a new one from a separate branch.
Thanks 💪
test.each<{ clbCount: number, albCount: number, nlbCount: number, TargetGroupInfoList: string[], ElbInfoList: string[] }>([ | ||
{ clbCount: 0, albCount: 0, nlbCount: 1, TargetGroupInfoList: ['NLBListenerNLB0FleetGroup657E42E4'], ElbInfoList: [] }, | ||
{ clbCount: 0, albCount: 0, nlbCount: 2, TargetGroupInfoList: ['NLBListenerNLB0FleetGroup657E42E4', 'NLBListenerNLB1FleetGroup5298209F'], ElbInfoList: [] }, | ||
{ clbCount: 0, albCount: 1, nlbCount: 0, TargetGroupInfoList: ['ALBListenerALB0FleetGroupF4CBAA91'], ElbInfoList: [] }, | ||
{ clbCount: 0, albCount: 2, nlbCount: 0, TargetGroupInfoList: ['ALBListenerALB0FleetGroupF4CBAA91', 'ALBListenerALB1FleetGroupD8E824C3'], ElbInfoList: [] }, | ||
{ clbCount: 0, albCount: 1, nlbCount: 1, TargetGroupInfoList: ['ALBListenerALB0FleetGroupF4CBAA91', 'NLBListenerNLB0FleetGroup657E42E4'], ElbInfoList: [] }, | ||
{ clbCount: 0, albCount: 2, nlbCount: 2, TargetGroupInfoList: ['ALBListenerALB0FleetGroupF4CBAA91', 'ALBListenerALB1FleetGroupD8E824C3', 'NLBListenerNLB0FleetGroup657E42E4', 'NLBListenerNLB1FleetGroup5298209F'], ElbInfoList: [] }, | ||
{ clbCount: 1, albCount: 0, nlbCount: 0, TargetGroupInfoList: [], ElbInfoList: ['CLB0677386E0'] }, | ||
{ clbCount: 2, albCount: 0, nlbCount: 0, TargetGroupInfoList: [], ElbInfoList: ['CLB0677386E0', 'CLB18DCC2BD6'] }, | ||
{ clbCount: 1, albCount: 0, nlbCount: 1, TargetGroupInfoList: ['NLBListenerNLB0FleetGroup657E42E4'], ElbInfoList: ['CLB0677386E0'] }, | ||
{ clbCount: 2, albCount: 0, nlbCount: 2, TargetGroupInfoList: ['NLBListenerNLB0FleetGroup657E42E4', 'NLBListenerNLB1FleetGroup5298209F'], ElbInfoList: ['CLB0677386E0', 'CLB18DCC2BD6'] }, | ||
{ clbCount: 1, albCount: 1, nlbCount: 0, TargetGroupInfoList: ['ALBListenerALB0FleetGroupF4CBAA91'], ElbInfoList: ['CLB0677386E0'] }, | ||
{ clbCount: 2, albCount: 2, nlbCount: 0, TargetGroupInfoList: ['ALBListenerALB0FleetGroupF4CBAA91', 'ALBListenerALB1FleetGroupD8E824C3'], ElbInfoList: ['CLB0677386E0', 'CLB18DCC2BD6'] }, | ||
{ clbCount: 1, albCount: 1, nlbCount: 1, TargetGroupInfoList: ['ALBListenerALB0FleetGroupF4CBAA91', 'NLBListenerNLB0FleetGroup657E42E4'], ElbInfoList: ['CLB0677386E0'] }, | ||
{ clbCount: 2, albCount: 2, nlbCount: 2, TargetGroupInfoList: ['ALBListenerALB0FleetGroupF4CBAA91', 'ALBListenerALB1FleetGroupD8E824C3', 'NLBListenerNLB0FleetGroup657E42E4', 'NLBListenerNLB1FleetGroup5298209F'], ElbInfoList: ['CLB0677386E0', 'CLB18DCC2BD6'] }, | ||
])('Should build ServerDeploymentGroup with $clbCount CLBs, $albCount ALBs and $nlbCount NLBs expecting TargetGroupInfoList $TargetGroupInfoList and ElbInfoList $ElbInfoList', ({ clbCount, albCount, nlbCount, TargetGroupInfoList, ElbInfoList }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test added below already gives test coverage for the new feature.
What's the benefit of checking for all potential combinations of ELBs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanted to make sure as many test cases were covered as possible in case I might of missed a corner case.
Moving the PR here |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Summary
This change adds multiple load balancer support for CodeDeploy deployment groups.
There is a currently a
loadBalancer
field in theServerDeploymentGroup
, addingloadBalancers
might be a good field to extend the functionality to create a deployment group with multiple load balancers.Closes #27407
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license