Skip to content
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

feat: Add iam_policy_enabled to allow IAM roles without policies #47

Merged
merged 2 commits into from
Aug 9, 2023

Conversation

dennislapchenko
Copy link
Contributor

@dennislapchenko dennislapchenko commented Jun 29, 2023

what

  • New variable iam_policy_enabled which allows creating iam eks role without a policy.
  • Also changed ["{}"] to [] in module "eks_iam_role".aws_iam_policy_document when iam_policy_enabled is true. as "{}" is still an item and the module was still attempting to create a policy. (because its based on length(var. aws_iam_policy_document))

why

  • When utilizing resource-based-policies access is granted on that specific resource, role that is granted access can have no policies at all, which is often a desired case.
  • On this issue it was suggested that deny * policy can always be used when no policy is desired. But this does not work when using resource based policies, as the role is denied all access, including the on in resource's policy
  • In my particular case I had a KMS key that allowed a role to decrypt using this key. The role needed no policies, so following the suggestion mention above I added deny all policy, which prevented by role from using the key. Removing the policy made things work, so this feature clearly has a valid use case.

references

Identity-based policies and resource-based policies grant permissions to the identities or resources to which they are attached. When an IAM entity (user or role) requests access to a resource within the same account, AWS evaluates all the permissions granted by the identity-based and resource-based policies. The resulting permissions are the total permissions of the two types. If an action is allowed by an identity-based policy, a resource-based policy, or both, then AWS allows the action. An explicit deny in either of these policies overrides the allow.

@Nuru Nuru added do not merge Do not merge this PR, doing so would cause problems invalid This doesn't seem right wontfix This will not be worked on auto-update This PR was automatically generated and removed do not merge Do not merge this PR, doing so would cause problems invalid This doesn't seem right wontfix This will not be worked on auto-update This PR was automatically generated labels Aug 9, 2023
@Nuru
Copy link
Contributor

Nuru commented Aug 9, 2023

/terratest

@Nuru Nuru added the patch A minor, backward compatible change label Aug 9, 2023
Copy link
Contributor

@Nuru Nuru left a comment

Choose a reason for hiding this comment

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

This is an unusual use case. Thank you for providing a concrete example of how this could be useful, and thank you for the PR.

@Nuru Nuru enabled auto-merge (squash) August 9, 2023 08:20
@Nuru Nuru merged commit e12cf7d into cloudposse:main Aug 9, 2023
16 checks passed
@Nuru Nuru mentioned this pull request Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
patch A minor, backward compatible change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create an IRSA without an IAM policy
2 participants