Skip to content

Commit

Permalink
feat: Opensearch Domain ip_address_type, Cloudwatch `log_group_clas…
Browse files Browse the repository at this point in the history
…s`, and `skip_destroy` (#13)
  • Loading branch information
magreenbaum authored Jun 19, 2024
1 parent f479250 commit b7ab787
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 14 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.40 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.54 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.40 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.54 |

## Modules

Expand Down Expand Up @@ -190,8 +190,10 @@ No modules.
| <a name="input_advanced_options"></a> [advanced\_options](#input\_advanced\_options) | Key-value string pairs to specify advanced configuration options. Note that the values for these configuration options must be strings (wrapped in quotes) or they may be wrong and cause a perpetual diff, causing Terraform to want to recreate your Elasticsearch domain on every apply | `map(string)` | `{}` | no |
| <a name="input_advanced_security_options"></a> [advanced\_security\_options](#input\_advanced\_security\_options) | Configuration block for [fine-grained access control](https://docs.aws.amazon.com/elasticsearch-service/latest/developerguide/fgac.html) | `any` | <pre>{<br> "anonymous_auth_enabled": false,<br> "enabled": true<br>}</pre> | no |
| <a name="input_auto_tune_options"></a> [auto\_tune\_options](#input\_auto\_tune\_options) | Configuration block for the Auto-Tune options of the domain | `any` | <pre>{<br> "desired_state": "ENABLED",<br> "rollback_on_disable": "NO_ROLLBACK"<br>}</pre> | no |
| <a name="input_cloudwatch_log_group_class"></a> [cloudwatch\_log\_group\_class](#input\_cloudwatch\_log\_group\_class) | Specified the log class of the log group. Possible values are: STANDARD or INFREQUENT\_ACCESS | `string` | `null` | no |
| <a name="input_cloudwatch_log_group_kms_key_id"></a> [cloudwatch\_log\_group\_kms\_key\_id](#input\_cloudwatch\_log\_group\_kms\_key\_id) | If a KMS Key ARN is set, this key will be used to encrypt the corresponding log group. Please be sure that the KMS Key has an appropriate key policy (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/encrypt-log-data-kms.html) | `string` | `null` | no |
| <a name="input_cloudwatch_log_group_retention_in_days"></a> [cloudwatch\_log\_group\_retention\_in\_days](#input\_cloudwatch\_log\_group\_retention\_in\_days) | Number of days to retain log events | `number` | `60` | no |
| <a name="input_cloudwatch_log_group_skip_destroy"></a> [cloudwatch\_log\_group\_skip\_destroy](#input\_cloudwatch\_log\_group\_skip\_destroy) | Set to true if you do not wish the log group (and any logs it may contain) to be deleted at destroy time, and instead just remove the log group from the Terraform state | `bool` | `null` | no |
| <a name="input_cloudwatch_log_resource_policy_name"></a> [cloudwatch\_log\_resource\_policy\_name](#input\_cloudwatch\_log\_resource\_policy\_name) | Name of the resource policy for OpenSearch to log to CloudWatch | `string` | `null` | no |
| <a name="input_cluster_config"></a> [cluster\_config](#input\_cluster\_config) | Configuration block for the cluster of the domain | `any` | <pre>{<br> "dedicated_master_enabled": true<br>}</pre> | no |
| <a name="input_cognito_options"></a> [cognito\_options](#input\_cognito\_options) | Configuration block for authenticating Kibana with Cognito | `any` | `{}` | no |
Expand All @@ -207,6 +209,7 @@ No modules.
| <a name="input_enable_access_policy"></a> [enable\_access\_policy](#input\_enable\_access\_policy) | Determines whether an access policy will be applied to the domain | `bool` | `true` | no |
| <a name="input_encrypt_at_rest"></a> [encrypt\_at\_rest](#input\_encrypt\_at\_rest) | Configuration block for encrypting at rest | `any` | <pre>{<br> "enabled": true<br>}</pre> | no |
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | Version of the OpenSearch engine to use | `string` | `null` | no |
| <a name="input_ip_address_type"></a> [ip\_address\_type](#input\_ip\_address\_type) | The IP address type for the endpoint. Valid values are ipv4 and dualstack | `string` | `null` | no |
| <a name="input_log_publishing_options"></a> [log\_publishing\_options](#input\_log\_publishing\_options) | Configuration block for publishing slow and application logs to CloudWatch Logs. This block can be declared multiple times, for each log\_type, within the same resource | `any` | <pre>[<br> {<br> "log_type": "INDEX_SLOW_LOGS"<br> },<br> {<br> "log_type": "SEARCH_SLOW_LOGS"<br> }<br>]</pre> | no |
| <a name="input_node_to_node_encryption"></a> [node\_to\_node\_encryption](#input\_node\_to\_node\_encryption) | Configuration block for node-to-node encryption options | `any` | <pre>{<br> "enabled": true<br>}</pre> | no |
| <a name="input_off_peak_window_options"></a> [off\_peak\_window\_options](#input\_off\_peak\_window\_options) | Configuration to add Off Peak update options | `any` | <pre>{<br> "enabled": true,<br> "off_peak_window": {<br> "hours": 7<br> }<br>}</pre> | no |
Expand Down
4 changes: 2 additions & 2 deletions examples/collection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ Note that this example may create resources which will incur monetary charges on
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.40 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.54 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.40 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.54 |

## Modules

Expand Down
2 changes: 1 addition & 1 deletion examples/collection/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.40"
version = ">= 5.54"
}
}
}
4 changes: 2 additions & 2 deletions examples/complete/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ Note that this example may create resources which will incur monetary charges on
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.40 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.54 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.40 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.54 |

## Modules

Expand Down
7 changes: 7 additions & 0 deletions examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ module "opensearch" {
{ log_type = "SEARCH_SLOW_LOGS" },
]

ip_address_type = "dualstack"

node_to_node_encryption = {
enabled = true
}
Expand Down Expand Up @@ -172,5 +174,10 @@ module "vpc" {
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k)]
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 10)]

enable_ipv6 = true

public_subnet_ipv6_prefixes = [0, 1, 2]
private_subnet_ipv6_prefixes = [3, 4, 5]

tags = local.tags
}
2 changes: 1 addition & 1 deletion examples/complete/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.40"
version = ">= 5.54"
}
}
}
5 changes: 4 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ resource "aws_opensearch_domain" "this" {
}
}

engine_version = var.engine_version
engine_version = var.engine_version
ip_address_type = var.ip_address_type

dynamic "log_publishing_options" {
for_each = { for opt in var.log_publishing_options : opt.log_type => opt }
Expand Down Expand Up @@ -402,6 +403,8 @@ resource "aws_cloudwatch_log_group" "this" {
name = try(each.value.log_group_name, "/aws/opensearch/${var.domain_name}/${each.key}")
retention_in_days = try(each.value.log_group_retention_in_days, var.cloudwatch_log_group_retention_in_days)
kms_key_id = try(each.value.log_group_kms_key_id, var.cloudwatch_log_group_kms_key_id)
skip_destroy = try(each.value.log_group_skip_destroy, var.cloudwatch_log_group_skip_destroy)
log_group_class = try(each.value.log_group_class, var.cloudwatch_log_group_class)

tags = merge(local.tags, try(each.value.log_group_tags, {}))
}
Expand Down
4 changes: 2 additions & 2 deletions modules/collection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ Examples codified under the [`examples`](https://github.com/terraform-aws-module
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.40 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.54 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.40 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.54 |

## Modules

Expand Down
2 changes: 1 addition & 1 deletion modules/collection/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.40"
version = ">= 5.54"
}
}
}
18 changes: 18 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ variable "engine_version" {
default = null
}

variable "ip_address_type" {
description = "The IP address type for the endpoint. Valid values are ipv4 and dualstack"
type = string
default = null
}

variable "log_publishing_options" {
description = "Configuration block for publishing slow and application logs to CloudWatch Logs. This block can be declared multiple times, for each log_type, within the same resource"
type = any
Expand Down Expand Up @@ -241,6 +247,18 @@ variable "cloudwatch_log_group_kms_key_id" {
default = null
}

variable "cloudwatch_log_group_skip_destroy" {
description = "Set to true if you do not wish the log group (and any logs it may contain) to be deleted at destroy time, and instead just remove the log group from the Terraform state"
type = bool
default = null
}

variable "cloudwatch_log_group_class" {
description = "Specified the log class of the log group. Possible values are: STANDARD or INFREQUENT_ACCESS"
type = string
default = null
}

variable "create_cloudwatch_log_resource_policy" {
description = "Determines whether a resource policy will be created for OpenSearch to log to CloudWatch"
type = bool
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.40"
version = ">= 5.54"
}
}
}
5 changes: 4 additions & 1 deletion wrappers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ module "wrapper" {
desired_state = "ENABLED"
rollback_on_disable = "NO_ROLLBACK"
})
cloudwatch_log_group_class = try(each.value.cloudwatch_log_group_class, var.defaults.cloudwatch_log_group_class, null)
cloudwatch_log_group_kms_key_id = try(each.value.cloudwatch_log_group_kms_key_id, var.defaults.cloudwatch_log_group_kms_key_id, null)
cloudwatch_log_group_retention_in_days = try(each.value.cloudwatch_log_group_retention_in_days, var.defaults.cloudwatch_log_group_retention_in_days, 60)
cloudwatch_log_group_skip_destroy = try(each.value.cloudwatch_log_group_skip_destroy, var.defaults.cloudwatch_log_group_skip_destroy, null)
cloudwatch_log_resource_policy_name = try(each.value.cloudwatch_log_resource_policy_name, var.defaults.cloudwatch_log_resource_policy_name, null)
cluster_config = try(each.value.cluster_config, var.defaults.cluster_config, {
dedicated_master_enabled = true
Expand All @@ -43,7 +45,8 @@ module "wrapper" {
encrypt_at_rest = try(each.value.encrypt_at_rest, var.defaults.encrypt_at_rest, {
enabled = true
})
engine_version = try(each.value.engine_version, var.defaults.engine_version, null)
engine_version = try(each.value.engine_version, var.defaults.engine_version, null)
ip_address_type = try(each.value.ip_address_type, var.defaults.ip_address_type, null)
log_publishing_options = try(each.value.log_publishing_options, var.defaults.log_publishing_options, [
{ log_type = "INDEX_SLOW_LOGS" },
{ log_type = "SEARCH_SLOW_LOGS" },
Expand Down

0 comments on commit b7ab787

Please sign in to comment.