skip to Main Content

I’m trying to set and get keys from ElastiCache (memcached) from a python lambda function using Boto3. I can figure out how to get the endpoints but that’s pretty much it. Is there some documentation out there that shows the entire process?

2

Answers


  1. It sounds like you are trying to interact with Memcached via Boto3. This is not possible. Boto3 is for interacting with the AWS API. You can manage your ElastiCache servers via the AWS API, but you can’t interact with the Memcached software running on those servers. You need to use a Memcached client library like python-memcached in your Python code to actually get and set keys in your Memcached cluster.

    Also, your Lambda function will need to reside in the same VPC as the ElastiCache node(s).

    Login or Signup to reply.
  2. I had the exact timeout problem listed in the commment of the older post. My bug is in the security group for memcached. Here is the working version in terraform:

    resource "aws_security_group" "memcached" {
      vpc_id = "${aws_vpc.dev.id}"
      name   = "memcached SG"
    
      ingress {
        from_port       = "${var.memcached_port}"                    
        to_port         = "${var.memcached_port}" 
        protocol        = "tcp"
        cidr_blocks = ["${var.public_subnet_cidr}"]
      }
    
      egress {
        from_port   = "${var.memcached_port}" 
        to_port     = "${var.memcached_port}" 
        protocol    = "tcp"
        cidr_blocks = ["${var.public_subnet_cidr}"]
      }
    
      tags = {
        Name = "memcached SG"
      }
    }
    

    I tested the connection by creating a EC2 instance in public subnet and do “telnet (input your cache node URL) 11211”.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search