Trying to create Elasticahe redis, I always get th...
# aws
a
Trying to create Elasticahe redis, I always get this error.
Copy code
* error creating ElastiCache Cache Cluster: CacheSubnetGroupNotFoundFault: Cache Subnet Group redis-subnet-group-ec90733 does not exist.
        status code: 400
adding dependencies explicitly doesn't help
Copy code
const subnetGroup = new SubnetGroup("redis-subnet-group", { subnetIds: sids.ids })

                const nsg = new SecurityGroup("sgredis", {
                    vpcId: vpc.id,
                    ingress: [{
                        fromPort: redisConfig.port,
                        toPort: redisConfig.port,
                        protocol: "tcp",
                        cidrBlocks: [vpc.cidrBlock]
                    }]
                })

                const cluster = new elasticache.Cluster("redis-cluster", {
                    preferredAvailabilityZones: redisConfig.availabilityZones,
                    nodeType: redisConfig.nodeType,
                    numCacheNodes: 1,
                    subnetGroupName: subnetGroup.name,
                    engine: "redis",
                    securityGroupIds: [nsg.id]
                }, { dependsOn: [subnetGroup, nsg] })
👀 1
b
Can you make sure that the
SubnetGroup
you're using is an
Elasticache
one? Quite a few other modules also contain SubnetGroup resources but they're all different:
a
You're totally right! I imported awsdaxSubnetGroup instead 🤦‍♂️
b
I'll be honest it completely threw me for a while.. it's very easy to do. Glad we got it sorted