instance_profile_indexers.tf 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. # checkov:skip=CKV_AWS_111: see tfsec aws-iam-no-policy-wildcard ignore comment
  16. # Allow copying to S3 for frozen
  17. # Allow use of S3 for SmartStore
  18. statement {
  19. sid = "GeneralBucketAccess"
  20. effect = "Allow"
  21. actions = [
  22. "s3:ListAllMyBuckets",
  23. ]
  24. resources = ["*"]
  25. }
  26. statement {
  27. sid = "S3BucketAccess"
  28. effect = "Allow"
  29. actions = [
  30. "s3:GetLifecycleConfiguration",
  31. "s3:DeleteObjectVersion",
  32. "s3:ListBucketVersions",
  33. "s3:GetBucketLogging",
  34. "s3:RestoreObject",
  35. "s3:ListBucket",
  36. "s3:GetBucketVersioning",
  37. "s3:PutObject",
  38. "s3:GetObject",
  39. "s3:PutLifecycleConfiguration",
  40. "s3:GetBucketCORS",
  41. "s3:DeleteObject",
  42. "s3:GetBucketLocation",
  43. "s3:GetObjectVersion",
  44. ]
  45. resources = [
  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-frozen/*",
  48. "arn:${var.aws_partition}:s3:::xdr-${var.prefix}-${var.environment}-splunk-smartstore",
  49. "arn:${var.aws_partition}:s3:::xdr-${var.prefix}-${var.environment}-splunk-smartstore/*",
  50. ]
  51. }
  52. statement {
  53. sid = "KMSKeyAccess"
  54. effect = "Allow"
  55. actions = [
  56. "kms:Decrypt",
  57. "kms:GenerateDataKeyWithoutPlaintext",
  58. "kms:Verify",
  59. "kms:GenerateDataKeyPairWithoutPlaintext",
  60. "kms:GenerateDataKeyPair",
  61. "kms:ReEncryptFrom",
  62. "kms:Encrypt",
  63. "kms:GenerateDataKey",
  64. "kms:ReEncryptTo",
  65. "kms:Sign",
  66. ]
  67. # tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
  68. resources = ["*"]
  69. }
  70. statement {
  71. sid = "AllowAssumeRoleToSplunkApps"
  72. effect = "Allow"
  73. actions = [
  74. "sts:AssumeRole"
  75. ]
  76. resources = [
  77. "arn:${var.aws_partition}:iam::${var.aws_account_id}:role/service/splunk-apps-s3"
  78. ]
  79. }
  80. }
  81. resource "aws_iam_role_policy_attachment" "indexer_instance_policy_attach_idx" {
  82. role = module.instance_profile.role_id
  83. policy_arn = aws_iam_policy.instance_policy_idx.arn
  84. }