fernandocarletti / capistrano-aws

Integrates Capistrano with AWS EC2.
MIT License
16 stars 6 forks source link

Allow default filters to be overridden #12

Closed kernow closed 4 years ago

kernow commented 4 years ago

@fernandocarletti I figured it might be easier to talk in code than discuss options as it's pretty simple code anyway 😀

This is an example of what I was originally thinking which would send the Application filter if it's set, or not send it at all if it's undefined.

kernow commented 4 years ago

So I've added a aws_ec2_skip_defaults option that could be used in combination. So a deploy.rb containing set :aws_ec2_skip_defaults, true would work as I was describing.

kernow commented 4 years ago

The aws_ec2_skip_defaults option might also be good for anyone that doesn't want to be affected by new defaults that may be added in new versions of the gem.

kernow commented 4 years ago

@fernandocarletti I've pushed up a WIP of the change, which is working for me.

At this point there is the possibility of making aws_ec2_application, aws_ec2_application_tag, aws_ec2_stage and aws_ec2_stage_tag redundant as we could change things so that overriding aws_ec2_default_filters is the way to change these from default. So aws_ec2_default_filters could then become:

set :aws_ec2_default_filters, (proc {
  [
    {
      name: "tag:Application",
      values: [fetch(:application)]
    },
    {
      name: "tag:Stage",
      values: [fetch(:stage)]
    },
    {
      name: 'instance-state-name',
      values: ['running']
    }
  ]
})

What are your thoughts on this? Once we decide which way to go I'll update the README with related info.

fernandocarletti commented 4 years ago

Sorry for the late reply. There was a reason to not use application and stage directly. I think it comes from Capistrano 2, before it got its multistage feature. Also, I think I tried to make it similar to cap-ec2.

That could be nice for a future version, but to be honest, I have not been using this library as I'm mainly using docker and Kubernetes at work and Heroku for personal projects. If you want to implement a new version with some improvements I would be glad to merge the PRs though.