首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AWS弹性redis redis集群配置

AWS弹性redis redis集群配置
EN

Stack Overflow用户
提问于 2022-06-29 00:25:43
回答 1查看 304关注 0票数 0

我对地形有点陌生,在这个问题上,我曾经也需要一些帮助。它创建了相应的资源,但是当连接到端点时,我会得到一个超时。我注意到安全组实际上并没有被创建,但我不知道为什么。任何帮助都将不胜感激。

配置:

代码语言:javascript
复制
provider "aws" {
  region = "us-west-2"
}

resource "aws_elasticache_cluster" "example" {
  cluster_id           = "cluster-example"
  engine               = "redis"
  node_type            = "cache.m4.large"
  num_cache_nodes      = 1
  parameter_group_name = "default.redis3.2"
  engine_version       = "3.2.10"
  port                 = 6379
}

resource "aws_security_group" "example" {
  name        = "example"
  description = "Used by the example Redis cluster"
  vpc_id      = "${aws_vpc.example.id}"

  ingress {
    description      = "TLS from VPC"
    from_port        = 443
    to_port          = 443
    protocol         = "tcp"
    cidr_blocks      = [aws_vpc.example.cidr_block]
  }

  egress {
    from_port        = 0
    to_port          = 0
    protocol         = "-1"
    cidr_blocks      = ["0.0.0.0/0"]
    ipv6_cidr_blocks = ["::/0"]
  }
}

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

  tags = {
    Name = "example"
  }
}

resource "aws_subnet" "example" {
  vpc_id     = "${aws_vpc.example.id}"
  cidr_block = "10.0.0.0/20"

  tags = {
    Name = "example"
  }
}

resource "aws_elasticache_subnet_group" "example" {
  name        = "example"
  description = "Example subnet group"
  subnet_ids  = ["${aws_subnet.example.id}"]
}

与端点的连接:

代码语言:javascript
复制
import os
import redis

ENDPOINT = os.environ.get('REDIS_HOST')

client = redis.Redis(host=ENDPOINT, port=6379, db=0)

client.ping()

(无密码簇)

编辑:我在本地机器上调用python中的端点。

EN

回答 1

Stack Overflow用户

发布于 2022-06-29 00:48:25

您不能直接从AWS外部访问EC集群,因为它可以只能从VPC访问。如果要从家庭网络连接,则必须使用VPN、直接连接或SSH隧道。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72794506

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档