CloudFormation:用于创建数据库,表,用户或加载架构的模板RDS Mysql [英] CloudFormation : Template RDS Mysql to Create DB, Tables, User, or Load Schema

查看:119
本文介绍了CloudFormation:用于创建数据库,表,用户或加载架构的模板RDS Mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用CloudFormation,我试图找出一些用例.

Using CloudFormation, I'm trying to figure out a few use cases.

第一种情况是拥有现有的AWS RDS MySQL服务器,如何通过CloudFormation模板创建数据库,表和用户帐户.

The first case is having an existing AWS RDS MySQL server, how to create a database, tables, and a user account though a CloudFormation template.

查看Cloudformation文档后,我认为可能会有一个 AWS::RDS::DBInstance属性,使我可以执行此操作;但是,尽管我找不到如何指定允许的数据库主机源(或者我可能读错了).

After looking at the Cloudformation docs, I thought there could be a AWS::RDS::DBInstance property that would allow me to do this action; however, though I couldn't find how to specify a database host source (or I may have misread it) that would allow.

aws-properties-rds-database-instance

然后,查看来自AWS的Cloudformation RDS模板,我看到了一个引人注目的fn::join命令.我的第一种情况会用fn::join完成吗?

then, looking at the Cloudformation RDS templates from AWS, I saw an fn::join command that stood out. Would my first case be done with fn::join?

"UserData": { "Fn::Base64": { "Fn::Join": ["", [....

接下来,在第二种情况下,我也很难找到如何使用现有的RDS MySQL服务器,如何从MySQL mysqldump加载方案.

Next, in the second case, I'm also having trouble finding how using an existing RDS MySQL server, load a scheme from a MySQL mysqldump.

我已经在上面的链接中查看了文档,但并不确定.我注意到AWS模板主要允许您创建资源.

I've looked at the docs in the link above for answers but not quite sure. I noticed AWS templates mostly allow you to create resources.

最后,为解决以上两种情况,我还阅读了可以或应该使用两个工具的方法,通过使用AWS CloudFormation模板并调用Chef来完成它.

Lastly, to solve the above two cases, I've also been reading that it could or should(?) be done using a two tool approach by way of using an AWS CloudFormation template and calls to Chef.

有想法吗?

推荐答案

简短的答案是:您现在不能在实例创建时自动运行SQL查询(将来,谁知道...).

Short answer is : you can't, right now, automatically run SQL queries at instance creation (in the future, who knows...).

我将通过以下方式解决此经典问题:

I would use the following way to resolve this classic problem:

  • 使用EC2运行所需的MySQL代码(不确定是否需要在EC2中放置"DependsOn"子句,因为您将不得不使用GetAtt引用RDS端点,这可能会放置一个隐式DependsOn子句).只要将RDS终结点以某种方式传递,就可以将其放入用户数据或所需的任何脚本中.当然,您将需要在EC2上安装MySQL客户端软件包.

正如您所写,CloudFormation允许您创建AWS资源,但是由您自己决定是否要填充这些资源.再次,一个MySQL客户端将解决这个问题(因为MySQL转储只不过是文件中的SQL代码,与您的初始要求相同).

As you wrote, CloudFormation allows you to create AWS resources, but populationg those resources is up to you. Once again, a MySQL client will do the trick (since a MySQL dump is no more than SQL code in a file, same as your initial requirement).

仅使用Chef或Puppet不能单独解决您的问题,因为两者都需要在EC2上安装代理,因此您无法在RDS服务器中运行代理.因此,您可以使用Chef或Puppet代理获得EC2,这将反过来启动MySQL脚本,但这不会比以前的解决方案提供更多的功能

Using Chef or Puppet will not solve your problem alone, since both need an agent installed on an EC2, you cannot run your agent in the RDS server. So you can have an EC2 using a Chef or Puppet agent, which will in turn launch the MySQL script, but this will not give you much more than the previous solution

这篇关于CloudFormation:用于创建数据库,表,用户或加载架构的模板RDS Mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆