policy-mdr_readonly_assumerole.tf 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #------------------------------------------------------------------------------------------
  2. # A Read Only Engineer. Assumption is this is everyone's normal working
  3. # role day-to-day in the AWS console. When you need it, you then elevate
  4. # to mdr_terraformer.
  5. #
  6. # Note this is NOT JUST READ ONLY ACCESS. This should only be
  7. # assigned to ENGINEERS who you expect will able to make changes
  8. # as needed.
  9. #------------------------------------------------------------------------------------------
  10. data "aws_iam_policy_document" "mdr_engineer_readonly_assumerole" {
  11. statement {
  12. sid = "AllowPassRoleForSpecificRoleTypes"
  13. effect = "Allow"
  14. actions = [
  15. "iam:PassRole",
  16. ]
  17. resources = [
  18. "arn:${local.aws_partition}:iam::${local.aws_account}:role/instance/*",
  19. "arn:${local.aws_partition}:iam::${local.aws_account}:role/lambda/*",
  20. "arn:${local.aws_partition}:iam::${local.aws_account}:role/aws_services/*",
  21. "arn:${local.aws_partition}:iam::${local.aws_account}:role/fargate/*",
  22. ]
  23. }
  24. statement {
  25. sid = "AssumeThisRoleInOtherAccounts"
  26. effect = "Allow"
  27. actions = [
  28. "sts:AssumeRole"
  29. ]
  30. resources = [
  31. "arn:${local.aws_partition}:iam::*:role/user/mdr_engineer_readonly",
  32. # Give a readonly engineer the ability if needed to elevate to terraformer
  33. # In order to make changes when needed.
  34. "arn:${local.aws_partition}:iam::*:role/user/mdr_terraformer",
  35. # These two are the legacy roles in the older AWS accounts.
  36. # Adding them in the hope we'll be able to get AssumeRole from
  37. # one central place to everything...
  38. "arn:${local.aws_partition}:iam::*:role/mdr_powerusers",
  39. "arn:${local.aws_partition}:iam::*:role/mdr_iam_admins",
  40. ]
  41. }
  42. }
  43. resource "aws_iam_policy" "mdr_engineer_readonly_assumerole" {
  44. name = "mdr_engineer_readonly_assumerole"
  45. path = "/user/"
  46. policy = data.aws_iam_policy_document.mdr_engineer_readonly_assumerole.json
  47. }