Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Make variables mutable #479

Open
ysdholak opened this issue Mar 7, 2024 · 1 comment
Open

[Enhancement] Make variables mutable #479

ysdholak opened this issue Mar 7, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@ysdholak
Copy link

ysdholak commented Mar 7, 2024

**Is your feature request related to a problem? Yes

A clear and concise description of what the problem is.

I've worked through many rules where we need to add or delete data from variables based on occurrences in all Resources.

Describe the solution you'd like

Make variables mutable, so data can be added or deleted as user wants and can get better control over rules and cover wide set of rules. Currently, it is immutable and so once defined it cannot be changed.

Describe alternatives you've considered

NA

Additional context

The best example was, I am trying to write a rule for AWS::EC2:NetworkNaclEntry resources and it fails if same resource ids uses same rule number. So I need to keep track of Refs to Resources Ids and their Rule numbers encountered so far and if for same reource, if rule number is repeated, rule fails.

In current cfn-guard versions, this wouldn't be possible.

Also, let me know if you need more info. Thanks!

@ysdholak ysdholak added the enhancement New feature or request label Mar 7, 2024
@joshfried-aws
Copy link
Contributor

joshfried-aws commented Mar 26, 2024

Hey @ysdholak thanks for reaching out.

I think the most likely approach we would take if we were to implement something like this would to not necessarily make the variables mutable, but to provide some sort of mechanism to achieve this functionality.

I think the approach that would best fit would be to provide a function which allows users to add items to the list.

This function would take n >= 2 arguments, where the first argument is the original list, and the next n-1 arguments are the items we want to add to the list. This function would not actually change the original list, what it would do is it would return a new list with all the elements form the first list, and all the elements that were passed as arguments.

For example say we were to have the following

let list = ["foo", "bar"]
let list = append(%list, "baz") 

%list == ["foo", "bar", "baz"] 

What do you think of this approach?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants