kayac / ecspresso

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

FeatureRequest: Support `--ignore` option #726

Open ponkio-o opened 1 month ago

ponkio-o commented 1 month ago

Hi @fujiwara, Thank you for developing a great tool!

Summary

I want ignore option when run ecspresso deploy command. Like lambroll deploy --ignore (https://github.com/fujiwara/lambroll/pull/281)

Why need it?

In our case, use AWS tags to manage cost and almost case these are managed in Terraform repository. On the other hands, ECS Service and ECS TaskDefinition are managed in application repository. Therefore, tags for cost management should be managed by Terraform using aws_ecs_tag or similar and ignored by ecspresso.

fujiwara commented 1 month ago

@ponkio-o Thank you for the request!

Unlike lambroll, ecspresso deploy (and diff) manipulates two elements: the service and the task definition. ECS's definitions are more complex than those of Lambda functions. Because those two definitions have different structures, an --ignore flag is needed for each.

If the ignore flag enables it to affect ANY service and task definition elements, it seems to add too much complexity. For example, the jq query for deleting the tag element that has a specified name is here.

.tags |= map(select(.key != "foo"))'

But if you only want to ignore some tags, for example, adding --ignore-tags may be sufficient. This is clear to use.

What do you think about this?

ponkio-o commented 1 month ago

@fujiwara Thank you for reply quickly!!

In our case, we want to ignore only tags field in service-def.json. In other words, other fields don't need ignore and these are managed by ecspresso. Therefore, --ignore-tags option satisfied for our use case.

ponkio-o commented 1 month ago

By the way, we want to avoid managing tags for ECS Service across Terraform and ecspresso. Because cost allocation tags are need for other AWS resources managed by Terraform.

fujiwara commented 1 month ago

It may be better to add a configuration item than a flag because that is common setting to the ECS service, and affects multiple subcommands, deploy, diff, and init.

It is easy to expand more elements to ignore not only tags in the future.

# ecspresso.yml
ignore:
  tags:
    - foo
    - bar
fujiwara commented 1 month ago

@ponkio-o I'm working on #728. How do you feel about this?

ponkio-o commented 1 month ago

@fujiwara Thank you for working this! I looked very good implementation.

ponkio-o commented 1 month ago

@fujiwara I verified working correctly this feature using v2.4.0-rc0 on our environment. Thank you for resolving issue! I'm waiting for release the v2.4.0.