如何使用AWS SSM在RD上运行一些SQL查询
我正在尝试在私人子网中对RD进行一些查询。经过一番研究,结果证明SSM是最好的选择。现在我有一些问题。
我是否需要在私有子网中使用SSM代理创建EC2实例来运行此类查询?
I am trying to run some queries on RDS in a private subnet. After a bit of research, turned out the SSM is the best option. Now I have some questions.
Do I need to create an ec2 instance with an SSM agent in the private subnet To run such queries?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如@mark B在他的评论中所建议的那样,只要您适当地配置了附加到EC2的子网和安全组,就可以在VPC中的任何子网中在EC2实例中运行SQL查询。
现在,从您的问题来看,尚不清楚为什么您喜欢AWS SSM以及您的用例是什么。因此,我假设您正在使用AWS SSM存储DB凭据。
如果您只想从EC2实例运行SQL查询,则不需要AWS SSM,除非您有特定的用例。您基本上可以使用
psql
运行SQL查询;为了使上述命令成功,您需要在
pgpassword
环境变量中拥有DB密码。例如;现在,从您的问题中不清楚为什么您要使用EC2或您的用例是什么,但是您还可以通过在适当的子网中配置并将其分配一个正确的安全组来探索通过Lambda函数运行查询。
一个建议:在发布问题之前,请从一个人的角度阅读,谁不知道您要做什么。只要您为我们提供正确的上下文并提供足够的信息,我们将在这里为您提供帮助。
As @Mark B suggested in his comment, you can run your SQL queries in EC2 instance in any subnet in a VPC as long as you have properly configured your inbound and outbound rules for your subnet and security group attached to your EC2.
Now, from your question, it is not clear as why you prefer AWS SSM and what is your use-case for it. So I am assuming you are using AWS SSM to store your DB credentials.
If you just want to run SQL query from your EC2 instance, you don't need AWS SSM as such unless you have a specific use-case. You can basically run SQL query using
psql
as follows;For the above command to succeed, you need to have DB password in
PGPASSWORD
environment variable. For example;Now, again, it is not clear from your question as why you are using EC2 or what is your use-case here but you can also explore running your query through Lambda function by configuring it in proper subnet and assigning it a right security group.
A piece of advice: Before posting question, read it from a person's perspective who does not have any idea what you are trying to do. We are all here to help you as long as you provide us the right context and provide enough info to start with.