Skip to content

Commit 0ce5de6

Browse files
committed
chore: Copy over code from old repository as base
1 parent 900b531 commit 0ce5de6

File tree

32 files changed

+1742
-11
lines changed

32 files changed

+1742
-11
lines changed

README.md

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ No providers.
3737

3838
## Modules
3939

40-
No modules.
40+
| Name | Source | Version |
41+
|------|--------|---------|
42+
| <a name="module_cluster"></a> [cluster](#module\_cluster) | ./modules/cluster | n/a |
43+
| <a name="module_parameter_group"></a> [parameter\_group](#module\_parameter\_group) | ./modules/parameter_group | n/a |
44+
| <a name="module_replication_group"></a> [replication\_group](#module\_replication\_group) | ./modules/replication_group | n/a |
45+
| <a name="module_subnet_group"></a> [subnet\_group](#module\_subnet\_group) | ./modules/subnet_group | n/a |
4146

4247
## Resources
4348

@@ -47,12 +52,63 @@ No resources.
4752

4853
| Name | Description | Type | Default | Required |
4954
|------|-------------|------|---------|:--------:|
50-
| <a name="input_create"></a> [create](#input\_create) | Determines whether resources will be created (affects all resources) | `bool` | `true` | no |
51-
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to add to all resources | `map(string)` | `{}` | no |
55+
| <a name="input_apply_immediately"></a> [apply\_immediately](#input\_apply\_immediately) | Specifies whether any modifications are applied immediately, or during the next maintenance window | `bool` | `false` | no |
56+
| <a name="input_at_rest_encryption_enabled"></a> [at\_rest\_encryption\_enabled](#input\_at\_rest\_encryption\_enabled) | Whether to enable encryption at rest | `bool` | `true` | no |
57+
| <a name="input_auth_token"></a> [auth\_token](#input\_auth\_token) | The password used to access a password protected server. Can be specified only if `transit_encryption_enabled = true` | `string` | `null` | no |
58+
| <a name="input_auto_minor_version_upgrade"></a> [auto\_minor\_version\_upgrade](#input\_auto\_minor\_version\_upgrade) | Specifies whether a minor engine upgrades will be applied automatically to the underlying Cache Cluster instances during the maintenance window | `bool` | `true` | no |
59+
| <a name="input_automatic_failover_enabled"></a> [automatic\_failover\_enabled](#input\_automatic\_failover\_enabled) | Specifies whether a read-only replica will be automatically promoted to read/write primary if the existing primary fails. If true, Multi-AZ is enabled for this replication group. If false, Multi-AZ is disabled for this replication group. Must be enabled for Redis (cluster mode enabled) replication groups | `bool` | `true` | no |
60+
| <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 | `string` | `null` | no |
61+
| <a name="input_availability_zones"></a> [availability\_zones](#input\_availability\_zones) | A list of EC2 availability zones in which the replication group's cache clusters will be created | `list(string)` | `[]` | no |
62+
| <a name="input_az_mode"></a> [az\_mode](#input\_az\_mode) | 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 |
63+
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | Group identifier. ElastiCache converts this name to lowercase | `string` | `null` | no |
64+
| <a name="input_cluster_mode"></a> [cluster\_mode](#input\_cluster\_mode) | Create a native redis cluster. automatic\_failover\_enabled must be set to true. Cluster Mode documented below. Only 1 cluster\_mode block is allowed | `list(map(string))` | `[]` | no |
65+
| <a name="input_create_parameter_group"></a> [create\_parameter\_group](#input\_create\_parameter\_group) | Determines whether the ElastiCache parameter group will be created or not | `bool` | `false` | no |
66+
| <a name="input_create_replication_group"></a> [create\_replication\_group](#input\_create\_replication\_group) | Determines whether an ElastiCache replication group will be created or not | `bool` | `false` | no |
67+
| <a name="input_create_subnet_group"></a> [create\_subnet\_group](#input\_create\_subnet\_group) | Determines whether the Elasticache subnet group will be created or not | `bool` | `false` | no |
68+
| <a name="input_engine"></a> [engine](#input\_engine) | The name of the cache engine to be used. e.g. `redis` | `string` | `null` | no |
69+
| <a name="input_engine_version"></a> [engine\_version](#input\_engine\_version) | The version number of the cache engine to be used | `string` | `null` | no |
70+
| <a name="input_identifier"></a> [identifier](#input\_identifier) | The identifier of the resource | `string` | `""` | no |
71+
| <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` | `null` | no |
72+
| <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. The format is ddd:hh24:mi-ddd:hh24:mi (24H Clock UTC). The minimum maintenance window is a 60 minute period. Example: sun:05:00-sun:09:00 | `string` | `null` | no |
73+
| <a name="input_node_type"></a> [node\_type](#input\_node\_type) | The compute and memory capacity of the nodes in the node group | `string` | n/a | yes |
74+
| <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 |
75+
| <a name="input_num_cache_nodes"></a> [num\_cache\_nodes](#input\_num\_cache\_nodes) | (Required unless replication\_group\_id is provided) 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. If this number is reduced on subsequent runs, the highest numbered nodes will be removed | `number` | `null` | no |
76+
| <a name="input_number_cache_clusters"></a> [number\_cache\_clusters](#input\_number\_cache\_clusters) | (Required for Cluster Mode Disabled) The number of cache clusters (primary and replicas) this replication group will have. If Multi-AZ is enabled, the value of this parameter must be at least 2. Updates will occur before other modifications | `number` | `null` | no |
77+
| <a name="input_parameter_group_description"></a> [parameter\_group\_description](#input\_parameter\_group\_description) | Description for the ElastiCache parameter group | `string` | `""` | no |
78+
| <a name="input_parameter_group_family"></a> [parameter\_group\_family](#input\_parameter\_group\_family) | The family of the ElastiCache parameter group | `string` | `null` | no |
79+
| <a name="input_parameter_group_name"></a> [parameter\_group\_name](#input\_parameter\_group\_name) | The name of the parameter group to associate with this replication group. If this argument is omitted, the default cache parameter group for the specified engine is used | `string` | `null` | no |
80+
| <a name="input_parameters"></a> [parameters](#input\_parameters) | List of ElastiCache parameters to apply | `list(map(string))` | `[]` | no |
81+
| <a name="input_port"></a> [port](#input\_port) | The port number on which each of the cache nodes will accept connections. | `number` | `null` | no |
82+
| <a name="input_preferred_availability_zones"></a> [preferred\_availability\_zones](#input\_preferred\_availability\_zones) | A list of the Availability Zones in which cache nodes are created. If you are creating your cluster in an Amazon VPC you can only locate nodes in Availability Zones that are associated with the subnets in the selected subnet group. The number of Availability Zones listed must equal the value of num\_cache\_nodes. If you want all the nodes in the same Availability Zone, use availability\_zone instead, or repeat the Availability Zone multiple times in the list. Default: System chosen Availability Zones. Detecting drift of existing node availability zone is not currently supported. Updating this argument by itself to migrate existing node availability zones is not currently supported and will show a perpetual difference | `list(string)` | `[]` | no |
83+
| <a name="input_replication_group_description"></a> [replication\_group\_description](#input\_replication\_group\_description) | A user-created description for the replication group | `string` | `null` | no |
84+
| <a name="input_replication_group_id"></a> [replication\_group\_id](#input\_replication\_group\_id) | The replication group identifier. This parameter is stored as a lowercase string | `string` | `null` | no |
85+
| <a name="input_security_group_ids"></a> [security\_group\_ids](#input\_security\_group\_ids) | One or more Amazon VPC security groups associated with this replication group. Use this parameter only when you are creating a replication group in an Amazon Virtual Private Cloud | `list(string)` | `[]` | no |
86+
| <a name="input_security_group_names"></a> [security\_group\_names](#input\_security\_group\_names) | A list of cache security group names to associate with this replication group | `list(string)` | `[]` | no |
87+
| <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(string)` | `[]` | no |
88+
| <a name="input_snapshot_name"></a> [snapshot\_name](#input\_snapshot\_name) | The name of a snapshot from which to restore data into the new node group. Changing the snapshot\_name forces a new resource | `string` | `null` | no |
89+
| <a name="input_snapshot_retention_limit"></a> [snapshot\_retention\_limit](#input\_snapshot\_retention\_limit) | The number of days for which ElastiCache will retain automatic cache cluster snapshots before deleting them. For example, if you set SnapshotRetentionLimit to 5, then a snapshot that was taken today will be retained for 5 days before being deleted. If the value of SnapshotRetentionLimit is set to zero (0), backups are turned off. Please note that setting a snapshot\_retention\_limit is not supported on cache.t1.micro or cache.t2.* cache nodes | `number` | `null` | no |
90+
| <a name="input_snapshot_window"></a> [snapshot\_window](#input\_snapshot\_window) | The daily time range (in UTC) during which ElastiCache will begin taking a daily snapshot of your cache cluster. The minimum snapshot window is a 60 minute period. Example: 05:00-09:00 | `string` | `null` | no |
91+
| <a name="input_subnet_group_description"></a> [subnet\_group\_description](#input\_subnet\_group\_description) | Description for the Elasticache subnet group | `string` | `null` | no |
92+
| <a name="input_subnet_group_name"></a> [subnet\_group\_name](#input\_subnet\_group\_name) | The name of the cache subnet group to be used for the replication group | `string` | `null` | no |
93+
| <a name="input_subnet_ids"></a> [subnet\_ids](#input\_subnet\_ids) | List of VPC Subnet IDs for the Elasticache subnet group | `list(string)` | `[]` | no |
94+
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to assign to the resource | `map(any)` | `{}` | no |
95+
| <a name="input_transit_encryption_enabled"></a> [transit\_encryption\_enabled](#input\_transit\_encryption\_enabled) | Whether to enable encryption in transit | `bool` | `false` | no |
5296

5397
## Outputs
5498

55-
No outputs.
99+
| Name | Description |
100+
|------|-------------|
101+
| <a name="output_cluster_address"></a> [cluster\_address](#output\_cluster\_address) | The DNS name of the cache cluster without the port appended |
102+
| <a name="output_cluster_cache_nodes"></a> [cluster\_cache\_nodes](#output\_cluster\_cache\_nodes) | List of node objects including id, address, port and availability\_zone |
103+
| <a name="output_cluster_configuration_endpoint"></a> [cluster\_configuration\_endpoint](#output\_cluster\_configuration\_endpoint) | The configuration endpoint to allow host discovery |
104+
| <a name="output_parameter_group_id"></a> [parameter\_group\_id](#output\_parameter\_group\_id) | The ElastiCache parameter group id |
105+
| <a name="output_parameter_group_name"></a> [parameter\_group\_name](#output\_parameter\_group\_name) | The ElastiCache parameter group name |
106+
| <a name="output_replication_group_configuration_endpoint_address"></a> [replication\_group\_configuration\_endpoint\_address](#output\_replication\_group\_configuration\_endpoint\_address) | The address of the replication group configuration endpoint when cluster mode is enabled |
107+
| <a name="output_replication_group_id"></a> [replication\_group\_id](#output\_replication\_group\_id) | The ID of the ElastiCache Replication Group |
108+
| <a name="output_replication_group_member_clusters"></a> [replication\_group\_member\_clusters](#output\_replication\_group\_member\_clusters) | The identifiers of all the nodes that are part of this replication group. |
109+
| <a name="output_replication_group_primary_endpoint_address"></a> [replication\_group\_primary\_endpoint\_address](#output\_replication\_group\_primary\_endpoint\_address) | The address of the endpoint for the primary node in the replication group, if the cluster mode is disabled |
110+
| <a name="output_subnet_group_ids"></a> [subnet\_group\_ids](#output\_subnet\_group\_ids) | The ElastiCache subnet group IDs |
111+
| <a name="output_subnet_group_name"></a> [subnet\_group\_name](#output\_subnet\_group\_name) | The ElastiCache subnet group name |
56112
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
57113

58114
## License
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Complete ElastiCache example for Memcached cluster
2+
3+
Configuration in this directory creates set of ElastiCaChe resources including cluster, subnet group and parameter group.
4+
5+
Data sources are used to discover existing VPC resources (VPC, subnet and security group).
6+
7+
## Usage
8+
9+
To run this example you need to execute:
10+
11+
```bash
12+
$ terraform init
13+
$ terraform plan
14+
$ terraform apply
15+
```
16+
17+
Note that this example may create resources which cost money. Run `terraform destroy` when you don't need these resources.
18+
19+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
20+
## Requirements
21+
22+
No requirements.
23+
24+
## Providers
25+
26+
| Name | Version |
27+
|------|---------|
28+
| <a name="provider_aws"></a> [aws](#provider\_aws) | n/a |
29+
30+
## Modules
31+
32+
| Name | Source | Version |
33+
|------|--------|---------|
34+
| <a name="module_memcached_cluster"></a> [memcached\_cluster](#module\_memcached\_cluster) | ../../ | n/a |
35+
36+
## Resources
37+
38+
| Name | Type |
39+
|------|------|
40+
| [aws_security_group.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/security_group) | data source |
41+
| [aws_subnet_ids.all](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/subnet_ids) | data source |
42+
| [aws_vpc.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source |
43+
44+
## Inputs
45+
46+
No inputs.
47+
48+
## Outputs
49+
50+
| Name | Description |
51+
|------|-------------|
52+
| <a name="output_address"></a> [address](#output\_address) | The DNS name of the cache cluster without the port appended |
53+
| <a name="output_cache_nodes"></a> [cache\_nodes](#output\_cache\_nodes) | List of node objects including id, address, port and availability\_zone |
54+
| <a name="output_configuration_endpoint"></a> [configuration\_endpoint](#output\_configuration\_endpoint) | The configuration endpoint to allow host discovery |
55+
| <a name="output_parameter_group_id"></a> [parameter\_group\_id](#output\_parameter\_group\_id) | The ElastiCache parameter group id |
56+
| <a name="output_parameter_group_name"></a> [parameter\_group\_name](#output\_parameter\_group\_name) | The ElastiCache parameter group name |
57+
| <a name="output_subnet_group_ids"></a> [subnet\_group\_ids](#output\_subnet\_group\_ids) | The ElastiCache subnet group IDs |
58+
| <a name="output_subnet_group_name"></a> [subnet\_group\_name](#output\_subnet\_group\_name) | The ElastiCache subnet group name |
59+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
locals {
2+
engine = "memcached"
3+
full_version = "1.5.16"
4+
patch_verson = join(".", slice(split(".", local.full_version), 0, 2))
5+
name = "${local.engine}-cluster-complete"
6+
}
7+
8+
module "memcached_cluster" {
9+
source = "../../"
10+
11+
cluster_id = local.name
12+
13+
engine = local.engine
14+
engine_version = local.full_version
15+
node_type = "cache.t2.micro"
16+
num_cache_nodes = 2
17+
az_mode = "cross-az"
18+
19+
security_group_ids = []
20+
21+
# subnet group
22+
create_subnet_group = true
23+
subnet_group_name = "${local.name}-${replace(local.patch_verson, ".", "-")}"
24+
subnet_group_description = "${title(local.name)} ${local.patch_verson} subnet group"
25+
subnet_ids = data.aws_subnet_ids.all.ids
26+
27+
maintenance_window = "sun:05:00-sun:09:00"
28+
apply_immediately = true
29+
30+
# parameter group
31+
create_parameter_group = true
32+
parameter_group_family = "${local.engine}${local.patch_verson}"
33+
parameter_group_name = "${local.name}-${replace(local.patch_verson, ".", "-")}"
34+
parameter_group_description = "${title(local.name)} ${local.patch_verson} parameter group"
35+
parameters = [{
36+
name = "idle_timeout"
37+
value = 60
38+
}]
39+
40+
tags = {
41+
Owner = "user"
42+
Environment = "dev"
43+
}
44+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
provider "aws" {
2+
region = "us-west-2"
3+
}
4+
5+
##############################################################
6+
# Data sources to get VPC, subnets and security group details
7+
##############################################################
8+
9+
data "aws_vpc" "default" {
10+
default = true
11+
}
12+
13+
data "aws_subnet_ids" "all" {
14+
vpc_id = data.aws_vpc.default.id
15+
}
16+
17+
data "aws_security_group" "default" {
18+
vpc_id = data.aws_vpc.default.id
19+
name = "default"
20+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
################################################################################
2+
# Cluster
3+
################################################################################
4+
5+
output "cache_nodes" {
6+
description = "List of node objects including id, address, port and availability_zone"
7+
value = module.memcached_cluster.cluster_cache_nodes
8+
}
9+
10+
output "configuration_endpoint" {
11+
description = "The configuration endpoint to allow host discovery"
12+
value = module.memcached_cluster.cluster_configuration_endpoint
13+
}
14+
15+
output "address" {
16+
description = "The DNS name of the cache cluster without the port appended"
17+
value = module.memcached_cluster.cluster_address
18+
}
19+
20+
################################################################################
21+
# Subnet Group
22+
################################################################################
23+
24+
output "subnet_group_name" {
25+
description = "The ElastiCache subnet group name"
26+
value = module.memcached_cluster.subnet_group_name
27+
}
28+
29+
output "subnet_group_ids" {
30+
description = "The ElastiCache subnet group IDs"
31+
value = module.memcached_cluster.subnet_group_ids
32+
}
33+
34+
################################################################################
35+
# Parameter Group
36+
################################################################################
37+
38+
output "parameter_group_name" {
39+
description = "The ElastiCache parameter group name"
40+
value = module.memcached_cluster.parameter_group_name
41+
}
42+
43+
output "parameter_group_id" {
44+
description = "The ElastiCache parameter group id"
45+
value = module.memcached_cluster.parameter_group_id
46+
}

0 commit comments

Comments
 (0)