question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conditional action execution

See original GitHub issue

Is your feature request related to a problem? Please describe. I am looking for conditions on actions, plain and simple 😃 This helps me solve a problem around only taking certain actions in certain accounts. I.E. in a Dev environment, delete something vs in a Prod environment, isolate it and notify. Traditionally, these small differences have resulted in a multiplication of policy by type of environment with different actions sometimes winding up with having to write the same thing 4 - 5 times with a small difference on one of the actions. Something like this could help to keep it to just 1 albeit meta-policy in the future.

Describe the solution you’d like I’d like to add a conditions attribute to actions where I could check the account_id in a value_from and then decide if I’m in a prod environment or not. Another variation of this could be a timed action, i.e. do this thing until 8/8, then after 8/8 do this other thing. By checking the condition and executing the action if it evaluates to true, this enables some possibilities around dynamic policy interpretation that were not there before.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
IngussNeilandscommented, Mar 23, 2021

One more use case could be:

    filters:
      - or:
        - "tag:tag-v1": absent
        - "tag:tag-v2": absent
        - "tag:tag-v3": absent
    actions:
      - type: tag
        key: tag-v1
        value: "v1"
        conditions:
          - "tag:tag-v1": absent
      - type: tag
        key: tag-v2
        value: "v2"
        conditions:
          - "tag:tag-v2": absent
      - type: tag
        key: tag-v3
        value: "v3"
        conditions:
          - "tag:tag-v3": absent
2reactions
tjstansellcommented, Aug 13, 2020

This is why we use a jinja framework to build our c7n policies. Way more granularity/control than trying to build it all into the c7n policies directly 😃 but i know that’s not for everyone…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using conditions to control job execution - GitHub Docs
<job_id>.if conditional to prevent a job from running unless a condition is met. You can use any supported context and expression to create...
Read more >
6. Conditionally Executing Actions - Courses
Sequential execution means that the statements are executed one after another in the order that they appear in the source code. In this...
Read more >
GitHub Actions: Conditional execution of steps in actions
This lets you prevent specific steps from executing unless a condition has been met. Like steps defined in workflows, you can use any...
Read more >
1.3. Performing Actions Conditionally - Actionscript Cookbook ...
To execute an action under certain circumstances, use one of ActionScript's conditional statements: if , switch , or the ternary conditional operator (...
Read more >
GitHub Actions — Conditional Job Execution | by Pavel Saman
Conditional job execution might not be the most used feature in GitHub Actions but it's worth mentioning, especially because the conditions might be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found