-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from CBIIT/standard-opensearch
Standardizing OpenSearch Implementations
- Loading branch information
Showing
10 changed files
with
550 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,94 @@ | ||
data "aws_region" "region" {} | ||
data "aws_caller_identity" "current" {} | ||
|
||
data "aws_caller_identity" "caller" {} | ||
data "aws_iam_policy_document" "logs" { | ||
count = var.create_cloudwatch_log_policy ? 1 : 0 | ||
|
||
data "aws_iam_policy_document" "os" { | ||
statement { | ||
effect = "Allow" | ||
actions = [ | ||
"logs:PutLogEvents", | ||
"logs:PutLogEventsBatch", | ||
"logs:CreateLogStream" | ||
] | ||
principals { | ||
type = "Service" | ||
identifiers = ["es.amazonaws.com"] | ||
} | ||
resources = [ | ||
aws_cloudwatch_log_group.os.arn, | ||
"${aws_cloudwatch_log_group.os.arn}:*" | ||
"${aws_cloudwatch_log_group.this[0].arn}", | ||
"${aws_cloudwatch_log_group.this[0].arn}:*" | ||
] | ||
} | ||
} | ||
|
||
data "aws_iam_policy_document" "access_policy" { | ||
count = var.create_access_policies ? 1 : 0 | ||
|
||
statement { | ||
effect = "Allow" | ||
actions = [ | ||
"es:ESHttpPut", | ||
"es:ESHttpPost", | ||
"es:ESHttpPatch", | ||
"es:ESHttpHead", | ||
"es:ESHttpGet", | ||
"es:ESHttpDelete" | ||
] | ||
principals { | ||
type = "AWS" | ||
identifiers = ["*"] | ||
} | ||
resources = ["${aws_opensearch_domain.this.arn}/*"] | ||
} | ||
} | ||
|
||
data "aws_iam_policy_document" "trust" { | ||
count = var.create_snapshot_role ? 1 : 0 | ||
|
||
statement { | ||
effect = "Allow" | ||
actions = ["sts:AssumeRole"] | ||
|
||
principals { | ||
type = "Service" | ||
identifiers = ["es.amazonaws.com"] | ||
} | ||
} | ||
} | ||
|
||
data "aws_iam_policy_document" "snapshot" { | ||
count = var.create_snapshot_role ? 1 : 0 | ||
|
||
statement { | ||
effect = "Allow" | ||
actions = ["s3:ListBucket"] | ||
resources = [var.s3_snapshot_bucket_arn] | ||
} | ||
|
||
statement { | ||
effect = "Allow" | ||
actions = [ | ||
"s3:GetObject", | ||
"s3:PutObject", | ||
"s3:DeleteObject" | ||
] | ||
resources = ["${var.s3_snapshot_bucket_arn}/*"] | ||
} | ||
|
||
statement { | ||
effect = "Allow" | ||
actions = [ | ||
"iam:PassRole", | ||
"iam:GetRole" | ||
] | ||
resources = [aws_iam_role.snapshot[0].arn] | ||
} | ||
|
||
statement { | ||
effect = "Allow" | ||
actions = ["es:ESHttpPut"] | ||
resources = [ | ||
"${aws_opensearch_domain.this.arn}/*", | ||
"${aws_opensearch_domain.this.arn}/*/*" | ||
] | ||
} | ||
} |
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions
11
terraform/modules/opensearch/examples/basic-configuration/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module "opensearch" { | ||
source = "../.." | ||
|
||
attach_permissions_boundary = true | ||
cluster_tshirt_size = "md" | ||
engine_version = "OpenSearch_2.11" | ||
resource_prefix = "program-tier-app" | ||
s3_snapshot_bucket_arn = "arn:aws:s3:::basic-example-snapshot-bucket" | ||
subnet_ids = ["subnet-01234567891011121", "subnet-abcdefghijklmnopq"] | ||
vpc_id = "vpc-01234567891011121" | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,33 @@ | ||
locals { | ||
domain_name = "${var.resource_prefix}-opensearch" | ||
subnets = var.multi_az_enabled ? var.opensearch_subnet_ids : [ var.opensearch_subnet_ids[0]] | ||
sg_description = "The security group regulating network access to the OpenSearch cluster" | ||
log_retention = var.env == "dev" || var.env == "qa" ? 30 : 90 | ||
now = timestamp() | ||
} | ||
access_policies = var.create_access_policies ? data.aws_iam_policy_document.access_policy[0].json : var.access_policies | ||
permissions_boundary = var.attach_permissions_boundary ? "arn:aws:iam::${data.aws_caller_identity.current.account_id}:policy/PermissionBoundary_PowerUser" : null | ||
security_group_ids = var.create_security_group ? aws_security_group.this[0].id : var.security_group_ids | ||
custom_instance_type = var.instance_type == null && var.cluster_tshirt_size != null ? lookup(local.instance_type_lookup, var.cluster_tshirt_size, null) : var.instance_type | ||
custom_instance_count = var.instance_count == null ? 1 : var.instance_count | ||
custom_volume_size = var.volume_size == null && var.cluster_tshirt_size != null ? lookup(local.volume_size_lookup, var.cluster_tshirt_size, null) : var.volume_size | ||
|
||
|
||
instance_type_lookup = { | ||
xs = "t3.small.search" | ||
sm = "t3.medium.search" | ||
md = "m6g.large.search" | ||
lg = "m6g.xlarge.search" | ||
xl = "m6g.2xlarge.search" | ||
} | ||
|
||
volume_size_lookup = { | ||
xs = 10 | ||
sm = 20 | ||
md = 40 | ||
lg = 80 | ||
xl = 160 | ||
} | ||
|
||
outputs = { | ||
security_group_arn = var.create_security_group ? aws_security_group.this[0].arn : "A Security Group was not created" | ||
security_group_id = var.create_security_group ? aws_security_group.this[0].id : "A Security Group was not created" | ||
role_arn = var.create_snapshot_role ? aws_iam_role.snapshot[0].arn : "A Snapshot Role was not created" | ||
role_id = var.create_snapshot_role ? aws_iam_role.snapshot[0].id : "A Snapshot Role was not created" | ||
role_name = var.create_snapshot_role ? aws_iam_role.snapshot[0].name : "A Snapshot Role was not created" | ||
} | ||
} |
Oops, something went wrong.