我遇到了这个问题并亲自解决了它。基本上不得不对 Typescript 撒谎以使类型对齐,以便我可以将正确的部署控制器设置传递给 Fargate 服务:
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
}
]
}
}
}
);