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

feature request: append stack_tag inheritance #1187

Closed
zaro0508 opened this issue Dec 21, 2021 · 5 comments · Fixed by #1445
Closed

feature request: append stack_tag inheritance #1187

zaro0508 opened this issue Dec 21, 2021 · 5 comments · Fixed by #1445

Comments

@zaro0508
Copy link
Contributor

Currently stack_tags inheritance strategy is override which means that stack tags can be defined in a Sceptre StackGroup and then overridden in the a child StackGroup or Stack config. I would like to make a feature request to append stack_tags on a dependencies.

Example:
Assume Scepter project A, B and C with dependency C -> B

root StackConfig config/config.yaml

stack_tags:
  - country: US

config/prod/A.yaml

stack_tags:
  - city: anaheim    # stack A tags are 'city:anaheim', 'country:US'

config/prod/C.yaml

dependencies:
  - prod/B.yaml
stack_tags:
  - county: collin   # stack C tags are 'county:collin', 'country:US'

config/prod/B.yaml

stack_tags:
  - city: boston    # stack B tags are 'city:boston', 'county:collin', 'country:US'
@jfalkenstein
Copy link
Contributor

Implementation on this should be fairly easy; Simply using the dict_merge strategy instead of the child_wins. The only concern here is that this could be considered a "breaking" change, as it would change the way existing sceptre configurations operate. But I love this idea and would like to see it happen.

@include
Copy link

include commented Sep 27, 2022

I was thinking about - maybe adding this stack_tags: block at config.yaml level - it would apply automatically tags to all resources under a project/folder; without the need to add this block on each yaml cfn definition.

@jfalkenstein
Copy link
Contributor

@include That already works in Sceptre. The challenge is when you want to mix tags in your deeper configs with higher level configs. Right now, the deeper configs override the higher level ones.

@okcleary
Copy link
Contributor

Bumping this topic, I've very interested in this use-case as it would be very valuable for projects I work on (things like tags that are the same for a set of environments, but need to be extended down at each stack group).

I agree that changing the default strategy would be a big challenge, and would cause untold problems for existing configurations - not worth the trouble at all IMO.

To that end I feel that allowing the strategy to be defined by the config would be a better solution overall, not just for mitigating the problem of having to change the default behaviour.

The example here would be like

stack_tags_inheritance: dict_merge
stack_tags:
    tag_1: value_1
    tag_2: value_2

This could easily be applied to other merge-able config keys as well.

okcleary added a commit to okcleary/sceptre that referenced this issue Feb 25, 2024
okcleary added a commit to okcleary/sceptre that referenced this issue Feb 25, 2024
@okcleary
Copy link
Contributor

I've put up a PR to add this feature for consideration.

I realised late that the original issue here indicates some inheritance of tags from dependants (config/prod/B.yaml), I don't think this fits the existing inheritance model nor does it seem to make sense to me so I haven't addressed it at this time.

okcleary added a commit to okcleary/sceptre that referenced this issue Mar 15, 2024
okcleary added a commit to okcleary/sceptre that referenced this issue Mar 19, 2024
okcleary added a commit to okcleary/sceptre that referenced this issue Mar 20, 2024
okcleary added a commit to okcleary/sceptre that referenced this issue Mar 22, 2024
zaro0508 pushed a commit that referenced this issue Mar 23, 2024
…t and dict configs (#1445)

Add configuration for inheritance strategies for list and dict configs.

This resolves #1187 by allowing selecting a dict_merge strategy at a stack group/stack level, while remaining backwards compatible with existing stacks by retaining the default of child_wins.

This does not however address the example from the original issue of including tags of dependencies (or dependents?), as I don't believe this fits with the existing model (or makes sense as a use case).

This PR additionally adds the same support to all list and dict based configs.

The config for inheritance strategy itself is also inheritable, but not configurable.

From the original issue example:

Example:
Assume Sceptre project A, B and C with dependency C -> B

root StackConfig config/config.yaml

```
stack_tags_inheritance: dict_merge
stack_tags:
  - country: US
```

config/prod/A.yaml

```
stack_tags:
  - city: anaheim    # stack A tags are 'city:anaheim', 'country:US'
```

config/prod/C.yaml

```
dependencies:
  - prod/B.yaml
stack_tags:
  - county: collin   # stack C tags are 'county:collin', 'country:US'
```

config/prod/B.yaml

```
stack_tags:         # In contrast to original issue example, dependencies do not impact inherited values
  - city: boston    # stack B tags are 'city:boston', 'country:US'
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants