In using the AWS CDK, creating a CfnServerlessCache Redis cache, the provided endpoint port is incorrect

0

I'm creating an Elasticache OSS Redis server with

const redisCluster = new Elasticache.CfnServerlessCache(this, redisName, {
      engine: 'redis',
      serverlessCacheName: redisName,
      securityGroupIds:[cacheSecurityGroup.securityGroupId],
      subnetIds: subnetIds,
      cacheUsageLimits : {
        dataStorage : {
          maximum: maxMemoryGB,
          unit: 'GB'
        }
      }
    });

    new cdk.CfnOutput(this,'RedisEndPointPort',{
      value: redisCluster.attrReaderEndpointPort
    })

The endpoint port is incorrect, however, it's 6380, instead of 6379:

Outputs:
dev-ServerlessRedisCacheStack.RedisEndPoint = dev-serverlessrediscacheredis-s9pu57.serverless.usw1.cache.amazonaws.com
dev-ServerlessRedisCacheStack.RedisEndPointPort = 6380

The cache cannot be connected to on 6380, only 6379. Note that the created security group does have the correct port:

devServerlessRedisCacheSecurityGroup43E6A92B:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: dev-ServerlessRedisCacheStack/dev-ServerlessRedisCacheSecurityGroup
      SecurityGroupEgress:
        - CidrIp: 0.0.0.0/0
          Description: Allow all outbound traffic by default
          IpProtocol: "-1"
      SecurityGroupIngress:
        - CidrIp: 0.0.0.0/0
          Description: from 0.0.0.0/0:6379
          FromPort: 6379
          IpProtocol: tcp
          ToPort: 6379

How can this be fixed?

Note that I also tried 'endpoint' instead of 'readerEndpoint', but the former is 'undefined'.

asked a month ago200 views
1 Answer
1
Accepted Answer

Hello.

The document below states that 6379 and 6380 are used, so it seems to work normally.
What you are outputting with "CfnOutput" is the port number of the reader endpoint, so 6380 should be normal.
https://docs.aws.amazon.com/AmazonElastiCache/latest/red-ug/wwe-troubleshooting.html#wwe-troubleshooting.connection

Ensure the security group allows access to ports 6379 and 6380: ElastiCache Serverless uses the 6379 port for the primary endpoint and the 6380 port for the reader endpoint. Some clients establish connectivity to both ports for every new connection, even if your application is not using the Read from Replica feature. If your security group does not allow inbound access to both ports, then connection establishment can take longer. Learn more about how to setup port access here.

I think if you check the writer endpoint with "attrEndpointPort" it will be 6379.
https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_elasticache.CfnServerlessCache.html

profile picture
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions