feat(codedeploy): loadbalancer support for imported Target Groups#17848
feat(codedeploy): loadbalancer support for imported Target Groups#17848mergify[bot] merged 13 commits intoaws:masterfrom
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.
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.
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
targetGroupNameproperty 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.
OK, I agree your proposal.👌
I will update soon with this approach.
Pull request has been modified.
| * ARN of the target group | ||
| */ | ||
| readonly targetGroupArn: string; | ||
|
|
There was a problem hiding this comment.
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.
Missing empty line after this line.
| /** | ||
| * The name of the target group | ||
| * | ||
| * @default targetGroupName |
There was a problem hiding this comment.
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.
This code added while my test.
I removed this.
| * ARN of the target group | ||
| */ | ||
| public readonly targetGroupArn: string; | ||
|
|
There was a problem hiding this comment.
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.
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.
| expect(stack).toHaveResource('AWS::CodeDeploy::DeploymentGroup', { | |
| expect(stack).toHaveResourceLike('AWS::CodeDeploy::DeploymentGroup', { |
| 'DeploymentStyle': { | ||
| 'DeploymentOption': 'WITH_TRAFFIC_CONTROL', | ||
| }, | ||
| }); |
There was a problem hiding this comment.
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.
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
|
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