【问题标题】:Pulumi: How to configure ECS service for a CODE_DEPLOY controllerPulumi:如何为 CODE_DEPLOY 控制器配置 ECS 服务
【发布时间】:2020-02-06 18:49:11
【问题描述】:

在尝试设置蓝/绿部署时,我遇到了以下问题:

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

到目前为止,我尝试使用自定义设置创建 aws.ecs.Cluster 并将其传递给 awsx.ecs.Cluster 但输入不正确:

const myCluster = new aws.ecs.Cluster('myCluster', {
    settings: {

    }
})

结束:

Type '{}' is not assignable to type 'Input<ClusterSetting>[] | Promise<Input<ClusterSetting>[]> | OutputInstance<Input<ClusterSetting>[]> | undefined'.

我无法在任何地方找到 ClusterSetting 类型。

如何为自定义 aws.ecs.Cluster 设置 ServiceDeploymentController 类型?

【问题讨论】:

    标签: amazon-web-services amazon-ecs pulumi


    【解决方案1】:

    我遇到了这个问题,并亲自这样解决了它。基本上不得不对 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
              }
            ]
          }
        }
      }
    );
    
    

    【讨论】:

      猜你喜欢
      • 2019-10-24
      • 1970-01-01
      • 1970-01-01
      • 2020-06-18
      • 2018-10-13
      • 2018-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多