Creates an ElastiCache cluster in an AWS Outpost environment with specific subnet and outpost settings.

Terraform Template

data "aws_outposts_outpost" "example" {
  id = tolist(data.aws_outposts_outposts.example.ids)[0]
}

data "aws_outposts_outposts" "example" {
}

resource "aws_elasticache_cluster" "example" {
  cluster_id = "cluster-example"
  engine = "memcached"
  node_type = "cache.r5.large"
  num_cache_nodes = 2
  outpost_mode = "single-outpost"
  parameter_group_name = "default.memcached1.4"
  port = 11211
  preferred_outpost_arn = data.aws_outposts_outpost.example.arn
  subnet_group_name = aws_elasticache_subnet_group.example.name
}

resource "aws_elasticache_subnet_group" "example" {
  name = "my-cache-subnet"
  subnet_ids = [aws_subnet.example.id]
}

resource "aws_subnet" "example" {
  cidr_block = "10.0.1.0/24"

  tags = {
    Name = "my-subnet"
  }
  vpc_id = aws_vpc.example.id
}

resource "aws_vpc" "example" {
  cidr_block = "10.0.0.0/16"
}