Scope IAM resource collection policy names to role name#274
Merged
raymondeah merged 3 commits intomasterfrom Feb 13, 2026
Merged
Scope IAM resource collection policy names to role name#274raymondeah merged 3 commits intomasterfrom
raymondeah merged 3 commits intomasterfrom
Conversation
… re-creation The Lambda that attaches resource collection permissions used hardcoded policy names (e.g. datadog-aws-integration-resource-collection-permissions-1) which are global per AWS account. When a stack is deleted and re-created with the same role name, cleanup may fail to delete the old policies (e.g. still attached), causing create_policy to fail with EntityAlreadyExists. Fix: include the IAM role name in policy names so they are unique per integration role. The existing wildcard ARN in the Lambda execution role already covers any suffix pattern. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
raymondeah
commented
Feb 12, 2026
|
|
||
| - Scope IAM policy names to role name to prevent `EntityAlreadyExists` errors on stack re-creation | ||
|
|
||
| # 4.5.0 (February 11, 2026) |
Contributor
Author
There was a problem hiding this comment.
drive-by add here
ktmq
approved these changes
Feb 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EntityAlreadyExistserrors when re-creating CloudFormation stacks_detach_and_delete_policyhelper to reduce duplication in cleanup logicattach_integration_permissions.pyand the inline Lambda indatadog_integration_role.yamlProblem
The Lambda that attaches resource collection permissions uses hardcoded policy names like
datadog-aws-integration-resource-collection-permissions-1. These names are global per AWS account. When a stack is deleted and re-created:cleanup_existing_policiestries to detach + delete old policiesDeleteConflictExceptionwhich is only logged as a warningcreate_policythen fails withEntityAlreadyExistsbecause the old policy wasn't deletedFix
Include the IAM role name in policy names:
Since IAM role names are unique per AWS account, this guarantees policy name uniqueness per integration. The existing wildcard ARN in the Lambda execution role (
policy/datadog-aws-integration-resource-collection-permissions-*) already covers any suffix.Risk
None. This was introduced in PR #250 and has not been released in Datadog UI yet.
Test plan
ResourceCollectionPermissions=true, verify policies created with role-scoped namesEntityAlreadyExistserrorIAMRoleNameparameter