aws / aws/aws-cdk

Add a way to iterate Tags assigned to a construct

Open
#19,760 5 comments 1 reaction 0 assignees View on GitHub
@aws-cdk/core effort/medium feature-request p2
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the feature

I have not found a way to iterate Tags of a construct (or its node).

Once we add a Tag, e.g. with `Tags.of(construct).add("key", "value")`, there is no way of finding out whether the tag has been assigned or find constructs with such tag.

Would it be possible to introduce a Tag iterator, so we could grab `Tags.of(construct)` and get the `key, value` pair for every attached Tag?

### Use Case

I would like to use an Aspect to iterate all constructs, and collect those with a particular Tag attached.

### Proposed Solution

Add iterator to `Tags.of()`, or a listing capability.

### Other Information

_No response_

### Acknowledgements

- [ ] I may be able to implement this feature request
- [ ] This feature might incur a breaking change

### CDK version used

1.x

### Environment details (OS name and version, etc.)

TypeScript on Mac

Contributor guide

Open the contributing guide

Research direction

Start with the Tags.of(construct) entry point and review how the proposed Aspect use case would inspect constructs. Define how listing or iteration exposes each attached key/value pair, then verify that an Aspect can identify constructs carrying a particular tag.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
infrastructure
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.