Skip to content

Loading…

boto.exception.BotoServerError exception when using boto.ec2.autoscale.launchconfig.LaunchConfiguration #753

Closed
jmevatt opened this Issue · 1 comment

2 participants

@jmevatt

When using boto.ec2.autoscale.AutoScaleConnection (boto 2.3.0, Python 2.7.2) to create a launch configuration (from a valid boto.ec2.autoscale.launchconfig.LaunchConfiguration) with a block device mapping specified, the following error occurs:

Traceback (most recent call last):
  File "cassandra_autoscale_launch.py", line 152, in <module>
    create_as_launch_config("dev", "us-east-1")
  File "cassandra_autoscale_launch.py", line 149, in create_as_launch_config
    print ascale.create_launch_configuration(lc)
  File "/usr/local/lib/python2.7/dist-packages/boto/ec2/autoscale/__init__.py", line 217, in create_launch_configuration
    Request, verb='POST')
  File "/usr/local/lib/python2.7/dist-packages/boto/connection.py", line 917, in get_object
    raise self.ResponseError(response.status, response.reason, body)
boto.exception.BotoServerError: BotoServerError: 400 Bad Request
<ErrorResponse xmlns="http://autoscaling.amazonaws.com/doc/2011-01-01/">
  <Error>
    <Type>Sender</Type>
    <Code>ValidationError</Code>
    <Message>1 validation error detected: Value null at 'blockDeviceMappings.1.member.deviceName' failed to satisfy constraint: Member must not be null</Message>
  </Error>
  <RequestId>76ccdbb0-9ebd-11e1-b999-9987acdb146a</RequestId>
</ErrorResponse>

This is the code I'm using to reproduce it. Note this is not ALL of the code, just the relevant portion to set up the LaunchConfiguration object. I've included some placeholder variables so you can reconfigure the necessary parts for your particular environment.

Assume NUM_EPHEMERAL is some dynamically configured int, we'll set it here for demonstration purposes

NUM_EPHEMERAL = 2

from boto.ec2.autoscale import AutoScaleConnection
from boto.ec2.blockdevicemapping import BlockDeviceMapping
from boto.ec2.blockdevicemapping import BlockDeviceType
from boto.ec2.autoscale.launchconfig import LaunchConfiguration

ascale = AutoScaleConnection(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)

region="us-east-1"

if NUM_EPHEMERAL == 0:
    mapping = None
else:
    mapping = BlockDeviceMapping()
    for i in range(NUM_EPHEMERAL):
        device = BlockDeviceType()
        device_name = "/dev/sd%s" % (chr(ord('b')+i))
        device.ephemeral_name = "ephemeral%i" % i
        mapping[device_name] = device_name

name = "mytestlc"
IMAGES = {'us-east-1' : 'ami-e565ba8c'} # Latest official Amazon AMI
SECURITY_GROUPS = ['dev'] # Replace with your AWS environment's security group
user_data_script = ""
INSTANCE_SIZE = "m1.large"
KEY = "dev" # Replace with your SSH key for your AWS environment

lc = LaunchConfiguration(name=name, image_id=IMAGES[region], key_name=KEY, security_groups=SECURITY_GROUPS, user_data=user_data_script, instance_type=INSTANCE_SIZE, block_device_mappings=[mapping])

ascale.create_launch_configuration(lc)

The last line above is what triggers the error.

The same code block to produce the "mapping" BlockDeviceMapping object has been used to launch many instances with EC2Connection.run_instances().

I added a call to print the "params" variable right before line 916 in connection.py (which is why the line in the output is line 917 as opposed to line 916 as it should be), and this is what it looks like (the UserData key is omitted because it's huge):

{'BlockDeviceMappings.member.1./dev/sdb': <boto.ec2.blockdevicemapping.BlockDeviceType object at 0xfc6e90>, 'BlockDeviceMappings.member.1./dev/sdc': <boto.ec2.blockdevicemapping.BlockDeviceType object at 0xfc6ed0>, 'InstanceMonitoring.Enabled': 'false', 'SecurityGroups.member.1': 'dev', 'ImageId': 'ami-e565ba8c', 'KeyName': 'dev', 'LaunchConfigurationName': 'mytestlc', 'InstanceType': 'm1.large'}

Please let me know if I can be of further assistance to debug this.

Here's some more code to attest that the mapping object is correct. Launching an EC2 instance using the same mapping object works using the following:

from boto.ec2.connection import EC2Connection

ec2 = EC2Connection(aws_access_key_id=AWS_ACCESS_KEY_ID, aws_secret_access_key=AWS_SECRET_ACCESS_KEY)

ec2.run_instances(IMAGES[region], min_count=1, max_count=1, key_name=KEY, security_groups=SECURITY_GROUPS, instance_type=INSTANCE_SIZE, placement=region, monitoring_enabled=0, block_device_map = mapping, user_data = user_data_script)
@toastdriven

Fixed in SHA: 974a23a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.