While trying to set up a blue/green deployment I hit the following issue:
error: Plan apply failed: Error creating CodeDeploy deployment group: InvalidECSServiceException: Deployment group's ECS service must be configured for a CODE_DEPLOY deployment controller.
status code: 400, request id: b9314f00-ef3e-467e-a7b0-a3bd87600484
So far I tried to create aws.ecs.Cluster
with custom settings and pass it to awsx.ecs.Cluster
but the typing is not right:
const myCluster = new aws.ecs.Cluster('myCluster', {
settings: {
}
})
ends up with:
Type '{}' is not assignable to type 'Input<ClusterSetting>[] | Promise<Input<ClusterSetting>[]> | OutputInstance<Input<ClusterSetting>[]> | undefined'.
and I am unable to find ClusterSetting type anywhere.
How do I set up ServiceDeploymentController type for a custom aws.ecs.Cluster
?
I ran into this issue and personally solved it like this. Basically had to lie to Typescript a little bit to make the types line up so that I could pass the correct deployment controller setting to the Fargate Service:
const serviceArgs: FargateServiceArgs = {
cluster,
waitForSteadyState: false,
taskDefinitionArgs: {
cpu: "512",
memory: "1024",
containers: {
nginx: {
image: "nginx",
portMappings: [blueListener]
}
}
},
desiredCount: 1
};
const deploymentContollerArgs = {
deploymentController: {
type: "CODE_DEPLOY"
}
};
// TODO: This is here because @pulumi/awsx doesn't expose a nice way to set the deployment controller.
const combinedArgs: FargateServiceArgs = {
...serviceArgs,
...deploymentContollerArgs
};
export const laravelWebAppService = new awsx.ecs.FargateService(
stackNamed("larvel-webapp-service"),
{
...combinedArgs
}
);
export const codeDeployGroup = new aws.codedeploy.DeploymentGroup(
stackNamed("code-deploy-group"),
{
appName: codeDeployApplication.name,
serviceRoleArn: role.arn,
deploymentGroupName: stackNamed("code-deploy-group"),
deploymentConfigName: "CodeDeployDefault.ECSAllAtOnce",
deploymentStyle: {
deploymentType: "BLUE_GREEN",
deploymentOption: "WITH_TRAFFIC_CONTROL"
},
blueGreenDeploymentConfig: {
deploymentReadyOption: {
actionOnTimeout: "CONTINUE_DEPLOYMENT"
},
terminateBlueInstancesOnDeploymentSuccess: {
action: "TERMINATE",
terminationWaitTimeInMinutes: 1
}
},
ecsService: {
clusterName: cluster.cluster.name,
serviceName: laravelWebAppService.service.name
},
loadBalancerInfo: {
targetGroupPairInfo: {
prodTrafficRoute: {
listenerArns: [blueListener.listener.arn]
},
testTrafficRoute: {
listenerArns: [greenListener.listener.arn]
},
targetGroups: [
{
name: blueTargetGroup.targetGroup.name
},
{
name: greenTargetGroup.targetGroup.name
}
]
}
}
}
);