简体   繁体   English

在具有VPC对等功能的不同VPC上,Amazon RDS dbinstance和EC2实例的安全组规则是什么?

[英]What are the security group rules for Amazon RDS dbinstance and EC2 instance over the different VPCs with VPC Peering?

What security group rules should I set for my db instance and my EC2 instance for accessing DB instance from my EC2 instance? 我应该为数据库实例和EC2实例设置哪些安全组规则以从EC2实例访问数据库实例?

Both are in different VPCs and I used VPC Peering between them. 两者都在不同的VPC中,我在它们之间使用了VPC对等。

I did following configuration: 我做了以下配置:

  • I created two VPC's 我创建了两个VPC
  • One is with public subnet and another is with private subnet 一个是使用公共子网,另一个是使用私有子网
  • Launch EC2 web instance with public VPC and MySQL db instance with private subnet 使用公共VPC启动EC2 Web实例,使用私有子网启动MySQL数据库实例
  • Set VPC peering between them and they both have different security groups 在它们之间设置VPC对等,并且它们都具有不同的安全组
  • Created a NAT Gateway in public subnet 在公共子网中创建了NAT网关

So, how should I set both security group rules for establishing connections between them? 因此,如何设置两个安全组规则以在它们之间建立连接?

You should configure: 您应该配置:

  • A security group on the Amazon EC2 instance ( App-SG ) that permits access to the instance/application as desired Amazon EC2实例App-SG上的安全组,该安全组允许根据需要访问该实例/应用程序
  • A security group on the Amazon RDS DB instance ( DB-SG ) that permits inbound access on port 3306 for App-SG Amazon RDS数据库实例DB-SG上的安全组 ,允许在端口3306上对App-SG进行入站访问

That is, DB-SG should specifically refer to App-SG in the inbound rules. 也就是说, DB-SG App-SG在入站规则中应专门引用App-SG

When connecting from the EC2 to the database, make sure you are using the DNS Name of the RDS database. 从EC2连接到数据库时,请确保您使用的是RDS数据库的DNS名称。 This should resolve to a private IP address. 这应该解析为私有IP地址。

The NAT Gateway is not required for the above connection. 上述连接不需要NAT网关。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 terraform 数据库实例和 ec2 安全组在不同的 vpc 中 - terraform the db instance and ec2 security group are in different vpcs 数据库实例和EC2安全组在不同的VPC,cloudFormation错误 - The DB instance and EC2 security group are in different VPCs, cloudFormation error 创建数据库实例时出错:InvalidParameterCombination:数据库实例和 EC2 安全组位于不同的 VPC 中 - Error creating DB Instance: InvalidParameterCombination: The DB instance and EC2 security group are in different VPCs 如何使用aws cli将vpc中实例的ip添加到rds ec2经典实例的安全组 - How to add the ip of an instance in a vpc to the security group of rds ec2 classic instance with aws cli 如果我们使用默认VPC和安全组公开访问“否”,为什么EC2实例无法访问RDS实例? - Why the EC2 instance is not able to access the RDS instance, if we set publicly access to 'No' with default VPC and Security group? 为什么在对等互连后无法从另一个 VPC 中的 EC2 实例连接 AWS RDS 实例 - Why can't I connect AWS RDS instance from EC2 instance in another VPC after peering 无法在非 VPC RDS MySQL 安全组中添加 Ec2 VPC 安全组? - Unable to add Ec2 VPC Security group in Non VPC RDS MySQL Security group? 如何在 AWS 中 ping 在同一 vpc 同一子网但不同安全组中运行的 EC2 实例 - How to ping an EC2 instance running in the same vpc same subnet but different security group in AWS 具有跨VPC对等连接的安全组的Ansible EC2 - Ansible EC2 with security groups across VPC peering connections 适用于SSH的Amazon EC2实例连接-安全组? - Amazon EC2 Instance Connect for SSH - security group?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM