instance_profile_indexers.tf 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. module "instance_profile" {
  2. source = "../../../submodules/iam/base_instance_profile"
  3. prefix = "xdr-idx"
  4. aws_partition = var.aws_partition
  5. aws_account_id = var.aws_account_id
  6. }
  7. # Indexer Specific Policy
  8. resource "aws_iam_policy" "instance_policy_idx" {
  9. name = "idx_instance_policy"
  10. path = "/launchroles/"
  11. description = "This policy allows indexer-specific functions"
  12. policy = data.aws_iam_policy_document.instance_policy_doc_idx.json
  13. }
  14. data "aws_iam_policy_document" "instance_policy_doc_idx" {
  15. # Allow copying to S3 for frozen
  16. # Allow use of S3 for SmartStore
  17. statement {
  18. sid = "GeneralBucketAccess"
  19. effect = "Allow"
  20. actions = [
  21. "s3:ListAllMyBuckets",
  22. ]
  23. resources = ["*"]
  24. }
  25. statement {
  26. sid = "S3BucketAccess"
  27. effect = "Allow"
  28. actions = [
  29. "s3:GetLifecycleConfiguration",
  30. "s3:DeleteObjectVersion",
  31. "s3:ListBucketVersions",
  32. "s3:GetBucketLogging",
  33. "s3:RestoreObject",
  34. "s3:ListBucket",
  35. "s3:GetBucketVersioning",
  36. "s3:PutObject",
  37. "s3:GetObject",
  38. "s3:PutLifecycleConfiguration",
  39. "s3:GetBucketCORS",
  40. "s3:DeleteObject",
  41. "s3:GetBucketLocation",
  42. "s3:GetObjectVersion",
  43. ]
  44. resources = [
  45. "arn:${var.aws_partition}:s3:::xdr-${var.prefix}-${var.environment}-splunk-frozen",
  46. "arn:${var.aws_partition}:s3:::xdr-${var.prefix}-${var.environment}-splunk-frozen/*",
  47. "arn:${var.aws_partition}:s3:::xdr-${var.prefix}-${var.environment}-splunk-smartstore",
  48. "arn:${var.aws_partition}:s3:::xdr-${var.prefix}-${var.environment}-splunk-smartstore/*",
  49. ]
  50. }
  51. statement {
  52. sid = "KMSKeyAccess"
  53. effect = "Allow"
  54. actions = [
  55. "kms:Decrypt",
  56. "kms:GenerateDataKeyWithoutPlaintext",
  57. "kms:Verify",
  58. "kms:GenerateDataKeyPairWithoutPlaintext",
  59. "kms:GenerateDataKeyPair",
  60. "kms:ReEncryptFrom",
  61. "kms:Encrypt",
  62. "kms:GenerateDataKey",
  63. "kms:ReEncryptTo",
  64. "kms:Sign",
  65. ]
  66. resources = ["*"]
  67. }
  68. statement {
  69. sid = "AllowAssumeRoleToSplunkApps"
  70. effect = "Allow"
  71. actions = [
  72. "sts:AssumeRole"
  73. ]
  74. resources = [
  75. "arn:${var.aws_partition}:iam::${var.aws_account_id}:role/service/splunk-apps-s3"
  76. ]
  77. }
  78. }
  79. resource "aws_iam_role_policy_attachment" "indexer_instance_policy_attach_idx" {
  80. role = module.instance_profile.role_id
  81. policy_arn = aws_iam_policy.instance_policy_idx.arn
  82. }