floci-io/floci · error · AwsException

InvalidDeploymentConfigException

InvalidDeploymentConfigException

Error message

ECS deployment group must specify ecsServices

What it means

Thrown in createEcsDeployment (CodeDeployService.java:1214) when the deployment group's ecsServices list is null/empty or its first entry has no serviceName. The service reads clusterName (defaulting to 'default') and serviceName from group.getEcsServices().get(0); a null serviceName means the group cannot identify which ECS service to shift traffic for. Note the error code InvalidDeploymentConfigException is a questionable mapping — real AWS signals a malformed deployment group with ValidationException/InvalidDeploymentGroupException.

Source

Thrown at src/main/java/io/github/hectorvent/floci/services/codedeploy/CodeDeployService.java:1214

        deployment.setStatus("Queued");
        deployment.setRevision(revision);
        deployment.setCreateTime(now);
        deployment.setDescription(description);
        deployment.setCreator("user");
        deployment.setComputePlatform("ECS");
        deploymentsFor(region).put(deploymentId, deployment);

        // Determine ECS cluster/service from deployment group
        String clusterName = "default";
        String serviceName = null;
        List<Map<String, Object>> ecsSvcs = group.getEcsServices();
        if (ecsSvcs != null && !ecsSvcs.isEmpty()) {
            Map<String, Object> svc = ecsSvcs.get(0);
            clusterName = (String) svc.getOrDefault("clusterName", "default");
            serviceName = (String) svc.get("serviceName");
        }
        if (serviceName == null) {
            throw new AwsException("InvalidDeploymentConfigException",
                    "ECS deployment group must specify ecsServices", 400);
        }

        // Determine blue/green TG ARNs from loadBalancerInfo
        String blueTgArn = null;
        String greenTgArn = null;
        List<String> listenerArns = new ArrayList<>();
        Map<String, Object> lbInfo = group.getLoadBalancerInfo();
        if (lbInfo != null) {
            List<Map<String, Object>> pairList = (List<Map<String, Object>>) lbInfo.get("targetGroupPairInfoList");
            if (pairList != null && !pairList.isEmpty()) {
                Map<String, Object> pair = pairList.get(0);
                List<Map<String, Object>> tgList = (List<Map<String, Object>>) pair.get("targetGroups");
                if (tgList != null && tgList.size() >= 2) {
                    String blueName = (String) tgList.get(0).get("name");
                    String greenName = (String) tgList.get(1).get("name");
                    TargetGroup blueTg = elbV2Service.getTargetGroupByName(region, blueName);
                    TargetGroup greenTg = elbV2Service.getTargetGroupByName(region, greenName);

View on GitHub (pinned to 62ff490619)

Solutions

  1. Recreate/update the deployment group with ecsServices: [{clusterName: '...', serviceName: '...'}].
  2. Call GetDeploymentGroup first and verify ecsServices[0].serviceName is set before deploying.
  3. Floci maintainers: align the error code with AWS (ValidationException or InvalidDeploymentGroupException).

Example fix

// before
client.create_deployment_group(applicationName='app', deploymentGroupName='ecs-dg',
    computePlatform='ECS', serviceConfig=None)  # or omitted

// after
client.create_deployment_group(applicationName='app', deploymentGroupName='ecs-dg',
    computePlatform='ECS',
    serviceConfig={'ecsServices': [{'clusterName': 'prod', 'serviceName': 'web'}]})
Defensive patterns

Strategy: validation

Validate before calling

dg = client.get_deployment_group(applicationName=app,
                                  deploymentGroupName=name)['deploymentGroupInfo']
svcs = dg.get('ecsServices') or []
if not svcs or not svcs[0].get('serviceName'):
    raise RuntimeError(f'deployment group {name} lacks ecsServices with serviceName')
client.create_deployment(applicationName=app, deploymentGroupName=name,
                         revision=revision)

Try / catch

try:
    client.create_deployment(...)
except client.exceptions.InvalidDeploymentConfigException as e:
    if 'ecsServices' in str(e):
        raise RuntimeError('fix the deployment group: add ecsServices[{clusterName, serviceName}]') from e
    raise

Prevention

When it happens

Trigger: CreateDeployment targeting a deployment group created with computePlatform=ECS but without serviceConfig/ecsServices (e.g., created with only tag filters), or with ecsServices[0] missing the serviceName key.

Common situations: Creating the deployment group with an older SDK shape ('ecsServices' vs newer nested serviceConfig); Terraform/CloudFormation group definitions missing the ecsServices block; testing against a group scaffolded as EC2 then repurposed for ECS.

Related errors


AI-assisted analysis of floci-io/floci@62ff490619 (2026-08-14). Data as JSON: /api/errors/995f0d0a7e4d9d14. Report an issue: GitHub.