iam_splunk_sh_role.tf 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. module "instance_profile" {
  2. count = var.create_instance_profile ? 1 : 0
  3. source = "../../../submodules/iam/base_instance_profile"
  4. prefix = "splunk-sh"
  5. aws_partition = var.aws_partition
  6. aws_account_id = var.aws_account_id
  7. }
  8. data "aws_iam_policy_document" "splunk_sh_policy_doc" {
  9. count = var.create_instance_profile ? 1 : 0
  10. statement {
  11. sid = "AllowAssumeRole"
  12. effect = "Allow"
  13. actions = [
  14. "sts:AssumeRole"
  15. ]
  16. resources = [
  17. "arn:${ var.aws_partition }:iam::${ var.aws_account_id }:role/service/splunk_apps_s3"
  18. ]
  19. }
  20. }
  21. resource "aws_iam_policy" "splunk_sh_policy" {
  22. count = var.create_instance_profile ? 1 : 0
  23. name = "splunk_sh"
  24. path = "/"
  25. policy = data.aws_iam_policy_document.splunk_sh_policy_doc[count.index].json
  26. }
  27. resource "aws_iam_role_policy_attachment" "splunk_sh_attach" {
  28. count = var.create_instance_profile ? 1 : 0
  29. role = module.instance_profile[count.index].role_id
  30. policy_arn = aws_iam_policy.splunk_sh_policy[count.index].arn
  31. }
  32. #This policy needs to be create prior to creating the Salt Master
  33. resource "aws_iam_role_policy_attachment" "splunk_sh_policy_attach_binaries" {
  34. count = var.create_instance_profile ? 1 : 0
  35. role = module.instance_profile[count.index].role_id
  36. policy_arn = "arn:${var.aws_partition}:iam::${var.aws_account_id}:policy/launchroles/default_instance_s3_binaries"
  37. }