policy-mdr_engineer.tf 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #------------------------------------------------------------------------------------------
  2. # A variant on PowerUserAccess that isn't so damn generous with sts:assumeRole
  3. #------------------------------------------------------------------------------------------
  4. data "aws_iam_policy_document" "mdr_engineer" {
  5. statement {
  6. effect = "Allow"
  7. not_actions = [
  8. "sts:*",
  9. "iam:*",
  10. "organizations:*",
  11. ]
  12. resources = [
  13. "*",
  14. ]
  15. }
  16. statement {
  17. effect = "Allow"
  18. actions = [
  19. "iam:CreateServiceLinkedRole",
  20. "iam:DeleteServiceLinkedRole",
  21. "iam:ListRoles",
  22. "iam:ListRolePolicies",
  23. "iam:ListInstanceProfiles",
  24. "iam:ListPolicies",
  25. "iam:GetRole",
  26. "iam:GetRolePolicy",
  27. "iam:GetInstanceProfile",
  28. "iam:GetPolicy",
  29. "iam:GetPolicyVersion",
  30. "iam:ListAttachedRolePolicies",
  31. "organizations:DescribeOrganization",
  32. ]
  33. resources = [
  34. "*",
  35. ]
  36. }
  37. statement {
  38. effect = "Allow"
  39. actions = [
  40. "iam:PassRole",
  41. ]
  42. resources = [
  43. "arn:${local.aws_partition}:iam::${local.aws_account}:role/instance/*",
  44. "arn:${local.aws_partition}:iam::${local.aws_account}:role/lambda/*",
  45. "arn:${local.aws_partition}:iam::${local.aws_account}:role/aws_services/*",
  46. "arn:${local.aws_partition}:iam::${local.aws_account}:role/fargate/*",
  47. ]
  48. }
  49. statement {
  50. sid = "AssumeThisRoleInOtherAccounts"
  51. effect = "Allow"
  52. actions = [
  53. "sts:AssumeRole"
  54. ]
  55. resources = [
  56. "arn:${local.aws_partition}:iam::*:role/user/mdr_engineer",
  57. "arn:${local.aws_partition}:iam::*:role/mdr_engineer",
  58. ]
  59. }
  60. }
  61. resource "aws_iam_policy" "mdr_engineer" {
  62. name = "mdr_engineer"
  63. path = "/user/"
  64. policy = data.aws_iam_policy_document.mdr_engineer.json
  65. }