generated from clowdhaus/terraform-aws-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Support elasticache serverless cache (#3)
- Loading branch information
1 parent
079e768
commit f91028d
Showing
23 changed files
with
470 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ terraform { | |
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 5.27" | ||
version = ">= 5.46" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ terraform { | |
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 5.27" | ||
version = ">= 5.46" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ terraform { | |
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 5.27" | ||
version = ">= 5.46" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ terraform { | |
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 5.27" | ||
version = ">= 5.46" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ terraform { | |
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 5.27" | ||
version = ">= 5.46" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
provider "aws" { | ||
region = local.region | ||
} | ||
|
||
data "aws_availability_zones" "available" {} | ||
|
||
locals { | ||
region = "eu-west-1" | ||
name = "ex-${basename(path.cwd)}" | ||
|
||
vpc_cidr = "10.0.0.0/16" | ||
azs = slice(data.aws_availability_zones.available.names, 0, 3) | ||
|
||
tags = { | ||
Name = local.name | ||
Example = local.name | ||
Repository = "https://github.com/terraform-aws-modules/terraform-aws-elasticache" | ||
} | ||
} | ||
|
||
module "serverless" { | ||
source = "../../modules/serverless-cache" | ||
|
||
engine = "redis" | ||
cache_name = local.name | ||
|
||
cache_usage_limits = { | ||
data_storage = { | ||
maximum = 2 | ||
} | ||
ecpu_per_second = { | ||
maximum = 1000 | ||
} | ||
} | ||
|
||
daily_snapshot_time = "22:00" | ||
description = "${local.name} serverless cluster" | ||
kms_key_id = aws_kms_key.this.arn | ||
major_engine_version = "7" | ||
security_group_ids = [module.sg.security_group_id] | ||
|
||
snapshot_retention_limit = 7 | ||
subnet_ids = module.vpc.private_subnets | ||
|
||
user_group_id = module.cache_user_group.group_id | ||
} | ||
|
||
module "cache_user_group" { | ||
source = "../../modules/user-group" | ||
|
||
default_user = { | ||
user_id = "${local.name}-default" | ||
authentication_mode = { | ||
type = "no-password-required" | ||
} | ||
} | ||
|
||
users = { | ||
redis = { | ||
user_id = local.name | ||
user_name = "redis" | ||
access_string = "on ~* -@all +@read" | ||
authentication_mode = { | ||
type = "no-password-required" | ||
} | ||
} | ||
} | ||
|
||
user_group_id = "redis" | ||
} | ||
|
||
################################################################################ | ||
# Supporting Resources | ||
################################################################################ | ||
|
||
module "vpc" { | ||
source = "terraform-aws-modules/vpc/aws" | ||
version = "~> 5.0" | ||
|
||
name = local.name | ||
cidr = local.vpc_cidr | ||
|
||
azs = local.azs | ||
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k)] | ||
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 10)] | ||
|
||
tags = local.tags | ||
} | ||
|
||
resource "aws_kms_key" "this" { | ||
description = "KMS CMK for ${local.name}" | ||
enable_key_rotation = true | ||
|
||
tags = local.tags | ||
} | ||
|
||
module "sg" { | ||
source = "terraform-aws-modules/security-group/aws" | ||
version = "~> 5.0" | ||
|
||
name = local.name | ||
description = "Security group for VPC traffic" | ||
vpc_id = module.vpc.vpc_id | ||
|
||
ingress_cidr_blocks = [module.vpc.vpc_cidr_block] | ||
ingress_rules = ["redis-tcp"] | ||
|
||
tags = local.tags | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
output "serverless_cache_arn" { | ||
description = "The amazon resource name of the serverless cache" | ||
value = module.serverless.serverless_cache_arn | ||
} | ||
|
||
output "serverless_cache_create_time" { | ||
description = "Timestamp of when the serverless cache was created" | ||
value = module.serverless.serverless_cache_create_time | ||
} | ||
|
||
output "serverless_cache_endpoint" { | ||
description = " Represents the information required for client programs to connect to a cache node" | ||
value = module.serverless.serverless_cache_endpoint | ||
} | ||
|
||
output "serverless_cache_full_engine_version" { | ||
description = "The name and version number of the engine the serverless cache is compatible with" | ||
value = module.serverless.serverless_cache_full_engine_version | ||
} | ||
|
||
output "serverless_cache_major_engine_version" { | ||
description = "The version number of the engine the serverless cache is compatible with" | ||
value = module.serverless.serverless_cache_major_engine_version | ||
} | ||
|
||
output "serverless_cache_reader_endpoint" { | ||
description = "Represents the information required for client programs to connect to a cache node" | ||
value = module.serverless.serverless_cache_reader_endpoint | ||
} | ||
|
||
output "serverless_cache_status" { | ||
description = "The current status of the serverless cache. The allowed values are CREATING, AVAILABLE, DELETING, CREATE-FAILED and MODIFYING" | ||
value = module.serverless.serverless_cache_status | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
terraform { | ||
required_version = ">= 1.0" | ||
|
||
required_providers { | ||
aws = { | ||
source = "hashicorp/aws" | ||
version = ">= 5.46" | ||
} | ||
} | ||
} |
Oops, something went wrong.