kayac / ecspresso

ecspresso is a deployment tool for Amazon ECS
MIT License
826 stars 90 forks source link

Diff behavior when a service is defined, but service_definition is not defined #771

Open tomoyasuzuki opened 4 days ago

tomoyasuzuki commented 4 days ago

Problem statement

I am using v2.3.5 and get the following error when using the ecspresso diff command.

2024/11/11 17:29:22 [INFO] ecspresso version: v2.3.5
2024/11/11 17:29:22 [ERROR] FAILED. failed to load service definition: service_definition is not defined

How to reproduce

  1. Install ecspresso
  2. Create dummy config file like this.
  3. run ecspresso diff --config test.yaml
region: ap-northeast-1
cluster: dev
service: test
task_definition: task-def.json

What is a problem ?

The diff command currently only checks the service in the config file, but there are cases where the service is defined without a service_definition (for instance, when configurations possible with service_definition are managed via Terraform). Since the diff command requires service_definition to compare service settings, I think it should also check if service_definition is not empty.

If community members agree to this change, I will create a PR.

current implementation

if d.config.Service != "" {

Ideal implementation

if d.config.Service != "" && d.config.ServiceDefinitionPath != "" {
fujiwara commented 3 days ago

@tomoyasuzuki That is by design.

When the service is defined in the config, ecspresso manages the ECS service. So ecspresso requires service_definition.

Remove the service from the config file to manage task definitions only (without ECS service).