AWS CLI创建RDS与elasticbeanstalk创造环境 [英] AWS CLI create RDS with elasticbeanstalk create-environment

查看:286
本文介绍了AWS CLI创建RDS与elasticbeanstalk创造环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能创建一个创建环境 AWS elasticbeanstalk 的另一子的RDS实例?我试过参数的几种组合都无济于事。下面是一个例子。

How can I create an RDS instance with the create-environment or another subcommand of aws elasticbeanstalk? I've tried several combinations of parameters to no avail. Below is an example.

APP_NAME="randall-railsapp"
aws s3api create-bucket --bucket "$APP_NAME"
APP_VERSION="$(git describe --always)"
APP_FILE="deploy-$APP_NAME-$APP_VERSION.zip"
git archive -o "$APP_FILE" HEAD
aws s3 cp "$APP_FILE" "s3://$APP_NAME/$APP_FILE"

aws --region us-east-1 elasticbeanstalk create-application-version \
--auto-create-application \
--application-name "$APP_NAME" \
--version-label "$APP_VERSION" \
--source-bundle S3Bucket="$APP_NAME",S3Key="$APP_FILE"

aws --region us-east-1 elasticbeanstalk create-environment \
--application-name "$APP_NAME" \
--version-label "$APP_VERSION" \
--environment-name "$APP_NAME-env" \
--description "randall's rails app environment" \
--solution-stack-name "64bit Amazon Linux 2014.03 v1.0.0 running Ruby 2.1 (Puma)" \
--cname-prefix "$APP_NAME-test" \
--option-settings file://test.json

和内容 test.json

[
{
    "OptionName": "EC2KeyName",
    "Namespace": "aws:autoscaling:launchconfiguration",
    "Value": "a-key-is-here"
},
{
    "OptionName": "EnvironmentType",
    "Namespace": "aws:elasticbeanstalk:environment",
    "Value": "SingleInstance"
},
{
    "OptionName": "SECRET_KEY_BASE",
    "Namespace": "aws:elasticbeanstalk:application:environment",
    "Value": "HAHAHAHAHAHA"
},
{
    "OptionName": "DBPassword",
    "Namespace": "aws:rds:dbinstance",
    "Value": "hunter2"
},
{
    "OptionName": "DBUser",
    "Namespace": "aws:rds:dbinstance",
    "Value": "random"
},
{
    "OptionName": "DBEngineVersion",
    "Namespace": "aws:rds:dbinstance",
    "Value": "9.3"
},
{
    "OptionName": "DBEngine",
    "Namespace": "aws:rds:dbinstance",
    "Value": "postgres"
}
]

任何人都知道这是为什么失败?什么我有一个 AWS注明:RDS:dbinstance具备命名空间似乎从配置得到删除

Anyone know why this is failing? Anything I specify with a aws:rds:dbinstance namespace seems to get removed from the configuration.

推荐答案

只需设置AWS:RDS:dbinstance具备选择不创建一个RDS数据库。 目前,您可以使用以下方法之一创建一个RDS实例:

Just setting the aws:rds:dbinstance options does not create an RDS database. Currently you can create an RDS instance using one of the following techniques:

  1. 创建使用AWS控制台
  2. 使用 EB CLI
  3. ebextensions使用参考资料部分创建RDS资源
  1. Create using AWS Console
  2. Use eb cli
  3. Use Resources section of ebextensions to create an RDS resource

前两种方法是最方便的,因为他们做的所有繁重的你,但在第三个你必须做一些额外的工作。第三种方法是,你会想,如果你不使用控制台或EB CLI来使用的。

The first two approaches are the most convenient as they do all the heavy lifting for you but for the third one you have to do some extra work. The third approach is what you would want to use if you are not using the console or eb CLI.

您可以创建使用以下ebextension段的豆茎环境的RDS资源。创建一个名为 01-rds.config 文件在你的应用程序源代码的 .ebextensions 目录。

You can create an RDS resource for your beanstalk environment using the following ebextension snippet. Create a file called 01-rds.config in the .ebextensions directory of your app source.

Resources:
    AWSEBRDSDatabase:
        Type: AWS::RDS::DBInstance
        Properties:
            AllocatedStorage: 5
            DBInstanceClass: db.t2.micro
            DBName: myawesomeapp
            Engine: postgres
            EngineVersion: 9.3
            MasterUsername: myAwesomeUsername
            MasterUserPassword: myCrazyPassword

这文件是YAML格式,以便缩进是非常重要的。你也可以使用JSON,如果你喜欢。 这些都不是选项设置,所以你不能把它作为 - 选项 - 设置test.json 。你只需要使用你的应用程序源代码包文件。

This file is in YAML format so indentation is important. You could also use JSON if you like. These are not option settings so you cannot pass it as --option-settings test.json. You just need to bundle this file with your app source.

了解更多您可以在您的RDS数据库配置什么样的属性<一个href="http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html"相对=nofollow>此处。在这个页面,你还可以找到哪些属性是必需的,哪些属性是可选的。

Read more about what properties you can configure on your RDS database here. On this page you can also find what properties are required and what properties are optional.

让我知道,如果上述方法不适合你,或者如果您有任何进一步的问题。

Let me know if the above does not work for you or if you have any further questions.

这篇关于AWS CLI创建RDS与elasticbeanstalk创造环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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