policy-mdr_readonly_assumerole.tf 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. "arn:${local.aws_partition}:iam::*:role/user/mdr_developer_readonly",
  35. # Give a readonly engineer the ability if needed to elevate to terraformer
  36. # In order to make changes when needed.
  37. "arn:${local.aws_partition}:iam::*:role/user/mdr_terraformer",
  38. # These two are the legacy roles in the older AWS accounts.
  39. # Adding them in the hope we'll be able to get AssumeRole from
  40. # one central place to everything...
  41. "arn:${local.aws_partition}:iam::*:role/mdr_powerusers",
  42. "arn:${local.aws_partition}:iam::*:role/mdr_iam_admins",
  43. ]
  44. }
  45. }
  46. resource "aws_iam_policy" "mdr_engineer_readonly_assumerole" {
  47. name = "mdr_engineer_readonly_assumerole"
  48. path = "/user/"
  49. policy = data.aws_iam_policy_document.mdr_engineer_readonly_assumerole.json
  50. }