Repository: boto/boto

Issue:
Update AWS Elastic Beanstalk to support worker nodes
Add support for new Tier parameter for CreateEnvironment and UpdateEnvironment.



Discussion:

Resolving patch:
diff --git a/boto/beanstalk/layer1.py b/boto/beanstalk/layer1.py
--- a/boto/beanstalk/layer1.py
+++ b/boto/beanstalk/layer1.py
@@ -237,7 +237,8 @@ def create_environment(self, application_name, environment_name,
                            version_label=None, template_name=None,
                            solution_stack_name=None, cname_prefix=None,
                            description=None, option_settings=None,
-                           options_to_remove=None):
+                           options_to_remove=None, tier_name=None,
+                           tier_type=None, tier_version='1.0'):
         """Launches an environment for the application using a configuration.
 
         :type application_name: string
@@ -308,6 +309,25 @@ def create_environment(self, application_name, environment_name,
             options to remove from the configuration set for this new
             environment.
 
+        :type tier_name: string
+        :param tier_name: The name of the tier.  Valid values are
+            "WebServer" and "Worker". Defaults to "WebServer".
+            The ``tier_name`` and a ``tier_type`` parameters are
+            related and the values provided must be valid.
+            The possible combinations are:
+
+              * "WebServer" and "Standard" (the default)
+              * "Worker" and "SQS/HTTP"
+
+        :type tier_type: string
+        :param tier_type: The type of the tier.  Valid values are
+            "Standard" if ``tier_name`` is "WebServer" and "SQS/HTTP"
+            if ``tier_name`` is "Worker". Defaults to "Standard".
+
+        :type tier_version: string
+        :type tier_version: The version of the tier.  Valid values
+            currently are "1.0". Defaults to "1.0".
+
         :raises: TooManyEnvironmentsException, InsufficientPrivilegesException
 
         """
@@ -330,6 +350,10 @@ def create_environment(self, application_name, environment_name,
         if options_to_remove:
             self.build_list_params(params, options_to_remove,
                                    'OptionsToRemove.member')
+        if tier_name and tier_type and tier_version:
+            params['Tier.member.Name'] = tier_name
+            params['Tier.member.Type'] = tier_type
+            params['Tier.member.Version'] = tier_version
         return self._get_response('CreateEnvironment', params)
 
     def create_storage_location(self):
@@ -848,9 +872,9 @@ def retrieve_environment_info(self, info_type='tail', environment_id=None,
         return self._get_response('RetrieveEnvironmentInfo', params)
 
     def swap_environment_cnames(self, source_environment_id=None,
-                                 source_environment_name=None,
-                                 destination_environment_id=None,
-                                 destination_environment_name=None):
+                                source_environment_name=None,
+                                destination_environment_id=None,
+                                destination_environment_name=None):
         """Swaps the CNAMEs of two environments.
 
         :type source_environment_id: string
@@ -1021,7 +1045,8 @@ def update_configuration_template(self, application_name, template_name,
     def update_environment(self, environment_id=None, environment_name=None,
                            version_label=None, template_name=None,
                            description=None, option_settings=None,
-                           options_to_remove=None):
+                           options_to_remove=None, tier_name=None,
+                           tier_type=None, tier_version='1.0'):
         """
         Updates the environment description, deploys a new application
         version, updates the configuration settings to an entirely new
@@ -1073,6 +1098,25 @@ def update_environment(self, environment_id=None, environment_name=None,
         :param options_to_remove: A list of custom user-defined configuration
             options to remove from the configuration set for this environment.
 
+        :type tier_name: string
+        :param tier_name: The name of the tier.  Valid values are
+            "WebServer" and "Worker". Defaults to "WebServer".
+            The ``tier_name`` and a ``tier_type`` parameters are
+            related and the values provided must be valid.
+            The possible combinations are:
+
+              * "WebServer" and "Standard" (the default)
+              * "Worker" and "SQS/HTTP"
+
+        :type tier_type: string
+        :param tier_type: The type of the tier.  Valid values are
+            "Standard" if ``tier_name`` is "WebServer" and "SQS/HTTP"
+            if ``tier_name`` is "Worker". Defaults to "Standard".
+
+        :type tier_version: string
+        :type tier_version: The version of the tier.  Valid values
+            currently are "1.0". Defaults to "1.0".
+        
         :raises: InsufficientPrivilegesException
         """
         params = {}
@@ -1093,6 +1137,10 @@ def update_environment(self, environment_id=None, environment_name=None,
         if options_to_remove:
             self.build_list_params(params, options_to_remove,
                                    'OptionsToRemove.member')
+        if tier_name and tier_type and tier_version:
+            params['Tier.member.Name'] = tier_name
+            params['Tier.member.Type'] = tier_type
+            params['Tier.member.Version'] = tier_version
         return self._get_response('UpdateEnvironment', params)
 
     def validate_configuration_settings(self, application_name,


Test patch:
diff --git a/tests/unit/beanstalk/test_layer1.py b/tests/unit/beanstalk/test_layer1.py
--- a/tests/unit/beanstalk/test_layer1.py
+++ b/tests/unit/beanstalk/test_layer1.py
@@ -117,3 +117,33 @@ def test_create_environment(self):
             'OptionSettings.member.2.OptionName': 'ENVVAR',
             'OptionSettings.member.2.Value': 'VALUE1',
         })
+
+    def test_create_environment_with_tier(self):
+        self.set_http_response(status_code=200)
+        api_response = self.service_connection.create_environment(
+            'application1', 'environment1', 'version1',
+            '32bit Amazon Linux running Tomcat 7',
+            option_settings=[
+                ('aws:autoscaling:launchconfiguration', 'Ec2KeyName',
+                 'mykeypair'),
+                ('aws:elasticbeanstalk:application:environment', 'ENVVAR',
+                 'VALUE1')],
+            tier_name='Worker', tier_type='SQS/HTTP', tier_version='1.0')
+        self.assert_request_parameters({
+            'Action': 'CreateEnvironment',
+            'ApplicationName': 'application1',
+            'EnvironmentName': 'environment1',
+            'TemplateName': '32bit Amazon Linux running Tomcat 7',
+            'ContentType': 'JSON',
+            'Version': '2010-12-01',
+            'VersionLabel': 'version1',
+            'OptionSettings.member.1.Namespace': 'aws:autoscaling:launchconfiguration',
+            'OptionSettings.member.1.OptionName': 'Ec2KeyName',
+            'OptionSettings.member.1.Value': 'mykeypair',
+            'OptionSettings.member.2.Namespace': 'aws:elasticbeanstalk:application:environment',
+            'OptionSettings.member.2.OptionName': 'ENVVAR',
+            'OptionSettings.member.2.Value': 'VALUE1',
+            'Tier.member.Name': 'Worker',
+            'Tier.member.Type': 'SQS/HTTP',
+            'Tier.member.Version': '1.0',
+        })