-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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): loadbalancer support for imported Target Groups #17848
Conversation
Title does not follow the guidelines of Conventional Commits. Please adjust title before merge. |
…ported alb and nlb
Move `parameterGroup` from `DatabaseInstanceSourceProps` to `DatabaseInstanceNewProps` since the parameter group of a replica instance can be customized. Closes aws#17580 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…Nine/aws-cdk into fix-codedeploy-loadbalancer
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 for the contribution @eastNine! I think we should go a slightly different route than what you proposed here.
Let me know if you agree with my proposal!
Thanks,
Adam
'Ref': 'NLBListenerFleetGroupB882EC86', | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}, |
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.
We're missing a unit test for using LoadBalancer
with imported Target Groups here 🙂.
class AlbLoadBalancer extends LoadBalancer { | ||
public readonly generation = LoadBalancerGeneration.SECOND; | ||
public readonly name = albTargetGroup.targetGroupName; | ||
public readonly name = targetGruopNameFromArn(albTargetGroup.targetGroupArn); |
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.
I don't particularly like this solution. I actually think this is putting the logic of how to get the name of the Target Group from its ARN in the wrong place.
Let's do this a little bit differently:
- Let's add a
targetGroupName
property toITargetGroup
. - In imported Target Groups, let's add the logic of parsing it from the ARN of the Target Group.
- Let's keep using
public readonly name = albTargetGroup.targetGroupName;
here, but now, this will Just Work.
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.
OK, I agree your proposal.👌
I will update soon with this approach.
Pull request has been modified.
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.
Looks good @eastNine, but we need a few changes before we merge this in.
@@ -350,7 +350,12 @@ export interface TargetGroupAttributes { | |||
* ARN of the target group | |||
*/ | |||
readonly targetGroupArn: string; | |||
|
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.
Let's keep this empty line (there should be an empty line separating the properties).
* | ||
* @default targetGroupName | ||
*/ | ||
readonly targetGroupName?: string; |
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.
Missing empty line after this line.
/** | ||
* The name of the target group | ||
* | ||
* @default targetGroupName |
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.
Why are we adding this property here? targetGroupArn
is already required, so what does providing an optional targetGroupName
accomplish? I also don't see you using this property anywhere.
I think we should remove this.
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.
This code added while my test.
I removed this.
@@ -14,7 +15,10 @@ export abstract class ImportedTargetGroupBase extends CoreConstruct implements I | |||
* ARN of the target group | |||
*/ | |||
public readonly targetGroupArn: string; | |||
|
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.
Same comment here (there should be an empty line separating the fields).
* Return the targetGroupName from targetGroupArn | ||
*/ | ||
export function targetGroupNameFromArn(targetGroupArn: string) { | ||
const arnParts = Fn.split('/', targetGroupArn); |
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.
We have a function in the core
Stack for this already: Stack.splitArn()
. See how it's used here, for example.
), | ||
}); | ||
|
||
expect(stack).toHaveResource('AWS::CodeDeploy::DeploymentGroup', { |
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.
expect(stack).toHaveResource('AWS::CodeDeploy::DeploymentGroup', { | |
expect(stack).toHaveResourceLike('AWS::CodeDeploy::DeploymentGroup', { |
'DeploymentStyle': { | ||
'DeploymentOption': 'WITH_TRAFFIC_CONTROL', | ||
}, | ||
}); |
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.
I don't think this is relevant to this test, let's just remove this.
'DeploymentStyle': { | ||
'DeploymentOption': 'WITH_TRAFFIC_CONTROL', | ||
}, |
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.
I don't think this is relevant to this test, let's just remove this.
packages/@aws-cdk/aws-elasticloadbalancingv2/test/alb/target-group.test.ts
Show resolved
Hide resolved
packages/@aws-cdk/aws-elasticloadbalancingv2/test/nlb/target-group.test.ts
Show resolved
Hide resolved
@eastNine make sure to re-request my review (there's a button in the top-right of the PR window, next to my avatar) once you're ready for another round of reviews - this way, I won't miss another iteration when it's ready. Thanks! |
Pull request has been modified.
@skinny85
I tried above, I think we can't use return value of Reference aws-properties-codedeploy-deploymentgroup-targetgroupinfo So I added one more split. |
c15e59c
to
e3823b6
Compare
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.
Looks great @eastNine, thanks so much for the contribution!
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
…s#17848) This PR fixes that imported alb and nlb target group be able to configure to loadBalancer property. Fixes aws#9677. example: ```TypeScript import * as cdk from '@aws-cdk/core'; import * as codedeploy from '@aws-cdk/aws-codedeploy'; import * as elbv2 from '@aws-cdk/aws-elasticloadbalancingv2'; const deploymentGroup = new codedeploy.ServerDeploymentGroup(this, 'deploymentGroup', { ... // configurable imported application loadbalancer targetgroup loadBalancer: codedeploy.LoadBalancer.application( elbv2.ApplicationTargetGroup.fromTargetGroupAttributes(this, 'importedAlbTg', { targetGroupArn: 'arn:aws:elasticloadbalancing:ap-northeast-2:111111111111:targetgroup/myAlbTargetgroup/abcd12345678efgf' }) ), // also network loadbalancer targetgroup loadBalancer: codedeploy.LoadBalancer.network( elbv2.NetworkTargetGroup.fromTargetGroupAttributes(this, 'importedNlbTg', { targetGroupArn: 'arn:aws:elasticloadbalancing:ap-northeast-2:111111111111:targetgroup/myNlbTargetgroup/wxyz09876543opqr' }) ), }); ``` ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
This PR fixes that imported alb and nlb target group be able to configure to loadBalancer property.
Fixes #9677.
example:
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license