Skip to content

Commit bf51e19

Browse files
authored
Merge pull request #6 from tomarv2/develop
Pulling refs/heads/develop into main
2 parents a34e3d9 + cdd53ae commit bf51e19

File tree

14 files changed

+139
-324
lines changed

14 files changed

+139
-324
lines changed

.github/workflows/pr-lint.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: PR lint
2+
3+
on:
4+
pull_request:
5+
types: ['opened', 'edited', 'reopened', 'synchronize']
6+
7+
jobs:
8+
pr-lint:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: seferov/pr-lint-action@master
12+
with:
13+
title-regex: '^((Pulling|Update from) refs\/heads\/|(\[tf (plan|apply|destroy|status)\]|\[non tf\])\s(feat|fix|build|chore|ci|docs|style|refactor|perf|test)(\!?): (.{3,250})[^\s*]$)'
14+
github-token: ${{ secrets.GITHUB_TOKEN }}
15+
auto-close-message: 'Closing this pull request since the title does not match %pattern% pattern. Please fix the title and re-open the pull request.'

.github/workflows/state-actions.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/antonbabenko/pre-commit-terraform
3-
rev: v1.64.0
3+
rev: v1.76.0
44
hooks:
55
- id: terraform_fmt
66
- id: terraform_tflint
@@ -12,14 +12,13 @@ repos:
1212
- '--args=--only=terraform_documented_outputs'
1313
- '--args=--only=terraform_documented_variables'
1414
- '--args=--only=terraform_typed_variables'
15-
#- '--args=--only=terraform_module_pinned_source'
1615
- '--args=--only=terraform_naming_convention'
1716
- '--args=--only=terraform_required_providers'
1817
- '--args=--only=terraform_standard_module_structure'
1918
- '--args=--only=terraform_workspace_remote'
2019

2120
- repo: https://github.com/pre-commit/pre-commit-hooks
22-
rev: v4.1.0
21+
rev: v4.3.0
2322
hooks:
2423
- id: trailing-whitespace
2524
- id: end-of-file-fixer
@@ -31,7 +30,7 @@ repos:
3130
- id: requirements-txt-fixer
3231

3332
- repo: https://github.com/bridgecrewio/checkov.git
34-
rev: '2.0.914'
33+
rev: '2.1.280'
3534
hooks:
3635
- id: checkov
3736
verbose: true

README.md

Lines changed: 11 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
### Versions
2626

2727
- Module tested for Terraform 1.0.1.
28-
- AWS provider version [3.74](https://registry.terraform.io/providers/hashicorp/aws/latest)
28+
- AWS provider version [4.35](https://registry.terraform.io/providers/hashicorp/aws/latest)
2929
- `main` branch: Provider versions not pinned to keep up with Terraform releases
3030
- `tags` releases: Tags are pinned with versions (use <a href="https://github.com/tomarv2/terraform-aws-elasticache/tags" alt="GitHub tag">
3131
<img src="https://img.shields.io/github/v/tag/tomarv2/terraform-aws-elasticache" /></a> in your releases)
@@ -44,7 +44,7 @@ terraform destroy -var='teamid=tryme' -var='prjid=project1'
4444

4545
#### Option 2:
4646

47-
##### Recommended method (stores remote state in S3 using `prjid` and `teamid` to create directory structure):
47+
##### Recommended method (stores remote state in remote backend(S3, Azure storage, or Google bucket) using `prjid` and `teamid` to create directory structure):
4848

4949
- Create python 3.8+ virtual environment
5050
```
@@ -91,43 +91,6 @@ tf -c=aws destroy -var='teamid=foo' -var='prjid=bar'
9191
```
9292

9393
**Note:** Read more on [tfremote](https://github.com/tomarv2/tfremote)
94-
```
95-
terraform {
96-
required_version = ">= 1.0.1"
97-
required_providers {
98-
aws = {
99-
version = "~> 3.74"
100-
}
101-
}
102-
}
103-
104-
provider "aws" {
105-
region = var.region
106-
}
107-
108-
module "redis" {
109-
source = "../"
110-
111-
deploy_redis = true
112-
deploy_redis_parameter_group = true
113-
114-
security_group_ids = [module.security_group.security_group_id]
115-
# ----------------------------------------------
116-
# Note: Do not change teamid and prjid once set.
117-
teamid = var.teamid
118-
prjid = var.prjid
119-
}
120-
121-
module "security_group" {
122-
source = "git::git@github.com:tomarv2/terraform-aws-security-group.git?ref=v0.0.6"
123-
124-
deploy_security_group = true
125-
126-
service_ports = [6379]
127-
teamid = var.teamid
128-
prjid = var.prjid
129-
}
130-
```
13194

13295
Please refer to examples directory [link](examples) for references.
13396

@@ -141,13 +104,13 @@ Please refer to examples directory [link](examples) for references.
141104
| Name | Version |
142105
|------|---------|
143106
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.1 |
144-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 3.74 |
107+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 4.35 |
145108

146109
## Providers
147110

148111
| Name | Version |
149112
|------|---------|
150-
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 3.74 |
113+
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 4.35 |
151114

152115
## Modules
153116

@@ -159,44 +122,23 @@ Please refer to examples directory [link](examples) for references.
159122

160123
| Name | Type |
161124
|------|------|
162-
| [aws_elasticache_cluster.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster) | resource |
163-
| [aws_elasticache_parameter_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_parameter_group) | resource |
164-
| [aws_elasticache_subnet_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_subnet_group) | resource |
125+
| [aws_elasticache_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster) | resource |
126+
| [aws_elasticache_parameter_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_parameter_group) | resource |
165127
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
166128
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |
167129

168130
## Inputs
169131

170132
| Name | Description | Type | Default | Required |
171133
|------|-------------|------|---------|:--------:|
172-
| <a name="input_apply_immediately"></a> [apply\_immediately](#input\_apply\_immediately) | Specifies whether any database modifications are applied immediately, or during the next maintenance window. Default is false. | `bool` | `true` | no |
173-
| <a name="input_availability_zone"></a> [availability\_zone](#input\_availability\_zone) | The Availability Zone for the cache cluster. If you want to create cache nodes in multi-az, use preferred\_availability\_zones instead. Default: System chosen Availability Zone. Changing this value will re-create the resource. | `string` | `null` | no |
174-
| <a name="input_az_mode"></a> [az\_mode](#input\_az\_mode) | (Memcached only) Specifies whether the nodes in this Memcached node group are created in a single Availability Zone or created across multiple Availability Zones in the cluster's region. Valid values for this parameter are single-az or cross-az, default is single-az. If you want to choose cross-az, num\_cache\_nodes must be greater than 1. | `string` | `null` | no |
175-
| <a name="input_cache_nodes"></a> [cache\_nodes](#input\_cache\_nodes) | The initial number of cache nodes that the cache cluster will have. For Redis, this value must be 1. For Memcache, this value must be between 1 and 20. | `number` | `1` | no |
176-
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | Group identifier. ElastiCache converts this name to lowercase | `string` | `null` | no |
177-
| <a name="input_cluster_mode_enabled"></a> [cluster\_mode\_enabled](#input\_cluster\_mode\_enabled) | Flag to enable/disable creation of a native redis cluster. `automatic_failover_enabled` must be set to `true`. Only 1 `cluster_mode` block is allowed | `bool` | `false` | no |
178-
| <a name="input_deploy_redis"></a> [deploy\_redis](#input\_deploy\_redis) | Feature flag, true or false | `bool` | `true` | no |
179-
| <a name="input_deploy_redis_parameter_group"></a> [deploy\_redis\_parameter\_group](#input\_deploy\_redis\_parameter\_group) | Feature flag, true or false | `bool` | `true` | no |
180-
| <a name="input_engine"></a> [engine](#input\_engine) | Name of the cache engine to be used for this cache cluster. Valid values for this parameter are memcached or redis. | `string` | `"redis"` | no |
181-
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | Version of engine | `string` | `"5.0.6"` | no |
182-
| <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` | `"mon:10:30-mon:11:30"` | no |
183-
| <a name="input_node_type"></a> [node\_type](#input\_node\_type) | The compute and memory capacity of the nodes | `string` | `"cache.t2.micro"` | no |
184-
| <a name="input_notification_topic_arn"></a> [notification\_topic\_arn](#input\_notification\_topic\_arn) | An Amazon Resource Name (ARN) of an SNS topic to send ElastiCache notifications to. Example: arn:aws:sns:us-east-1:012345678999:my\_sns\_topic. | `string` | `null` | no |
185-
| <a name="input_parameter"></a> [parameter](#input\_parameter) | A list of Redis parameters to apply. Note that parameters may differ from one Redis family to another | <pre>list(object({<br> name = string<br> value = string<br> }))</pre> | `[]` | no |
186-
| <a name="input_parameter_group_family"></a> [parameter\_group\_family](#input\_parameter\_group\_family) | The family of the ElastiCache parameter group | `string` | `"redis5.0"` | no |
187-
| <a name="input_port"></a> [port](#input\_port) | The port number on which each of the cache nodes will accept connections. For Memcache the default is 11211, and for Redis the default port is 6379. | `number` | `6379` | no |
188-
| <a name="input_prjid"></a> [prjid](#input\_prjid) | Name of the project/stack e.g: mystack, nifieks, demoaci. Should not be changed after running 'tf apply' | `string` | n/a | yes |
189-
| <a name="input_security_group_ids"></a> [security\_group\_ids](#input\_security\_group\_ids) | One or more VPC security groups associated with the cache cluster | `string` | n/a | yes |
190-
| <a name="input_snapshot_arns"></a> [snapshot\_arns](#input\_snapshot\_arns) | A single-element string list containing an Amazon Resource Name (ARN) of a Redis RDB snapshot file stored in Amazon S3. Example: arn:aws:s3:::my\_bucket/snapshot1.rdb | `list(any)` | <pre>[<br> ""<br>]</pre> | no |
191-
| <a name="input_snapshot_retention_limit"></a> [snapshot\_retention\_limit](#input\_snapshot\_retention\_limit) | Number of days snapshot image will be retained | `number` | `5` | no |
192-
| <a name="input_snapshot_window"></a> [snapshot\_window](#input\_snapshot\_window) | Daily time range (in UTC) during which ElastiCache will begin taking a daily snapshot of your cache cluster. Example: 05:00-09:00. | `string` | `""` | no |
193-
| <a name="input_teamid"></a> [teamid](#input\_teamid) | Name of the team/group e.g. devops, dataengineering. Should not be changed after running 'tf apply' | `string` | n/a | yes |
134+
| <a name="input_config"></a> [config](#input\_config) | Redis configuration | `map(any)` | `{}` | no |
135+
| <a name="input_extra_tags"></a> [extra\_tags](#input\_extra\_tags) | Additional tags to associate | `map(string)` | `{}` | no |
194136

195137
## Outputs
196138

197139
| Name | Description |
198140
|------|-------------|
199-
| <a name="output_aws_elasticache_parameter_group"></a> [aws\_elasticache\_parameter\_group](#output\_aws\_elasticache\_parameter\_group) | Elasticache Parameter Group |
200-
| <a name="output_elasticache_cluster_address"></a> [elasticache\_cluster\_address](#output\_elasticache\_cluster\_address) | Elasticache Cluster address |
201-
| <a name="output_elasticache_id"></a> [elasticache\_id](#output\_elasticache\_id) | Elasticache Id |
141+
| <a name="output_cluster_address"></a> [cluster\_address](#output\_cluster\_address) | Elasticache Cluster address |
142+
| <a name="output_cluster_id"></a> [cluster\_id](#output\_cluster\_id) | Elasticache Id |
143+
| <a name="output_parameter_group"></a> [parameter\_group](#output\_parameter\_group) | Elasticache Parameter Group |
202144
<!-- END_TF_DOCS -->

examples/main.tf

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,59 @@ terraform {
22
required_version = ">= 1.0.1"
33
required_providers {
44
aws = {
5-
version = "~> 3.74"
5+
version = "~> 4.35"
66
}
77
}
88
}
99

1010
provider "aws" {
11-
region = var.region
11+
region = "us-west-2"
1212
}
1313

1414
module "redis" {
1515
source = "../"
1616

17-
deploy_redis = true
18-
deploy_redis_parameter_group = true
19-
20-
security_group_ids = [module.security_group.security_group_id]
21-
# ----------------------------------------------
22-
# Note: Do not change teamid and prjid once set.
23-
teamid = var.teamid
24-
prjid = var.prjid
17+
config = {
18+
demo = {
19+
security_group_ids = module.security_group.id
20+
engine_version = "6.2"
21+
family = "redis6.x"
22+
parameter_group_config = {
23+
activerehashing = {
24+
value = "yes"
25+
}
26+
}
27+
}
28+
}
2529
}
2630

2731
module "security_group" {
28-
source = "git::git@github.com:tomarv2/terraform-aws-security-group.git?ref=v0.0.6"
29-
30-
deploy_security_group = true
31-
32-
service_ports = [6379]
33-
teamid = var.teamid
34-
prjid = var.prjid
32+
#source = "git::git@github.com:tomarv2/terraform-aws-security-group.git?ref=v0.0.12"
33+
source = "../../terraform-aws-security-group"
34+
config = {
35+
demo_redis = {
36+
all_ingress_rules = [
37+
{
38+
description = "https"
39+
type = "ingress"
40+
from_port = 6379
41+
protocol = "tcp"
42+
to_port = 6379
43+
self = true
44+
cidr_blocks = []
45+
}
46+
]
47+
all_egress_rules = [
48+
{
49+
description = "outbound traffic"
50+
from_port = 0
51+
protocol = "-1"
52+
type = "egress"
53+
to_port = 0
54+
self = false
55+
cidr_blocks = ["0.0.0.0/0"]
56+
}
57+
]
58+
}
59+
}
3560
}

examples/outputs.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
output "elasticache_id" {
1+
output "cluster_id" {
2+
value = module.redis.cluster_id
23
description = "Elasticache Id"
3-
value = module.redis.elasticache_id
44
}
55

6-
output "elasticache_cluster_address" {
6+
output "cluster_address" {
7+
value = module.redis.cluster_address
78
description = "Elasticache Cluster address"
8-
value = module.redis.elasticache_cluster_address
99
}
1010

11-
output "aws_elasticache_parameter_group" {
11+
output "parameter_group" {
1212
description = "Elasticache Parameter Group"
13-
value = module.redis.aws_elasticache_parameter_group
13+
value = module.redis.parameter_group
1414
}
1515

1616
output "security_group_id" {
1717
description = "Security group Id"
18-
value = module.security_group.security_group_id
18+
value = module.security_group.id
1919
}

examples/variables.tf

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)