Skip to content

aws ecs deploy: --cluster "" (empty string) is not treated as unspecified, unlike omitting --cluster #10556

Description

@Adityaj0

Describe the bug

ECSClient.get_service_details(), used by aws ecs deploy, has a broken conditional for defaulting the --cluster value:

def get_service_details(self):
    cluster = self._args.cluster

    if cluster is None or '':
        cluster = 'default'

Due to Python operator precedence, this parses as if (cluster is None) or (''):. The empty string literal '' is always falsy, so it contributes nothing to the condition — the or '' is dead code. The check is silently equivalent to just if cluster is None:.

The command's own help text for --cluster says:

If you do not specify a cluster, the "default" cluster is assumed.

That's true when --cluster is omitted entirely (argparse leaves it as None). But if a caller passes --cluster "" — for example a CI/CD pipeline doing aws ecs deploy --cluster "$CLUSTER_NAME" ... where $CLUSTER_NAME is unset or empty — cluster is an empty string, not None, so the fallback to "default" is skipped and the empty string is sent straight through to DescribeServices.

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

--cluster "" should be treated the same as omitting --cluster, and fall back to the "default" cluster, matching the documented behavior.

Current Behavior

describe_services is called with cluster='' instead of cluster='default', which does not match the documented "default cluster is assumed" fallback and will fail cluster/service resolution against the ECS API instead of deploying to the default cluster.

Demonstrated directly against ECSClient.get_service_details():

>>> client._args.cluster = ''
>>> client.get_service_details()
# describe_services is invoked with cluster='' instead of cluster='default'

Reproduction Steps

$ CLUSTER_NAME=
$ aws ecs deploy --service my-service --cluster "$CLUSTER_NAME" \
    --task-definition file://task-def.json \
    --codedeploy-appspec file://appspec.yaml

Because $CLUSTER_NAME is empty, this passes --cluster "", and the command does not fall back to the default cluster the way omitting --cluster entirely would.

Possible Solution

Replace the broken condition with if not cluster:, which correctly treats both None and '' as "not specified" and falls back to 'default' in both cases. I have a PR ready with the fix and regression tests (there was previously no test coverage at all for the cluster-defaulting behavior in get_service_details).

CLI version used

aws-cli/2.36.23 (reproduced on v2 at 4c331fc)

Environment details (OS name and version, etc.)

macOS 15 (Darwin 25.2.0), Python 3.12 — not OS-specific, this is a pure logic bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions