Add a private redis instance.
This commit is contained in:
parent
49999fbf67
commit
7f186956db
@ -261,3 +261,27 @@ module "cloudsql" {
|
||||
module.networking
|
||||
]
|
||||
}
|
||||
|
||||
#################### Redis ################################
|
||||
|
||||
module "redis" {
|
||||
source = "../modules/redis"
|
||||
project = var.project
|
||||
region = var.region
|
||||
private_network_id = module.networking.private_network_id
|
||||
|
||||
depends_on = [
|
||||
module.networking
|
||||
]
|
||||
}
|
||||
|
||||
output "redis_host" {
|
||||
description = "Hostname/IP Address for redis database."
|
||||
value = module.redis.redis_host
|
||||
}
|
||||
|
||||
output "redis_port" {
|
||||
description = "Port for redis database."
|
||||
value = module.redis.redis_port
|
||||
}
|
||||
|
||||
|
46
terraform/modules/redis/redis.tf
Normal file
46
terraform/modules/redis/redis.tf
Normal file
@ -0,0 +1,46 @@
|
||||
variable "project" {
|
||||
description = "Project ID."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
description = "Region."
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "private_network_id" {
|
||||
description = "Private network id."
|
||||
type = string
|
||||
}
|
||||
|
||||
output "redis_host" {
|
||||
description = "Hostname/IP Address for redis database."
|
||||
value = google_redis_instance.cache.host
|
||||
}
|
||||
|
||||
output "redis_port" {
|
||||
description = "Port for redis database."
|
||||
value = google_redis_instance.cache.port
|
||||
}
|
||||
|
||||
resource "google_project_service" "redis" {
|
||||
project = var.project
|
||||
service = "redis.googleapis.com"
|
||||
disable_dependent_services = true
|
||||
}
|
||||
|
||||
resource "google_redis_instance" "cache" {
|
||||
project = var.project
|
||||
region = var.region
|
||||
name = "private-cache"
|
||||
display_name = "Private redis cache database."
|
||||
tier = "STANDARD_HA"
|
||||
memory_size_gb = 1
|
||||
authorized_network = var.private_network_id
|
||||
connect_mode = "PRIVATE_SERVICE_ACCESS"
|
||||
redis_version = "REDIS_5_0"
|
||||
|
||||
depends_on = [
|
||||
google_project_service.redis
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user