iam_splunk_sh.tf 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # Creates an IAM role so that splunk can trigger creation of audit reports
  2. resource "aws_iam_role" "run_audit_report_role" {
  3. name = "run_audit_report_role"
  4. path = "/service/"
  5. assume_role_policy = jsonencode(
  6. {
  7. "Version" : "2012-10-17",
  8. "Statement" : [
  9. {
  10. "Effect" : "Allow",
  11. "Principal" : {
  12. "AWS" : "arn:${var.aws_partition}:iam::${var.c2_accounts[var.aws_partition]}:role/instance/moose-splunk-sh-instance-role"
  13. },
  14. "Action" : "sts:AssumeRole"
  15. }
  16. ]
  17. })
  18. tags = merge(local.standard_tags, var.tags)
  19. }
  20. # tfsec:ignore:aws-iam-no-policy-wildcards Allows use by the entire account
  21. data "aws_iam_policy_document" "run_audit_report_policy_doc" {
  22. # checkov:skip=CKV_AWS_111: see tfsec aws-iam-no-policy-wildcard ignore comment
  23. statement {
  24. sid = ""
  25. effect = "Allow"
  26. resources = ["*"]
  27. actions = [
  28. "acm-pca:CreateCertificateAuthorityAuditReport"
  29. ]
  30. }
  31. }
  32. resource "aws_iam_policy" "run_audit_report_policy" {
  33. name = "run_audit_report_policy"
  34. path = "/"
  35. policy = data.aws_iam_policy_document.run_audit_report_policy_doc.json
  36. }
  37. resource "aws_iam_role_policy_attachment" "run_audit_report_policy_attach" {
  38. role = aws_iam_role.run_audit_report_role.name
  39. policy_arn = aws_iam_policy.run_audit_report_policy.arn
  40. }