Question

I am not a JSON expert but I was able to manipulate the AWS Beanstalk VPC cloudformation template to pull a .WAR file from S3 and deploy as a new application. I also manipulated the script to create 2 additional subnets 1 for public and the other for private as opposed to the original script which only created 2 subnets. I am having an issue with the below piece of code. I need to manipulate so the EC2 instance and ELB use the additional subnets I created in the script.So for the value Subnets I will need to add PrivateSubnet and PrivateSubnet2. The same will be the same for the ELBs value.

"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"
  }
}

},

Any help will be appreciated..

Was it helpful?

Solution

Ran across this while I was trying to find the answer to the same question

The OptionName Value needs to be a single comma delimited string e.g "a,b"

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

Unlike the SubnetIDs in RDSSubnetGroup where you can just list the subnetids e.g "a","b"

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

I used the intrinsic join function to join a few references further up in my template into one string.

{
  "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"} ] ] } 
},
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top