Skip to content

feat: migrate Tier 2 resources to map_existing_resources#538

Merged
michael-richey merged 2 commits intomainfrom
mrichey/map-existing-resources-tier2-and-fixes-v2
Apr 21, 2026
Merged

feat: migrate Tier 2 resources to map_existing_resources#538
michael-richey merged 2 commits intomainfrom
mrichey/map-existing-resources-tier2-and-fixes-v2

Conversation

@michael-richey
Copy link
Copy Markdown
Collaborator

@michael-richey michael-richey commented Apr 21, 2026

Summary

  • Migrate roles, security_monitoring_rules, team_memberships, logs_metrics to the map_existing_resources pattern (matching Tier 1 from feat: migrate Tier 1 resources to map_existing_resources #528)
  • Fix transitive dependency handling in resources_handler.py so map_existing_resources is called for resource types pulled in transitively (e.g. roles as a dep of users)
  • Fix role assignment for users: allow built-in Datadog roles (Admin, Read Only, Standard) through the sync flow so connect_id can translate source→destination role IDs. The existing managed check in create_resource prevents any actual API calls — it just creates the mapping.
  • Fix pre-existing bug in users.py update_user_roles where DeepDiff values_changed could produce a dict object as new_value instead of a string ID
  • Add _wait_for_no_destination_monitors pre-check in TestCli sync/migrate tests to handle async deletion side-effects from preceding resource tests

Note on built-in roles

If you have existing source state from before this change (where built-in roles were filtered and never imported), run import again before sync to create the correct source→destination ID mapping.

Test plan

  • All integration tests pass (RECORD=true tox -e py39)
  • tox -e ruff,black passes
  • CI passes

🤖 Generated with Claude Code

michael-richey and others added 2 commits April 21, 2026 11:07
- Migrate roles, security_monitoring_rules, team_memberships, logs_metrics
  to map_existing_resources pattern
- Fix transitive dependency handling in resources_handler.py so
  map_existing_resources is called for all resource types including
  transitively-pulled-in ones
- Fix roles: allow built-in roles through sync to establish source→dest
  ID mapping (managed-role guard in create_resource prevents any API calls)
- Fix users: correct role ID translation in update_user_roles; add
  isinstance guard for dict-typed DeepDiff values_changed entries
- Add monitor pre-check in TestCli sync/migrate tests to handle async
  deletion side-effects from preceding resource tests
- Remove redundant map_existing_resources override from team_memberships
- Black formatting

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Re-recorded cassettes after Tier 2 map_existing_resources migration
and related fixes. All TestCli and resource tests pass.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@michael-richey michael-richey marked this pull request as ready for review April 21, 2026 15:09
@michael-richey michael-richey requested a review from a team as a code owner April 21, 2026 15:09
@michael-richey michael-richey merged commit 8c668bb into main Apr 21, 2026
21 of 22 checks passed
@michael-richey michael-richey deleted the mrichey/map-existing-resources-tier2-and-fixes-v2 branch April 21, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants