in src/main/java/com/ecs/cicd/DeploymentGroupRequestCreator.java [37:76]
static Object createDeploymentGroupParam(EcsApplication ecsApplication,
Role serviceRole,
NetworkListener productionListener,
NetworkListener greenListener,
String blueTarget,
String targetGreen,
String clusterName,
String serviceName,
String deploymentGroupName) {
LoadBalancerInfo loadBalancerInfo = new LoadBalancerInfo()
.withTargetGroupPairInfoList(new TargetGroupPairInfo()
.withProdTrafficRoute(new TrafficRoute()
.withListenerArns(productionListener.getListenerArn()))
.withTestTrafficRoute(new TrafficRoute()
.withListenerArns(greenListener.getListenerArn()))
.withTargetGroups(new TargetGroupInfo()
.withName(blueTarget),
new TargetGroupInfo()
.withName(targetGreen)));
CreateDeploymentGroupRequest deploymentGroup = new CreateDeploymentGroupRequest().withApplicationName(ecsApplication.getApplicationName())
.withDeploymentGroupName(deploymentGroupName)
.withServiceRoleArn(serviceRole.getRoleArn())
.withDeploymentStyle(new DeploymentStyle()
.withDeploymentOption(DeploymentOption.WITH_TRAFFIC_CONTROL)
.withDeploymentType(DeploymentType.BLUE_GREEN))
.withBlueGreenDeploymentConfiguration(new BlueGreenDeploymentConfiguration()
.withTerminateBlueInstancesOnDeploymentSuccess(new BlueInstanceTerminationOption()
.withAction(InstanceAction.TERMINATE)
.withTerminationWaitTimeInMinutes(5))
.withDeploymentReadyOption(new DeploymentReadyOption()
.withActionOnTimeout(DeploymentReadyAction.CONTINUE_DEPLOYMENT)))
.withEcsServices(new ECSService()
.withServiceName(serviceName)
.withClusterName(clusterName))
.withLoadBalancerInfo(loadBalancerInfo);
return MAPPER.convertValue(deploymentGroup, Map.class);
}