policy-mdr_readonly_assumerole.tf 2.2 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. # tfsec:ignore:aws-iam-no-policy-wildcards - baseline this setting first. Lockdown after baselining IAM permissions
  18. resources = [
  19. "arn:${local.aws_partition}:iam::${local.aws_account}:role/instance/*",
  20. "arn:${local.aws_partition}:iam::${local.aws_account}:role/lambda/*",
  21. "arn:${local.aws_partition}:iam::${local.aws_account}:role/aws_services/*",
  22. "arn:${local.aws_partition}:iam::${local.aws_account}:role/fargate/*",
  23. ]
  24. }
  25. statement {
  26. sid = "AssumeThisRoleInOtherAccounts"
  27. effect = "Allow"
  28. actions = [
  29. "sts:AssumeRole"
  30. ]
  31. # tfsec:ignore:aws-iam-no-policy-wildcards - baseline this setting first. Lockdown after baselining IAM permissions
  32. resources = [
  33. "arn:${local.aws_partition}:iam::*:role/user/mdr_engineer_readonly",
  34. # Give a readonly engineer the ability if needed to elevate to terraformer
  35. # In order to make changes when needed.
  36. "arn:${local.aws_partition}:iam::*:role/user/mdr_terraformer",
  37. # These two are the legacy roles in the older AWS accounts.
  38. # Adding them in the hope we'll be able to get AssumeRole from
  39. # one central place to everything...
  40. "arn:${local.aws_partition}:iam::*:role/mdr_powerusers",
  41. "arn:${local.aws_partition}:iam::*:role/mdr_iam_admins",
  42. ]
  43. }
  44. }
  45. resource "aws_iam_policy" "mdr_engineer_readonly_assumerole" {
  46. name = "mdr_engineer_readonly_assumerole"
  47. path = "/user/"
  48. policy = data.aws_iam_policy_document.mdr_engineer_readonly_assumerole.json
  49. }