2

我不是JSON專家,但我能夠操縱AWS Beanstalk VPC cloudformation模板以從S3抽取.WAR文件並將其部署爲新應用程序。我還操縱腳本爲public創建了另外兩個子網1,另一個用於私有,而不是僅創建2個子網的原始腳本。我遇到了下面一段代碼的問題。我需要操作,以便EC2實例和ELB使用我在腳本中創建的其他子網。所以對於值子網我需要添加PrivateSubnetPrivateSubnet2ELBs的值也是一樣的。向ELB和子網添加子網Cloudformation Beanstalk腳本中的值

"SampleEnvironment" : { 
    "Type" : "AWS::ElasticBeanstalk::Environment", 
    "Properties" : { 
    "ApplicationName" : { "Ref" : "SampleApplication" }, 
    "EnvironmentName" : "Sandbox", 
    "Description" : "AWS Elastic Beanstalk Environment running Python Sample Application", 
    "SolutionStackName" : "64bit Amazon Linux 2014.02 running Tomcat 7 Java 7", 
    "OptionSettings" : [ 
     {"Namespace" : "aws:autoscaling:launchconfiguration", "OptionName" : "SSHSourceRestriction", "Value" : { "Fn::Join" : [ "", ["tcp,22,22,", { "Ref" : "BastionSecurityGroup" }]]}}, 
     {"Namespace" : "aws:autoscaling:launchconfiguration", "OptionName" : "SecurityGroups", "Value" : { "Ref" : "BeanstalkSecurityGroup" }}, 
     {"Namespace" : "aws:autoscaling:launchconfiguration", "OptionName" : "EC2KeyName", "Value" : { "Ref" : "InstanceKeyName" }}, 
     {"Namespace" : "aws:ec2:vpc", "OptionName" : "VPCId", "Value" : { "Ref" : "VPC" }}, 
     {"Namespace" : "aws:ec2:vpc", "OptionName" : "Subnets", "Value" : { "Ref" : "PrivateSubnet" }}, 
     {"Namespace" : "aws:ec2:vpc", "OptionName" : "ELBSubnets", "Value" : { "Ref" : "PublicSubnet" }}], 
    "VersionLabel" : "Initial Version" 
    } 
} 

},

任何幫助將不勝感激..過這個,而我試圖找到答案對同一問題

+0

你在哪裏創建額外的子網?在同一個CloudFormation模板中?請添加這些細節。 – Jason

+0

是的,它們都在相同的腳本/模板中。 – user2040074

回答

3

的OPTIONNAME值需要一個單逗號分隔字符串例如「a,b」

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-beanstalk-option-settings.html

不像RDSSubnetGroup的SubnetIDs在那裏你可以列出subnetids如「A」,「B」

http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbsubnet-group.html

我用內在的聯接功能,進一步加入一些參考在我的模板到一個字符串。

{ 
    "Namespace" : "aws:ec2:vpc", 
    "OptionName" : "Subnets", 
    "Value" : { "Fn::Join" : [ ",", [ { "Ref": "PrivateSubnetAvailabiltyZoneA" }, {"Ref": "PrivateSubnetAvailabiltyZoneB"} ] ] } 
}, 
{ 
    "Namespace" : "aws:ec2:vpc", 
    "OptionName" : "ELBSubnets", 
    "Value" : { "Fn::Join" : [ ",", [ { "Ref": "PublicSubnetAvailabiltyZoneA" }, {"Ref": "PublicSubnetAvailabiltyZoneB"} ] ] } 
}, 
+0

感謝使用連接功能,它允許添加不同的網絡。 – user2040074

相關問題