Skip to content

Commit

Permalink
Add ELB Classic as a CodeDeploy load balancer.
Browse files Browse the repository at this point in the history
  • Loading branch information
skinny85 committed Sep 26, 2018
1 parent 4e4e01c commit 745a81f
Show file tree
Hide file tree
Showing 6 changed files with 879 additions and 1 deletion.
29 changes: 29 additions & 0 deletions packages/@aws-cdk/aws-codedeploy/lib/deployment-group.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import autoscaling = require("@aws-cdk/aws-autoscaling");
import codedeploylb = require("@aws-cdk/aws-codedeploy-api");
import ec2 = require("@aws-cdk/aws-ec2");
import s3 = require("@aws-cdk/aws-s3");
import cdk = require("@aws-cdk/cdk");
Expand Down Expand Up @@ -143,6 +144,15 @@ export interface ServerDeploymentGroupProps {
* @see https://docs.aws.amazon.com/codedeploy/latest/userguide/codedeploy-agent-operations-install.html
*/
installAgent?: boolean;

/**
* The load balancer to place in front of this Deployment Group.
* Can be either a classic Elastic Load Balancer,
* or an Application Load Balancer / Network Load Balancer Target Group.
*
* @default the Deployment Group will not have a load balancer defined
*/
loadBalancer?: codedeploylb.LoadBalancerProvider;
}

/**
Expand Down Expand Up @@ -188,6 +198,7 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupRef {
this._autoScalingGroups.length === 0
? undefined
: this._autoScalingGroups.map(asg => asg.autoScalingGroupName())),
loadBalancerInfo: this.loadBalancerInfo(props.loadBalancer),
});

this.deploymentGroupName = resource.deploymentGroupName;
Expand Down Expand Up @@ -244,6 +255,24 @@ export class ServerDeploymentGroup extends ServerDeploymentGroupRef {
break;
}
}

private loadBalancerInfo(lbProvider?: codedeploylb.LoadBalancerProvider):
cloudformation.DeploymentGroupResource.LoadBalancerInfoProperty | undefined {
if (!lbProvider) {
return undefined;
}

switch (lbProvider.codeDeployLoadBalancerGeneration()) {
case codedeploylb.LoadBalancerGeneration.FIRST:
return {
elbInfoList: [
{ name : lbProvider.codeDeployLoadBalancerName() },
],
};
case codedeploylb.LoadBalancerGeneration.SECOND:
throw new Error('not implemented yet');
}
}
}

function deploymentGroupName2Arn(applicationName: string, deploymentGroupName: string): string {
Expand Down
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-codedeploy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,15 @@
"devDependencies": {
"@aws-cdk/assert": "^0.9.2",
"@aws-cdk/aws-ec2": "^0.9.2",
"@aws-cdk/aws-elasticloadbalancing": "^0.9.2",
"cdk-build-tools": "^0.9.2",
"cdk-integ-tools": "^0.9.2",
"cfn2ts": "^0.9.2",
"pkglint": "^0.9.2"
},
"dependencies": {
"@aws-cdk/aws-autoscaling": "^0.9.2",
"@aws-cdk/aws-codedeploy-api": "^0.9.2",
"@aws-cdk/aws-codepipeline-api": "^0.9.2",
"@aws-cdk/aws-s3": "^0.9.2",
"@aws-cdk/cdk": "^0.9.2"
Expand Down
Loading

0 comments on commit 745a81f

Please sign in to comment.