2014-03-13 50 views
2

我几天前开始使用AWS。AWS:使用Cloud Formation和现有密钥对部署堆栈

我想使用Cloud Formation服务部署一个堆栈,然后能够将SSH部署到部署的实例中。在创建模板时,我没有看到包含密钥对的选项。

根据this,我需要从一开始就有一个密钥对。

如何使用密钥对部署堆栈,以便在部署完成后可以进入SSH?

我也试图通过增加下的参数键名段改变在一个文本文件的模板:

"Parameters" : { 
"AccessControl" : { 
    "Description" : " The IP address range that can be used to access the CloudFormer tool. NOTE: We highly recommend that you specify a customized address range to lock down the tool.", 
    "Type": "String", 
    "MinLength": "9", 
    "MaxLength": "18", 
    "Default": "0.0.0.0/0", 
    "AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})", 
    "ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x." 
} 

"KeyName" : { 
    "Description" : " Name of an existing EC2 KeyPair to enable SSH access to the instances", 
    "Type": "String", 
    "MinLength": "1", 
    "MaxLength": "64", 
    "AllowedPattern": "[-_ a-zA-Z0-9]*", 
    "ConstraintDescription": "Can contain only alphanumeric characters, spaces, dashes, and underscores." 
} 

这将导致以下错误:“模板验证错误:模板格式错误:JSON格式不正确“。

我希望能够远程访问Linux和Windows实例。

回答

0

您需要创建密钥,然后将密钥的名称用作Cloud Formation脚本的参数。

JSON错误可能是由于AccessControl属性值关闭后缺少逗号造成的。

http://jsonlint.com/有一个JSON验证器,它将突出显示这些类型的格式错误。

1

您可以使用 “默认” 来指定一个默认的键名

    "KeyPair" : { 
      "Type" : "String", 
      "Default" : "MyKeyName", 
      "Description" : "Enter a keypair for this instance" 
    } 

然后在 “属性”

"Properties": { 
     "KeyName": { "Ref": "KeyPair" }, 
+0

谢谢你,我的作品。 :) – Kino

相关问题