|
@@ -1,19 +1,62 @@
|
|
|
-module "instance_profile" {
|
|
|
- source = "../../../submodules/iam/base_instance_profile"
|
|
|
- prefix = "xdr-indexer"
|
|
|
- aws_partition = var.aws_partition
|
|
|
- aws_account_id = var.aws_account_id
|
|
|
+#############################
|
|
|
+# Indexer instance profile
|
|
|
+#
|
|
|
+# Includes policies for the indexers:
|
|
|
+# * Same policies as the default instance profile
|
|
|
+resource "aws_iam_instance_profile" "indexer_instance_profile" {
|
|
|
+ name = "xdr-indexer-instance-profile"
|
|
|
+ path = "/instance/"
|
|
|
+ role = aws_iam_role.indexer_instance_role.name
|
|
|
+}
|
|
|
+
|
|
|
+resource "aws_iam_role" "indexer_instance_role" {
|
|
|
+ name = "xdr-indexer-instance-role"
|
|
|
+ path = "/instance/"
|
|
|
+ assume_role_policy = <<EOF
|
|
|
+{
|
|
|
+ "Version": "2012-10-17",
|
|
|
+ "Statement": [
|
|
|
+ {
|
|
|
+ "Sid": "",
|
|
|
+ "Effect": "Allow",
|
|
|
+ "Principal": {
|
|
|
+ "Service": [
|
|
|
+ "ec2.amazonaws.com",
|
|
|
+ "ssm.amazonaws.com"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "Action": "sts:AssumeRole"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+EOF
|
|
|
+}
|
|
|
+
|
|
|
+# These 3 are the default profile attachments:
|
|
|
+resource "aws_iam_role_policy_attachment" "indexer_instance_AmazonEC2RoleforSSM" {
|
|
|
+ role = aws_iam_role.indexer_instance_role.name
|
|
|
+ policy_arn = "arn:${var.aws_partition}:iam::aws:policy/service-role/AmazonEC2RoleforSSM"
|
|
|
+}
|
|
|
+
|
|
|
+resource "aws_iam_role_policy_attachment" "indexer_instance_default_policy_attach" {
|
|
|
+ role = aws_iam_role.indexer_instance_role.name
|
|
|
+ policy_arn = "arn:${ var.aws_partition }:iam::${ var.aws_account_id }:policy/launchroles/default_instance_tag_read"
|
|
|
+}
|
|
|
+
|
|
|
+resource "aws_iam_role_policy_attachment" "indexer_instance_cloudwatch_policy_attach" {
|
|
|
+ role = aws_iam_role.indexer_instance_role.name
|
|
|
+ policy_arn = "arn:${ var.aws_partition }:iam::${ var.aws_account_id }:policy/cloudwatch_events"
|
|
|
}
|
|
|
|
|
|
# Indexer Specific Policy
|
|
|
-resource "aws_iam_policy" "instance_policy" {
|
|
|
+resource "aws_iam_policy" "indexer_instance_policy" {
|
|
|
name = "indexer_instance_policy"
|
|
|
path = "/launchroles/"
|
|
|
description = "This policy allows indexer-specific functions"
|
|
|
- policy = data.aws_iam_policy_document.instance_policy_doc.json
|
|
|
+ policy = data.aws_iam_policy_document.indexer_instance_policy_doc.json
|
|
|
}
|
|
|
|
|
|
-data "aws_iam_policy_document" "instance_policy_doc" {
|
|
|
+data "aws_iam_policy_document" "indexer_instance_policy_doc" {
|
|
|
# Allow copying to S3 for frozen
|
|
|
# Allow use of S3 for SmartStore
|
|
|
statement {
|
|
@@ -70,22 +113,9 @@ data "aws_iam_policy_document" "instance_policy_doc" {
|
|
|
]
|
|
|
resources = [ "*" ]
|
|
|
}
|
|
|
-
|
|
|
- statement {
|
|
|
- sid = "AllowAssumeRoleToSplunkApps"
|
|
|
- effect = "Allow"
|
|
|
-
|
|
|
- actions = [
|
|
|
- "sts:AssumeRole"
|
|
|
- ]
|
|
|
-
|
|
|
- resources = [
|
|
|
- "arn:${ var.aws_partition }:iam::${ var.aws_account_id }:role/service/splunk-apps-s3"
|
|
|
- ]
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
resource "aws_iam_role_policy_attachment" "indexer_instance_policy_attach" {
|
|
|
- role = module.instance_profile.role_id
|
|
|
- policy_arn = aws_iam_policy.instance_policy.arn
|
|
|
+ role = aws_iam_role.indexer_instance_role.name
|
|
|
+ policy_arn = aws_iam_policy.indexer_instance_policy.arn
|
|
|
}
|