instance_profile_indexers.tf 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. # tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
  67. resources = ["*"]
  68. }
  69. statement {
  70. sid = "AllowAssumeRoleToSplunkApps"
  71. effect = "Allow"
  72. actions = [
  73. "sts:AssumeRole"
  74. ]
  75. resources = [
  76. "arn:${var.aws_partition}:iam::${var.aws_account_id}:role/service/splunk-apps-s3"
  77. ]
  78. }
  79. }
  80. resource "aws_iam_role_policy_attachment" "indexer_instance_policy_attach_idx" {
  81. role = module.instance_profile.role_id
  82. policy_arn = aws_iam_policy.instance_policy_idx.arn
  83. }