Skip to content

Instantly share code, notes, and snippets.

@adborden
Last active May 20, 2020 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adborden/1f6ccddcf1b4f5f87d6fb1a737e142ef to your computer and use it in GitHub Desktop.
Save adborden/1f6ccddcf1b4f5f87d6fb1a737e142ef to your computer and use it in GitHub Desktop.
Example Redis ElastiCache configuration for Data.gov

Redis configuration template

This is an example of the Redis ElastiCache configuration that we're interested in. We're using Terraform both as a machine and human readable format to describe the configuration in concrete terms. The goal is to clearly communicate what configuration we're after and not so much to provide Terraform code for someone to run.

main.tf is the entrypoint for Terraform but most of the details of the configuration are in the redis module of datagov-infrastructure-modules.

plan.txt was generated from the main.tf using terraform plan and sandbox AWS credentials. I don't expect someone to take exactly what exists here and expect it to work with terraform apply.

provider "aws" {}
module "redis" {
source = "github.com/gsa/datagov-infrastructure-modules.git//modules/redis?ref=v3.6.0"
allow_security_groups = [] # any security groups allowing access from catalog-web and catalog-harvester
auth_token = "secretpasswordsecretpassword"
enable = true
env = "datagov-prod"
name = "catalog"
node_type = "cache.t3.large"
subnets = [] # subnet Ids
vpc_id = "" # VPC Id
}
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# module.redis.aws_elasticache_replication_group.redis[0] will be created
+ resource "aws_elasticache_replication_group" "redis" {
+ apply_immediately = (known after apply)
+ at_rest_encryption_enabled = false
+ auth_token = (sensitive value)
+ auto_minor_version_upgrade = true
+ automatic_failover_enabled = false
+ configuration_endpoint_address = (known after apply)
+ engine = "redis"
+ engine_version = "5.0.6"
+ id = (known after apply)
+ maintenance_window = (known after apply)
+ member_clusters = (known after apply)
+ node_type = "cache.t3.large"
+ number_cache_clusters = 1
+ parameter_group_name = "default.redis5.0"
+ port = 6379
+ primary_endpoint_address = (known after apply)
+ replication_group_description = "Redis replication group for datagov-prod-catalog"
+ replication_group_id = "rep-datagov-prod-catalog"
+ security_group_ids = (known after apply)
+ security_group_names = (known after apply)
+ snapshot_window = (known after apply)
+ subnet_group_name = "catalog-datagov-prod"
+ tags = {
+ "env" = "datagov-prod"
+ "name" = "catalog"
}
+ transit_encryption_enabled = true
+ cluster_mode {
+ num_node_groups = (known after apply)
+ replicas_per_node_group = (known after apply)
}
}
# module.redis.aws_elasticache_subnet_group.redis[0] will be created
+ resource "aws_elasticache_subnet_group" "redis" {
+ description = "Managed by Terraform"
+ id = (known after apply)
+ name = "catalog-datagov-prod"
}
# module.redis.aws_security_group.redis[0] will be created
+ resource "aws_security_group" "redis" {
+ arn = (known after apply)
+ description = "Security group for Redis"
+ egress = (known after apply)
+ id = (known after apply)
+ ingress = [
+ {
+ cidr_blocks = []
+ description = ""
+ from_port = 6379
+ ipv6_cidr_blocks = []
+ prefix_list_ids = []
+ protocol = "tcp"
+ security_groups = []
+ self = false
+ to_port = 6379
},
]
+ name = "catalog-redis-datagov-prod"
+ owner_id = (known after apply)
+ revoke_rules_on_delete = false
+ tags = {
+ "env" = "datagov-prod"
+ "name" = "catalog"
}
+ vpc_id = (known after apply)
}
Plan: 3 to add, 0 to change, 0 to destroy.
------------------------------------------------------------------------
Note: You didn't specify an "-out" parameter to save this plan, so Terraform
can't guarantee that exactly these actions will be performed if
"terraform apply" is subsequently run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment