Skip to content
This repository was archived by the owner on Mar 23, 2026. It is now read-only.

Adapt new IAM provider to use new Tags concept#13884

Merged
dfangl merged 2 commits into
iam/moto-migrationfrom
daniel/unc-293
Mar 5, 2026
Merged

Adapt new IAM provider to use new Tags concept#13884
dfangl merged 2 commits into
iam/moto-migrationfrom
daniel/unc-293

Conversation

@dfangl

@dfangl dfangl commented Mar 4, 2026

Copy link
Copy Markdown
Member

Motivation

With #13821 a new concept for tagging was introduced, a Tags class to store tags for a provider.

This PR will migrate the new IAM provider to use this new mechanism.

Changes

  • Migrate all tags to separate TAGS store entry.

Tests

  • All tagging related tests still pass

Related

Closes UNC-293

@dfangl dfangl requested a review from pinzon as a code owner March 4, 2026 19:07
@dfangl dfangl added this to the 2026.03 milestone Mar 4, 2026
@dfangl dfangl added semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes labels Mar 4, 2026
@dfangl dfangl requested a review from bentsku March 4, 2026 19:07
@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown

LocalStack Community integration with Pro

  2 files  ±    0    2 suites  ±0   2m 53s ⏱️ - 2h 4m 39s
520 tests  - 5 133  509 ✅  - 4 771  11 💤  - 361  0 ❌  - 1 
522 runs   - 5 133  509 ✅  - 4 771  13 💤  - 361  0 ❌  - 1 

Results for commit e0a5c38. ± Comparison against base commit 2770dfd.

@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown

Test Results - Preflight, Unit

23 104 tests  ±0   21 217 ✅ ±0   6m 19s ⏱️ -16s
     1 suites ±0    1 887 💤 ±0 
     1 files   ±0        0 ❌ ±0 

Results for commit b5e4fe2. ± Comparison against base commit 2770dfd.

♻️ This comment has been updated with latest results.

@pinzon pinzon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No comments 👍

@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 3s ⏱️ -2s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit b5e4fe2. ± Comparison against base commit 2770dfd.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Mar 4, 2026

Copy link
Copy Markdown

Test Results (amd64) - Integration, Bootstrap

  5 files  ±    0    5 suites  ±0   11m 53s ⏱️ - 2h 29m 35s
544 tests  - 5 514  533 ✅  - 4 996  11 💤  - 517  0 ❌  - 1 
550 runs   - 5 514  533 ✅  - 4 996  17 💤  - 517  0 ❌  - 1 

Results for commit b5e4fe2. ± Comparison against base commit 2770dfd.

♻️ This comment has been updated with latest results.

@bentsku bentsku left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, this is nice to see tags being centralized! This is gonna make it easier to interact with them from outside 👍

One note: tagging functionality does not need to be put into particular methods anymore, as they do not need to be overridden.

Using the store directly if it equals to the same logic makes sense 👍 except if we want to keep consistency, so it's a matter of personal preference in the end, on how the provider is structured. Just wanted to mention that it was not a requirement anymore 😄

Jus have some comments about some docstrings that seem to be out of date, but logically it seems all good 👍

One thing to always keep track of is to clean up tags when deleting resources, but it seems to be taken care of in this PR 👍

\cc @viren-nadkarni @aidehn for a Tags migration, if you want to have a look

ACCOUNT_ALIAS: str | None = CrossRegionAttribute(default=None)

# Centralized tag storage for all IAM resources
TAGS: Tags = CrossRegionAttribute(default=Tags)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: usually, Tagging is a LocalAttribute. This is because from testing in ResourceGroupsTaggingApi, trying to list the tags of something will only yield depending on the region of the caller. But as IAM is a truly global service, I think this does not apply 👍

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With a LocalAttribute we would have had a problem with store lookup should, somehow, a request be made to a different region. To avoid this incompatibility, I chose a CrossRegionAttribute here as well :)

@bentsku bentsku Mar 5, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in other services, we use the resource ARN to do the store lookup for tags in particular, because it seems are scoped by region somehow, as showed by RGTA testing.

For ex, for Route53, you can list tags in RGTA if the originating request is in us-east-1, otherwise it returns no tags.

Same for S3, the originating request needs to be in the same as the region.
So we do not want to have all tags from all regions when trying to list tags per region.

But coming back to Route53, then we just have hardcoded region in RGTA, etc 👍 or you can filter it in the RGTA plugin itself. You can see rgta.py in Route53 and S3 for weird examples, and KMS for a normal one


:param store: IamStore instance
:param arn: Resource ARN
:param case_sensitive: Not used for get, but kept for API consistency

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this param isn't there anymore

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude added that, I removed it again and missed that 😅

Comment on lines +929 to +936
def _delete_all_tags(self, store: IamStore, arn: str) -> None:
"""
Delete all tags for a resource (used when the resource is deleted).

:param store: IamStore instance
:param arn: Resource ARN
"""
store.TAGS.delete_all_tags(arn)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think as this function does not hold more logic, it can be removed and the provider can call the store directly

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, but I am inclined to keep it, if there are any more iterations on the tags storage, we only have to change it in a central location 😅

Comment on lines +938 to +950
def _store_initial_tags(
self, store: IamStore, arn: str, tags: list[dict] | None, case_sensitive: bool = True
) -> None:
"""
Store initial tags when creating a resource.

:param store: IamStore instance
:param arn: Resource ARN
:param tags: Tags in list format [{"Key": ..., "Value": ...}]
:param case_sensitive: Whether to treat keys case-sensitively (True) or case-insensitively (False)
"""
if tags:
self._update_tags(store, arn, tags, case_sensitive)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same with this function, it can probably directly in the provider? except if we don't want to repeat the if tags I guess, this is up to you

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is truly unnecessary, agreed! Will just use _update_tags directly everywhere

@dfangl dfangl merged commit a492fcd into iam/moto-migration Mar 5, 2026
29 of 32 checks passed
@dfangl dfangl deleted the daniel/unc-293 branch March 5, 2026 10:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants