Skip to content

Conversation

@raymondeah
Copy link
Contributor

@raymondeah raymondeah commented Oct 24, 2025

What does this PR do?

Removes all enumerated IAM permissions from the datadog_integration_role nested stack. Adds a Lambda function to retrieve the same permissions from the Datadog API and attach them to the integration role.

Motivation

We want to cut down as much as possible all places where we enumerate IAM permissions. Since we recently released public API endpoints returning the IAM permissions required by the integration, we can use this instead.

Testing Guidelines

link to new template

Tested following cases:

  • On first stack run -> Account integration is created in Datadog, IAM policies are successfully created and attached to the integration role
  • On subsequent stack runs -> customer managed policies are successfully recreated and attached to the specified integration role
  • Previously created policies are manually detached/deleted before rerunning stack -> stack doesn't fail

Additional Notes

Anything else we should know when reviewing?

@@ -1 +1 @@
v4.1.4
Copy link
Member

Choose a reason for hiding this comment

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

I think this warrants a major version update

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that depends: is it backwards compatible? e.g., will customers updating from an older version to this experience a breaking change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This shouldn't be a breaking change, the only thing changing currently is the naming of the resource collection permissions managed policies, from {role name}-ManagedPolicy-* to datadog-aws-integration-resource-collection-permissions-*. To be fully backwards compatible we could also keep the original naming

# 4.2.4 (October 24, 2025)

- Remove enumerated IAM permissions
- Add Lambda function to attach IAM permissions
Copy link
Member

Choose a reason for hiding this comment

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

Maybe let's write down a more comprehensive changelog for customers, similar to the PR description

@raymondeah raymondeah marked this pull request as ready for review October 24, 2025 15:16
@raymondeah raymondeah requested a review from a team as a code owner October 24, 2025 15:16
raymondeah and others added 3 commits October 24, 2025 11:18
# Remove resource collection permissions
for i in range(max_policies):
policy_name = f"{BASE_POLICY_PREFIX_RESOURCE_COLLECTION}-{i+1}"
policy_arn = f"arn:aws:iam::{account_id}:policy/{policy_name}"
Copy link
Contributor

Choose a reason for hiding this comment

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

💭 anywhere we construct policy arns we should use ${AWS::Partition} so it works for govcloud and china

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in b3e9522

handle_delete(event, context, role_name, account_id)
else:
handle_create_update(event, context, role_name, account_id, should_install_security_audit_policy)
DatadogAttachIntegrationPermissionsFunctionTrigger:
Copy link
Contributor

Choose a reason for hiding this comment

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

💭 should this have a dependency on DatadogIntegrationRole to ensure the role is created first?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we should, there's an implicit dependency on the Lambda resource but this would make it completely safe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in b3e9522

- iam:PutRolePolicy
Resource:
- !Sub arn:aws:iam::${AWS::AccountId}:role/${IAMRoleName}
- !Sub arn:aws:iam::${AWS::AccountId}:policy/datadog-aws-integration-resource-collection-permissions-*
Copy link
Contributor

Choose a reason for hiding this comment

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

💭 re: the name datadog-aws-integration-resource-collection-permissions-* -- these aren't all necessarily resource collection related, right? these are also the standard and core permissions

Copy link
Contributor

Choose a reason for hiding this comment

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

or are we just missing the policies containing the standard perms here?

Copy link
Contributor Author

@raymondeah raymondeah Feb 9, 2026

Choose a reason for hiding this comment

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

these permissions datadog-aws-integration-resource-collection-permissions-* are all resource collection related (there is some overlap with standard but only the ones necessary for resource collection). since standard permissions are attached here as an inline policy, we don't need to add the naming here since we can just create it directly

@raymondeah raymondeah merged commit c4919d3 into master Feb 10, 2026
5 of 7 checks passed
@raymondeah raymondeah deleted the ray.eah/awscore-221-quickstart-remove-iam-permissions branch February 10, 2026 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants