Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Os module #206

Merged
merged 35 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
536b4c6
commented access policy count
michael-fleming Jun 14, 2024
e61198c
updated policy reference
michael-fleming Jun 14, 2024
33c0488
updated arns in data
michael-fleming Jun 14, 2024
c57f096
debug
michael-fleming Jun 14, 2024
8c7c9dc
debug
michael-fleming Jun 14, 2024
47af9f2
commented update options
michael-fleming Jun 14, 2024
8bb55d7
commented dashboard endpoint
michael-fleming Jun 17, 2024
06d88c9
fixed sg error
michael-fleming Jun 17, 2024
34eed0f
debug
michael-fleming Jun 17, 2024
781842e
debug
michael-fleming Jun 17, 2024
1216a7c
debug
michael-fleming Jun 17, 2024
a2de591
debug
michael-fleming Jun 17, 2024
3a0b64f
debug
michael-fleming Jun 17, 2024
69edc53
debug
michael-fleming Jun 17, 2024
6609bb3
updates for aws 5.x provider
michael-fleming Jun 17, 2024
0545cd0
debug
michael-fleming Jun 17, 2024
576cfbb
debug
michael-fleming Jun 17, 2024
f46f28e
updated node count
michael-fleming Jun 18, 2024
20bad8d
uncommented update block
michael-fleming Jun 18, 2024
a2f5614
added local for subnet ids
michael-fleming Jun 20, 2024
2c8c4d0
updated locals
michael-fleming Jun 20, 2024
106960c
updated to list
michael-fleming Jun 20, 2024
0e2e021
updated auto tune options
michael-fleming Jun 20, 2024
e6b2b6c
updated function
michael-fleming Jun 20, 2024
9e4cbcb
updated local for autotune
michael-fleming Jun 20, 2024
0233d59
updated zone awareness
michael-fleming Jun 20, 2024
3294a6f
reverted zone awareness
michael-fleming Jun 20, 2024
43cee75
removed debug
michael-fleming Jun 20, 2024
57e6e7f
updated s3 policy
michael-fleming Jun 20, 2024
332f0e9
reverted debug
michael-fleming Jun 20, 2024
fba5be4
terraform-docs: automated action
github-actions[bot] Jun 24, 2024
5aeb917
added aws provider version
michael-fleming Jun 25, 2024
601d916
terraform-docs: automated action
github-actions[bot] Jun 25, 2024
b9c1603
updated required AWS provider version
michael-fleming Jun 26, 2024
0ba467c
terraform-docs: automated action
github-actions[bot] Jun 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions terraform/modules/cloudfront/kinesis.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ resource "aws_iam_role_policy_attachment" "firehose_policy_attachment" {

resource "aws_kinesis_firehose_delivery_stream" "firehose_stream" {
name = "aws-waf-logs-${var.resource_prefix}-kinesis-firehose-stream"
destination = "s3"
s3_configuration {
destination = "extended_s3"

extended_s3_configuration {
role_arn = aws_iam_role.firehose_role.arn
bucket_arn = aws_s3_bucket.kinesis_log.arn
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ resource "aws_kinesis_firehose_delivery_stream" "kinesis" {
request_configuration {
content_encoding = var.content_encoding
}
}

s3_configuration {
role_arn = var.role_arn
bucket_arn = var.s3_bucket_arn
prefix = var.s3_object_prefix
error_output_prefix = var.s3_error_output_prefix
buffer_size = var.buffer_size
buffer_interval = var.buffer_interval
compression_format = var.s3_compression_format
s3_configuration {
role_arn = var.role_arn
bucket_arn = var.s3_bucket_arn
prefix = var.s3_object_prefix
error_output_prefix = var.s3_error_output_prefix
#buffer_size = var.buffer_size
#buffer_interval = var.buffer_interval
compression_format = var.s3_compression_format
}
}
}

Expand Down
1 change: 1 addition & 0 deletions terraform/modules/opensearch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ No modules.
| [aws_iam_policy_document.logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.snapshot](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.trust](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |

## Inputs

Expand Down
8 changes: 5 additions & 3 deletions terraform/modules/opensearch/data.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
data "aws_region" "current" {}

data "aws_caller_identity" "current" {}

data "aws_iam_policy_document" "logs" {
Expand Down Expand Up @@ -37,7 +39,7 @@ data "aws_iam_policy_document" "access_policy" {
type = "AWS"
identifiers = ["*"]
}
resources = ["${aws_opensearch_domain.this.arn}/*"]
resources = ["arn:aws:es:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:domain/${var.resource_prefix}-opensearch/*"]
}
}

Expand Down Expand Up @@ -87,8 +89,8 @@ data "aws_iam_policy_document" "snapshot" {
effect = "Allow"
actions = ["es:ESHttpPut"]
resources = [
"${aws_opensearch_domain.this.arn}/*",
"${aws_opensearch_domain.this.arn}/*/*"
"arn:aws:es:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:domain/${var.resource_prefix}-opensearch/*",
"arn:aws:es:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:domain/${var.resource_prefix}-opensearch/*/*"
]
}
}
4 changes: 3 additions & 1 deletion terraform/modules/opensearch/locals.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
locals {
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
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
auto_tune_enabled = var.auto_tune_enabled && !strcontains(local.custom_instance_type, "t2") && !strcontains(local.custom_instance_type, "t3") ? "ENABLED" : "DISABLED"
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
cluster_subnet_ids = local.custom_instance_count == 1 ? [tolist(var.subnet_ids)[0]] : var.subnet_ids


instance_type_lookup = {
Expand Down
12 changes: 6 additions & 6 deletions terraform/modules/opensearch/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ resource "aws_opensearch_domain" "this" {

cluster_config {
instance_type = local.custom_instance_type
instance_count = var.zone_awareness_enabled ? local.custom_instance_count : (local.custom_instance_count * 2)
instance_count = var.zone_awareness_enabled ? (local.custom_instance_count * 2) : local.custom_instance_count

zone_awareness_enabled = var.zone_awareness_enabled

Expand All @@ -19,7 +19,7 @@ resource "aws_opensearch_domain" "this" {
dedicated_master_type = var.dedicated_master_enabled ? local.custom_instance_type : null

warm_enabled = var.warm_enabled
warm_count = var.warm_enabled ? 2 : 0
warm_count = var.warm_enabled ? 2 : null
warm_type = var.warm_enabled ? local.custom_instance_type : null

cold_storage_options {
Expand All @@ -28,7 +28,7 @@ resource "aws_opensearch_domain" "this" {
}

auto_tune_options {
desired_state = var.auto_tune_enabled ? "ENABLED" : "DISABLED"
desired_state = local.auto_tune_enabled
}

domain_endpoint_options {
Expand All @@ -52,7 +52,7 @@ resource "aws_opensearch_domain" "this" {
content {
enabled = true
cloudwatch_log_group_arn = aws_cloudwatch_log_group.this[0].arn
log_type = each.value
log_type = log_publishing_options.value
}
}

Expand All @@ -69,7 +69,7 @@ resource "aws_opensearch_domain" "this" {
}

vpc_options {
subnet_ids = var.subnet_ids
subnet_ids = local.cluster_subnet_ids
security_group_ids = local.security_group_ids
}
}
Expand Down Expand Up @@ -109,7 +109,7 @@ resource "aws_cloudwatch_log_resource_policy" "this" {
count = var.create_cloudwatch_log_policy ? 1 : 0

policy_name = "${var.resource_prefix}-opensearch-log-policy"
policy_document = data.aws_iam_policy_document.logs.json
policy_document = data.aws_iam_policy_document.logs[0].json
}

resource "aws_iam_role" "snapshot" {
Expand Down