2017-08-04 94 views
0

我定義我的參數是這樣的:AWS cloudformation -resource屬性錯誤

"InstanceSecurityGroup" : { 
     "Type" : "AWS::EC2::SecurityGroup", 
     "Properties" : { 
     "VpcId" : {"Ref": "VPCLIST"} , 
     "GroupDescription" : "Enable 3306/80/SSH access via port 22" 
} 

,並在執行這個我:

{ 
    "PrivateSubnets":{ 
     "Description":"db subnetlist", 
     "Type": "List<AWS::EC2::Subnet::Id>" 
    }, 

    "VPCLIST": { 
     "Description": "VPC list", 
     "Type": "List<AWS::EC2::VPC::Id>" 
    } 
} 

和「資源」像部分以下,參照上述參數得到下面的錯誤。

AWS EC2 :: :: SecurityGroup InstanceSecurityGroup 「屬性VpcId的值必須是String類型的」

注:我只默認VPC可用它未作爲字符串?對此問題的任何解決方案...

+0

下面是錯誤信息:錯誤 無法列出數據:內部故障 –

回答

0

安全組要求VpcId是一個字符串,屬性是一個數組列表,因此您需要將該屬性更改爲Type:String,或使用 Fn::Select函數。

{ "Fn::Select" : [ 0, VPCLIST ] } 

列表 - VPC ID的數組

{ 
    "Type" : "AWS::EC2::SecurityGroup", 
    "Properties" : { 
    "GroupName" : String, 
    "GroupDescription" : String, 
    "SecurityGroupEgress" : [ Security Group Rule, ... ], 
    "SecurityGroupIngress" : [ Security Group Rule, ... ], 
    "Tags" : [ Resource Tag, ... ], 
    "VpcId" : String 
    } 
} 

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-ec2-security-group.html

0

正確的做法應該是讓這種變化:

{ 
    "PrivateSubnets": { 
    "Description":"db subnetlist", 
    "Type": "AWS::EC2::Subnet::Id" 
    }, 
    "VPCLIST": { 
    "Description": "VPC list", 
    "Type": "AWS::EC2::VPC::Id" 
    } 
}