-
Notifications
You must be signed in to change notification settings - Fork 47
[aws-ints] Align IAM policy naming to match onboarding templates #260
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[aws-ints] Align IAM policy naming to match onboarding templates #260
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the legacy clean up won't work since the old policy won't match right now.
| LOGGER.error(f"Error deleting policy {policy_name}: {str(e)}") | ||
|
|
||
| # Clean up legacy hash-based policies if they exist (from old versions of this template) | ||
| legacy_prefixes = ["datadog-aws-integration-iam-permissions"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this expected to have more prefixes to deal with or can we eliminate the loop to reduce nesting?
| legacy_prefixes = ["datadog-aws-integration-iam-permissions"] | ||
| for prefix in legacy_prefixes: | ||
| for i in range(1, max_policies + 1): | ||
| policy_name = f"{prefix}-part{i}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this missing the hash so it won't match the previous naming convention?
| for i, chunk in enumerate(permission_chunks): | ||
| # Create policy | ||
| policy_name = f"{base_policy_name}-part{i+1}" | ||
| policy_name = f"{role_name}-ManagedPolicy-{i+1}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe move this to a get policy method that you can share so we don't get out of sync again with the format for creation and deletion
| """Clean up existing policies with the base_policy_name prefix""" | ||
| for i in range(max_policies): | ||
| policy_name = f"{base_policy_name}-part{i+1}" | ||
| def cleanup_existing_policies(iam_client, role_name, account_id, max_policies=20): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this just a copy paste from above or does this get generated or something?
Note: Please remember to review the contribution guidelines
if you have not yet done so.
What does this PR do?
Changes the naming of the iam policies created by the
aws_attach_integration_permissionstemplate to match the naming in our quickstart and organizations templatesdatadog-aws-integration-iam-permissions-{hash}-part1,part2, etc.{RoleName}-ManagedPolicy-1,{RoleName}-ManagedPolicy-2, etc.Motivation
A customer noticed that we are creating policies with duplicate permissions since the naming is not aligned
Testing Guidelines
How did you test this pull request?
Additional Notes
Anything else we should know when reviewing?