You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Pulumi配置ECS服务CODE_DEPLOY控制器及集群设置问题解决

Fixing ECS Blue-Green Deployment Issues with Pulumi

Let's work through your two connected problems one by one:

1. Resolving the CodeDeploy Deployment Group Error

The error InvalidECSServiceException: Deployment group's ECS service must be configured for a CODE_DEPLOY deployment controller pops up because your ECS Service is using the default ECS deployment controller, but CodeDeploy requires the service to use CODE_DEPLOY instead.

To fix this, explicitly set the deploymentController property when defining your ECS Service — whether you're using the raw aws.ecs.Service or the higher-level awsx.ecs.Service:

// Example with raw aws.ecs.Service
const ecsService = new aws.ecs.Service("myEcsService", {
  // ... other required properties (cluster, taskDefinition, desiredCount, etc.)
  deploymentController: {
    type: "CODE_DEPLOY", // This line is critical for CodeDeploy integration
  },
});

// If using awsx.ecs.Service, pass it via serviceOptions
const awsxService = new awsx.ecs.Service("myAwsxService", {
  cluster: myCluster,
  taskDefinition: myTaskDef,
  serviceOptions: {
    deploymentController: {
      type: "CODE_DEPLOY",
    },
  },
});

Once your service uses the CODE_DEPLOY controller, creating the CodeDeploy deployment group should work without the 400 error.

2. Fixing the Cluster Setting Type Error

The type error when creating aws.ecs.Cluster happens because the settings field expects an array of ClusterSetting objects, not an empty object {}. Each ClusterSetting requires a name and value pair (common use cases include enabling Container Insights or configuring Service Connect defaults).

If you don't need any cluster-specific settings, you can just omit the settings parameter entirely. If you do need to set them, here's the correct syntax:

// Correct way to define cluster settings (if needed)
const myCluster = new aws.ecs.Cluster("myCluster", {
  settings: [
    {
      name: "containerInsights",
      value: "enabled",
    },
  ],
});

Using a Custom Cluster with awsx.ecs.Cluster

To use your custom aws.ecs.Cluster instance with awsx.ecs.Cluster, simply pass it via the cluster property — the awsx wrapper can work with existing raw cluster objects:

// Your custom raw ECS cluster
const rawCluster = new aws.ecs.Cluster("rawCluster", {
  settings: [
    { name: "containerInsights", value: "enabled" },
  ],
});

// Wrap it with awsx.ecs.Cluster for higher-level operations
const awsxCluster = new aws.ecs.Cluster("awsxCluster", {
  cluster: rawCluster,
});

Key Reminder

Don't confuse cluster settings with service deployment settings: the CODE_DEPLOY deployment controller is configured on the ECS Service, not the Cluster itself. Cluster settings are for cluster-wide features, not deployment behavior.

内容的提问来源于stack exchange,提问作者pbn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:14:22