How to connect Golang Lambda function with Redis Elasticache AWS

huangapple go评论72阅读模式
英文:

How to connect Golang Lambda function with Redis Elasticache AWS

问题

我是你的中文翻译助手,以下是翻译好的内容:

我是新手使用golang。

我一直在查看lambda-golang-AWS的文档,但在调用函数时仍然遇到超时问题。

我已经进行了以下配置:

  1. Elasticache集群(1个主节点),
  2. VPC(为redis和lambda使用相同的VPC),
  3. 安全组,
  4. 子网,
  5. 入站和出站规则,
  6. 角色

我有这个主要的Redis端点 xxxxxx

我只需要一个示例。

所以,我的问题是:

  1. 我们可以在Linux上连接Redis而不使用EC2实例吗?可能可以尝试使用RDM。
  2. 我们如何将AWS Redis的端点放入主函数中?(我们只需要端点吗?还是还需要其他内容?)
  3. 可以只使用端点(无需AUTH)连接到Redis Elasticache吗?

非常感谢!

英文:

I'm new with golang.

I've been looking documentation of lambda-golang-AWS and still had this timeout in when invoking the function.

I've been configuring:

  1. Elasticache cluster (1 primary node),
  2. VPC (one same VPC for redis and lambda),
  3. Security groups,
  4. Subnets,
  5. Inbound and outbound,
  6. role

I have this primary Redis endpoint xxxxxx

I just need an example.

So, my questions are:

  1. Can we connect Redis in Linux without an EC2 instance? Possibly try it with RDM.
  2. How do we put AWS redis's endpoint in the main function? (do we only need the endpoint? or else)
  3. Is it possible to connect to Redis Elasticache with only endpoint (without AUTH)?

Thanks a lot!

答案1

得分: 2

我们可以在Linux上连接Redis而不需要EC2实例吗?

是的,当然可以,为什么需要EC2实例作为额外要求呢?你只需要在Lambda函数的部署包中包含一个Redis客户端库,并配置Elasticache集群以允许Lambda函数所分配的安全组的入站流量。

我们如何在主函数中放置AWS Redis的端点?(我们只需要端点吗?还是还需要其他内容)

我会将端点配置为Lambda函数的环境变量之一。

只使用端点(无需AUTH)是否可以连接到Redis Elasticache?

如果你没有在Elasticache上启用AUTH,则可以在没有AUTH的情况下进行连接。AUTH是一个可选的配置设置。

英文:

> Can we connect Redis in Linux without an EC2 instance?

Yes, of course, why would an EC2 instance be an additional requirement? You just need to include a Redis client library in your Lambda function's deployment artifact, and configure the Elasticache cluster to allow inbound traffic from the security group assigned to the Lambda function.

> How do we put AWS redis's endpoint in the main function? (do we only
> need the endpoint? or else)

I would configure the endpoint as one of the Lambda function's environment variables.

> Is it possible to connect to Redis Elasticache with only endpoint
> (without AUTH)?

If you don't enable AUTH on Elasticache, then you can connect without AUTH. AUTH is an optional configuration setting.

huangapple
  • 本文由 发表于 2021年9月14日 00:12:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/69165966.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定