Skip to content

Commit adbfc9a

Browse files
iramelloAbdul Wahid
andauthored
Support Redis log delivery (#26)
* Initial commit * Fix dynamic * More changes * Updated Readme * Add documentation Co-authored-by: Abdul Wahid <abdul.wahid@umotif.com>
1 parent 67cf19b commit adbfc9a

File tree

7 files changed

+65
-8
lines changed

7 files changed

+65
-8
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.1.0
3+
rev: v4.2.0
44
hooks:
55
- id: check-added-large-files
66
args: ['--maxkb=500']
@@ -17,8 +17,8 @@ repos:
1717
- id: detect-aws-credentials
1818
args: ['--allow-missing-credentials']
1919
- id: trailing-whitespace
20-
- repo: git://github.com/antonbabenko/pre-commit-terraform
21-
rev: v1.64.0
20+
- repo: https://github.com/antonbabenko/pre-commit-terraform
21+
rev: v1.71.0
2222
hooks:
2323
- id: terraform_fmt
2424
- id: terraform_docs

CHANGELOG.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
<a name="unreleased"></a>
66
## [Unreleased]
77

8+
- Updated Readme
9+
- More changes
10+
- Fix dynamic
11+
- Initial commit
12+
13+
14+
<a name="3.0.0"></a>
15+
## [3.0.0] - 2022-03-09
16+
17+
- Upgrade module to be compatible with AWS Provider 4.0.0 ([#21](https://github.com/umotif-public/terraform-aws-elasticache-redis/issues/21))
818

919

1020
<a name="2.2.0"></a>
@@ -97,7 +107,8 @@ All notable changes to this project will be documented in this file.
97107
- Initial commit of docs
98108

99109

100-
[Unreleased]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/2.2.0...HEAD
110+
[Unreleased]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/3.0.0...HEAD
111+
[3.0.0]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/2.2.0...3.0.0
101112
[2.2.0]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/2.1.0...2.2.0
102113
[2.1.0]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/2.0.0...2.1.0
103114
[2.0.0]: https://github.com/umotif-public/terraform-aws-elasticache-redis/compare/1.5.0...2.0.0

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ A Terraform module to create an AWS Redis ElastiCache cluster
1616
```hcl
1717
module "redis" {
1818
source = "umotif-public/elasticache-redis/aws"
19-
version = "~> 2.1.0"
19+
version = "~> v3.0"
2020
2121
name_prefix = "core-example"
2222
number_cache_clusters = 2
@@ -50,6 +50,15 @@ module "redis" {
5050
}
5151
]
5252
53+
log_delivery_configuration = [
54+
{
55+
destination_type = "cloudwatch-logs"
56+
destination = "aws_cloudwatch_log_group.example.name"
57+
log_format = "json"
58+
log_type = "engine-log"
59+
}
60+
]
61+
5362
tags = {
5463
Project = "Test"
5564
}
@@ -72,14 +81,14 @@ Module managed by [Abdul Wahid](https://github.com/Ohid25) ([LinkedIn](https://w
7281
| Name | Version |
7382
|------|---------|
7483
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.14.11 |
75-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0.0 |
84+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.8.0 |
7685
| <a name="requirement_random"></a> [random](#requirement\_random) | >= 3.1.0 |
7786

7887
## Providers
7988

8089
| Name | Version |
8190
|------|---------|
82-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.0.0 |
91+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.8.0 |
8392
| <a name="provider_random"></a> [random](#provider\_random) | >= 3.1.0 |
8493

8594
## Modules
@@ -117,6 +126,7 @@ No modules.
117126
| <a name="input_ingress_cidr_blocks"></a> [ingress\_cidr\_blocks](#input\_ingress\_cidr\_blocks) | List of Ingress CIDR blocks. | `list(string)` | `[]` | no |
118127
| <a name="input_ingress_self"></a> [ingress\_self](#input\_ingress\_self) | Specify whether the security group itself will be added as a source to the ingress rule. | `bool` | `false` | no |
119128
| <a name="input_kms_key_id"></a> [kms\_key\_id](#input\_kms\_key\_id) | The ARN of the key that you wish to use if encrypting at rest. If not supplied, uses service managed encryption. Can be specified only if `at_rest_encryption_enabled = true` | `string` | `""` | no |
129+
| <a name="input_log_delivery_configuration"></a> [log\_delivery\_configuration](#input\_log\_delivery\_configuration) | Log Delivery configuration for the cluster. | <pre>list(object({<br> destination_type = string<br> destination = string<br> log_format = string<br> log_type = string<br> }))</pre> | `[]` | no |
120130
| <a name="input_maintenance_window"></a> [maintenance\_window](#input\_maintenance\_window) | Specifies the weekly time range for when maintenance on the cache cluster is performed. | `string` | `""` | no |
121131
| <a name="input_multi_az_enabled"></a> [multi\_az\_enabled](#input\_multi\_az\_enabled) | Specifies whether to enable Multi-AZ Support for the replication group. If true, `automatic_failover_enabled` must also be enabled. Defaults to false. | `string` | `false` | no |
122132
| <a name="input_name_prefix"></a> [name\_prefix](#input\_name\_prefix) | The replication group identifier. This parameter is stored as a lowercase string. | `string` | n/a | yes |

examples/redis-basic/main.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ module "redis" {
5858
}
5959
]
6060

61+
log_delivery_configuration = [
62+
{
63+
destination_type = "cloudwatch-logs"
64+
destination = "aws_cloudwatch_log_group.henrique.name"
65+
log_format = "json"
66+
log_type = "engine-log"
67+
}
68+
]
69+
6170
tags = {
6271
Project = "Test"
6372
}

main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,17 @@ resource "aws_elasticache_replication_group" "redis" {
3636
replicas_per_node_group = var.cluster_mode_enabled ? var.replicas_per_node_group : null
3737
num_node_groups = var.cluster_mode_enabled ? var.num_node_groups : null
3838

39+
dynamic "log_delivery_configuration" {
40+
for_each = var.log_delivery_configuration
41+
42+
content {
43+
destination_type = log_delivery_configuration.value.destination_type
44+
destination = log_delivery_configuration.value.destination
45+
log_format = log_delivery_configuration.value.log_format
46+
log_type = log_delivery_configuration.value.log_type
47+
}
48+
}
49+
3950
tags = merge(
4051
{
4152
"Name" = "${var.name_prefix}-redis"

variables.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,19 @@ variable "global_replication_group_id" {
192192
type = string
193193
default = null
194194
}
195+
196+
variable "log_delivery_configuration" {
197+
type = list(object({
198+
destination_type = string
199+
destination = string
200+
log_format = string
201+
log_type = string
202+
}))
203+
description = "Log Delivery configuration for the cluster."
204+
default = []
205+
206+
validation {
207+
condition = length(var.log_delivery_configuration) <= 2
208+
error_message = "You can set 2 targets at most for log delivery options."
209+
}
210+
}

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_version = ">= 0.14.11"
33

44
required_providers {
5-
aws = ">= 4.0.0"
5+
aws = ">= 4.8.0"
66
random = ">= 3.1.0"
77
}
88
}

0 commit comments

Comments
 (0)