Skip to content

Commit

Permalink
Merge pull request #6 from tomarv2/develop
Browse files Browse the repository at this point in the history
Pulling refs/heads/develop into main
  • Loading branch information
tomarv2 authored Nov 2, 2022
2 parents a34e3d9 + cdd53ae commit bf51e19
Show file tree
Hide file tree
Showing 14 changed files with 139 additions and 324 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/pr-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: PR lint

on:
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize']

jobs:
pr-lint:
runs-on: ubuntu-latest
steps:
- uses: seferov/pr-lint-action@master
with:
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*]$)'
github-token: ${{ secrets.GITHUB_TOKEN }}
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.'
32 changes: 0 additions & 32 deletions .github/workflows/state-actions.yml

This file was deleted.

7 changes: 3 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.64.0
rev: v1.76.0
hooks:
- id: terraform_fmt
- id: terraform_tflint
Expand All @@ -12,14 +12,13 @@ repos:
- '--args=--only=terraform_documented_outputs'
- '--args=--only=terraform_documented_variables'
- '--args=--only=terraform_typed_variables'
#- '--args=--only=terraform_module_pinned_source'
- '--args=--only=terraform_naming_convention'
- '--args=--only=terraform_required_providers'
- '--args=--only=terraform_standard_module_structure'
- '--args=--only=terraform_workspace_remote'

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -31,7 +30,7 @@ repos:
- id: requirements-txt-fixer

- repo: https://github.com/bridgecrewio/checkov.git
rev: '2.0.914'
rev: '2.1.280'
hooks:
- id: checkov
verbose: true
Expand Down
80 changes: 11 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
### Versions

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

#### Option 2:

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

- Create python 3.8+ virtual environment
```
Expand Down Expand Up @@ -91,43 +91,6 @@ tf -c=aws destroy -var='teamid=foo' -var='prjid=bar'
```

**Note:** Read more on [tfremote](https://github.com/tomarv2/tfremote)
```
terraform {
required_version = ">= 1.0.1"
required_providers {
aws = {
version = "~> 3.74"
}
}
}
provider "aws" {
region = var.region
}
module "redis" {
source = "../"
deploy_redis = true
deploy_redis_parameter_group = true
security_group_ids = [module.security_group.security_group_id]
# ----------------------------------------------
# Note: Do not change teamid and prjid once set.
teamid = var.teamid
prjid = var.prjid
}
module "security_group" {
source = "git::[email protected]:tomarv2/terraform-aws-security-group.git?ref=v0.0.6"
deploy_security_group = true
service_ports = [6379]
teamid = var.teamid
prjid = var.prjid
}
```

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

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

## Providers

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

## Modules

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

| Name | Type |
|------|------|
| [aws_elasticache_cluster.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster) | resource |
| [aws_elasticache_parameter_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_parameter_group) | resource |
| [aws_elasticache_subnet_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_subnet_group) | resource |
| [aws_elasticache_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_cluster) | resource |
| [aws_elasticache_parameter_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/elasticache_parameter_group) | resource |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <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 |
| <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 |
| <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 |
| <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 |
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | Group identifier. ElastiCache converts this name to lowercase | `string` | `null` | no |
| <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 |
| <a name="input_deploy_redis"></a> [deploy\_redis](#input\_deploy\_redis) | Feature flag, true or false | `bool` | `true` | no |
| <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 |
| <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 |
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | Version of engine | `string` | `"5.0.6"` | no |
| <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 |
| <a name="input_node_type"></a> [node\_type](#input\_node\_type) | The compute and memory capacity of the nodes | `string` | `"cache.t2.micro"` | no |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <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 |
| <a name="input_config"></a> [config](#input\_config) | Redis configuration | `map(any)` | `{}` | no |
| <a name="input_extra_tags"></a> [extra\_tags](#input\_extra\_tags) | Additional tags to associate | `map(string)` | `{}` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_aws_elasticache_parameter_group"></a> [aws\_elasticache\_parameter\_group](#output\_aws\_elasticache\_parameter\_group) | Elasticache Parameter Group |
| <a name="output_elasticache_cluster_address"></a> [elasticache\_cluster\_address](#output\_elasticache\_cluster\_address) | Elasticache Cluster address |
| <a name="output_elasticache_id"></a> [elasticache\_id](#output\_elasticache\_id) | Elasticache Id |
| <a name="output_cluster_address"></a> [cluster\_address](#output\_cluster\_address) | Elasticache Cluster address |
| <a name="output_cluster_id"></a> [cluster\_id](#output\_cluster\_id) | Elasticache Id |
| <a name="output_parameter_group"></a> [parameter\_group](#output\_parameter\_group) | Elasticache Parameter Group |
<!-- END_TF_DOCS -->
59 changes: 42 additions & 17 deletions examples/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,59 @@ terraform {
required_version = ">= 1.0.1"
required_providers {
aws = {
version = "~> 3.74"
version = "~> 4.35"
}
}
}

provider "aws" {
region = var.region
region = "us-west-2"
}

module "redis" {
source = "../"

deploy_redis = true
deploy_redis_parameter_group = true

security_group_ids = [module.security_group.security_group_id]
# ----------------------------------------------
# Note: Do not change teamid and prjid once set.
teamid = var.teamid
prjid = var.prjid
config = {
demo = {
security_group_ids = module.security_group.id
engine_version = "6.2"
family = "redis6.x"
parameter_group_config = {
activerehashing = {
value = "yes"
}
}
}
}
}

module "security_group" {
source = "git::[email protected]:tomarv2/terraform-aws-security-group.git?ref=v0.0.6"

deploy_security_group = true

service_ports = [6379]
teamid = var.teamid
prjid = var.prjid
#source = "git::[email protected]:tomarv2/terraform-aws-security-group.git?ref=v0.0.12"
source = "../../terraform-aws-security-group"
config = {
demo_redis = {
all_ingress_rules = [
{
description = "https"
type = "ingress"
from_port = 6379
protocol = "tcp"
to_port = 6379
self = true
cidr_blocks = []
}
]
all_egress_rules = [
{
description = "outbound traffic"
from_port = 0
protocol = "-1"
type = "egress"
to_port = 0
self = false
cidr_blocks = ["0.0.0.0/0"]
}
]
}
}
}
14 changes: 7 additions & 7 deletions examples/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
output "elasticache_id" {
output "cluster_id" {
value = module.redis.cluster_id
description = "Elasticache Id"
value = module.redis.elasticache_id
}

output "elasticache_cluster_address" {
output "cluster_address" {
value = module.redis.cluster_address
description = "Elasticache Cluster address"
value = module.redis.elasticache_cluster_address
}

output "aws_elasticache_parameter_group" {
output "parameter_group" {
description = "Elasticache Parameter Group"
value = module.redis.aws_elasticache_parameter_group
value = module.redis.parameter_group
}

output "security_group_id" {
description = "Security group Id"
value = module.security_group.security_group_id
value = module.security_group.id
}
15 changes: 0 additions & 15 deletions examples/variables.tf

This file was deleted.

Loading

0 comments on commit bf51e19

Please sign in to comment.