1

I have included some code that uploads a war file into an s3 bucket (creating the bucket first if it does not exist). It then creates an elastic beanstalk application version using the just-uploaded war file.

Assume /tmp/server_war exists and is a valid war file. The following code will fail with boto.exception.BotoServerError: BotoServerError: 400 Bad Request:

#!/usr/bin/env python

import time

import boto

BUCKET_NAME = 'foo_bar23498'

s3 = boto.connect_s3()
bucket = s3.lookup(BUCKET_NAME)
if not bucket:
  bucket = s3.create_bucket(BUCKET_NAME, location='')

version_label = 'server%s' % int(time.time())

# uplaod the war file
key_name = '%s.war' % version_label
s3key = bucket.new_key(key_name)
print 'uploading war file...'
s3key.set_contents_from_filename('/tmp/server.war',
                                 headers={'Content-Type' : 'application/x-zip'})

# uses us-east-1 by default
eb = boto.connect_beanstalk()

eb.create_application_version(
  application_name='TheApp', 
  version_label=version_label, 
  s3_bucket=BUCKET_NAME, 
  s3_key=key_name, 
  auto_create_application=True)

what would cause this?

groggygreggy
  • 153
  • 2
  • 8

1 Answers1

4

One possible cause of this error is the bucket name. Apparently you can have s3 bucket names that contain underscores, but you cannot create application versions using keys in those buckets.

If you change the fourth line above to

BUCKET_NAME = 'foo-bar23498'

It should work.

Yes, it feels weird to be answering my own question...apparently this the recommended approach for this situation on stack overflow. I hope I save someone else a whole lot of debugging time.

groggygreggy
  • 153
  • 2
  • 8