Skip to content

Commit

Permalink
feat: add snapshot_arns_to_restore for serverless ElastiCache (#252)
Browse files Browse the repository at this point in the history
* [CloudPose Terraform Module] feat: Add snapshot_arns_to_restore for serverless ElastiCache

[PS-1]

- Added new variable snapshot_arns_to_restore
- Updated README
- Added same variable to serverless example as well
- Fixed EOL for files

Signed-off-by: muhammadasgharaliqureshi <[email protected]>

* Reformatted serverless example main.tf file

* Fixed README style for new variable

* Addressed feedbacks: Updated variable description

---------

Signed-off-by: muhammadasgharaliqureshi <[email protected]>
Co-authored-by: asghar.qureshi <[email protected]>
  • Loading branch information
muhammadasgharaliqureshi and asghar-qureshi authored Jan 28, 2025
1 parent d87f99c commit abead68
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ Available targets:
| <a name="input_user_group_ids"></a> [user\_group\_ids](#input\_user\_group\_ids) | User Group ID to associate with the replication group | `list(string)` | `null` | no |
| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | VPC ID | `string` | n/a | yes |
| <a name="input_zone_id"></a> [zone\_id](#input\_zone\_id) | Route53 DNS Zone ID as list of string (0 or 1 items). If empty, no custom DNS name will be published.<br/>If the list contains a single Zone ID, a custom DNS name will be pulished in that zone.<br/>Can also be a plain string, but that use is DEPRECATED because of Terraform issues. | `any` | `[]` | no |
| <a name="input_serverless_snapshot_arns_to_restore"></a> [serverless_snapshot_arns_to_restore](#input\_serverless\_snapshot\_arns\_to\_restore) | The list of ARN(s) of the snapshot that the new serverless cache will be created from. Available for Redis only. | `list(string)` | `[]` | no |

## Outputs

Expand Down
1 change: 0 additions & 1 deletion examples/serverless/fixtures.us-east-2.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ serverless_cache_usage_limits = {
at_rest_encryption_enabled = false

zone_id = "Z3SO0TKDDQ0RGG"

18 changes: 9 additions & 9 deletions examples/serverless/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ module "cloudwatch_logs" {
module "redis" {
source = "../../"

serverless_enabled = var.serverless_enabled
zone_id = [aws_route53_zone.private.id]
vpc_id = module.vpc.vpc_id
allowed_security_groups = [module.vpc.vpc_default_security_group_id]
subnets = module.subnets.private_subnet_ids
serverless_major_engine_version = var.serverless_major_engine_version
at_rest_encryption_enabled = var.at_rest_encryption_enabled
serverless_cache_usage_limits = var.serverless_cache_usage_limits

serverless_enabled = var.serverless_enabled
zone_id = [aws_route53_zone.private.id]
vpc_id = module.vpc.vpc_id
allowed_security_groups = [module.vpc.vpc_default_security_group_id]
subnets = module.subnets.private_subnet_ids
serverless_major_engine_version = var.serverless_major_engine_version
at_rest_encryption_enabled = var.at_rest_encryption_enabled
serverless_cache_usage_limits = var.serverless_cache_usage_limits
serverless_snapshot_arns_to_restore = var.serverless_snapshot_arns_to_restore
# Verify that we can safely change security groups (name changes forces new SG)
security_group_create_before_destroy = true
security_group_name = length(var.sg_name) > 0 ? [var.sg_name] : []
Expand Down
2 changes: 1 addition & 1 deletion examples/serverless/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ output "serverless_host" {
output "serverless_enabled" {
value = module.redis.serverless_enabled
description = "Indicates if serverless mode is enabled"
}
}
8 changes: 7 additions & 1 deletion examples/serverless/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,10 @@ variable "sg_name" {
type = string
default = ""
description = "Name to give to created security group"
}
}

variable "serverless_snapshot_arns_to_restore" {
type = list(string)
default = []
description = "The list of ARN(s) of the snapshot that the new serverless cache will be created from. Available for Redis only."
}
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ resource "aws_elasticache_serverless_cache" "default" {
security_group_ids = local.create_security_group ? concat(local.associated_security_group_ids, [module.aws_security_group.id]) : local.associated_security_group_ids

daily_snapshot_time = var.serverless_snapshot_time
snapshot_arns_to_restore = var.serverless_snapshot_arns_to_restore
description = coalesce(var.description, module.this.id)
major_engine_version = var.serverless_major_engine_version
snapshot_retention_limit = var.snapshot_retention_limit
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,9 @@ variable "serverless_cache_usage_limits" {
default = {}
description = "The usage limits for the serverless cache"
}

variable "serverless_snapshot_arns_to_restore" {
type = list(string)
default = []
description = "The list of ARN(s) of the snapshot that the new serverless cache will be created from. Available for Redis only."
}

0 comments on commit abead68

Please sign in to comment.