terraform deploy on ECS (#27)
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# Redis Terraform
|
||||
|
||||
Creates a Redis elasticache cluster. Run it like the following
|
||||
|
||||
`AWS_REGION=<region> terraform apply`
|
||||
|
||||
Enter a name for the cluster, as well as the subnet ids that Redis should be created in
|
||||
@@ -0,0 +1,33 @@
|
||||
#
|
||||
# The following variables need to be set:
|
||||
# AWS_ACCESS_KEY_ID (or reads from ~/.aws/credentials)
|
||||
# AWS_SECRET_ACCESS_KEY (or reads from ~/.aws/credentials)
|
||||
# AWS_REGION
|
||||
#
|
||||
provider "aws" {
|
||||
}
|
||||
|
||||
# type of instance to deploy on
|
||||
# see: https://aws.amazon.com/elasticache/pricing/
|
||||
variable "instance_type" {
|
||||
type = string
|
||||
default = "cache.t3.micro"
|
||||
}
|
||||
|
||||
# name of the cluster
|
||||
variable "cluster_id" {
|
||||
type = string
|
||||
}
|
||||
|
||||
# launch in the following subnet ids
|
||||
variable "subnet_ids" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "security_groups" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
output "address" {
|
||||
value = "${aws_elasticache_cluster.main.cache_nodes[0].address}:${aws_elasticache_cluster.main.cache_nodes[0].port}"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
resource "aws_elasticache_cluster" "main" {
|
||||
cluster_id = var.cluster_id
|
||||
engine = "redis"
|
||||
node_type = var.instance_type
|
||||
num_cache_nodes = 1
|
||||
parameter_group_name = "default.redis6.x"
|
||||
# strangely terraform requires you to change to a specific version when
|
||||
# modifying the resource.
|
||||
engine_version = "6.x"
|
||||
subnet_group_name = aws_elasticache_subnet_group.main.name
|
||||
security_group_ids = var.security_groups
|
||||
port = 6379
|
||||
}
|
||||
|
||||
resource "aws_elasticache_subnet_group" "main" {
|
||||
name = var.cluster_id
|
||||
subnet_ids = var.subnet_ids
|
||||
}
|
||||
Reference in New Issue
Block a user