簡體   English   中英

Pulumi:如何為 CODE_DEPLOY controller 配置 ECS 服務

[英]Pulumi: How to configure ECS service for a CODE_DEPLOY controller

在嘗試設置藍/綠部署時,我遇到了以下問題:

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 類型?

我遇到了這個問題並親自解決了它。 基本上不得不對 Typescript 撒謊以使類型對齊,以便我可以將正確的部署 controller 設置傳遞給 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
          }
        ]
      }
    }
  }
);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM