0

Boto has a function, update_environment, that allows the user to update options in an AWS ElasticBeanstalk environment.

Using the AWS CLI, this would typically be actioned as follows:

aws elasticbeanstalk update-environment --environment-name my-env --option-settings Namespace=aws:autoscaling:asg,OptionName=MinSize,Value=1

In Boto, update_environment takes a List parameter for option_settings, as described here:

http://boto.readthedocs.org/en/latest/ref/beanstalk.html

update_environment(environment_id=None, environment_name=None, version_label=None, template_name=None, description=None, option_settings=None, options_to_remove=None, tier_name=None, tier_type=None, tier_version='1.0')

I've tried various methods of passing the string

Namespace=aws:autoscaling:asg,OptionName=MinSize,Value=1

as a List, but none seem to work. The API keeps telling me:

Invalid option specification 

Does anyone know what the correct format for the List is?

Garreth McDaid
  • 3,449
  • 1
  • 27
  • 42

2 Answers2

1

Figured it out by looking at the Python source code for boto. Correct format is:

option_settings=[("aws:autoscaling:asg","MinSize","1"),("aws:autoscaling:asg","MaxSize","4")]
Garreth McDaid
  • 3,449
  • 1
  • 27
  • 42
0

This is the code is working for me.

try: client = boto3.client('elasticbeanstalk', region_name=AWS_REGION) response = client.update_environment( EnvironmentName='envname', OptionSettings=[ { 'Namespace': 'aws:autoscaling:asg:launchconfiguration', 'OptionName': 'MinSize', 'Value': '0' }, { 'Namespace': 'aws:autoscaling:asg:launchconfiguration', 'OptionName': 'MaxSize', 'Value': '0' } ],) except ClientError as err: print("Failed to update environment.\n" + str(err)) return False return True