Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeDeploy does not work when region is specified. #3259

Closed
mjallday opened this issue Jul 2, 2015 · 1 comment
Closed

CodeDeploy does not work when region is specified. #3259

mjallday opened this issue Jul 2, 2015 · 1 comment
Labels

Comments

@mjallday
Copy link

mjallday commented Jul 2, 2015

Maybe I'm using it incorrectly, I'm not sure. Here's what I've got:

import boto
profile_name = 'xxx'
region = ... # RegionInfo:us-east-1
cd_conn = boto.connect_codedeploy(region=region, profile_name=profile_name)
cd_conn.get_application('foo')

gives me the error:

<?xml version="1.0" encoding="UTF-8"?>\n<Response><Errors><Error><Code>InvalidHttpRequest</Code><Message>The HTTP request is invalid. Reason: Unable to parse request</Message></Error></Errors><RequestID>c5908e08-c014-47ff-a0b0-325f8f7244a8</RequestID></Response>

from the request

Headers

{'Authorization': u'AWS4-HMAC-SHA256 Credential=AKIAXXXXXX/20150702/us-east-1/ec2/aws4_request,SignedHeaders=host;x-amz-date;x-amz-target,Signature=XXXXX',
 'Content-Length': '33',
 'Content-Type': 'application/x-amz-json-1.1',
 'Host': 'ec2.us-east-1.amazonaws.com',
 'User-Agent': 'Boto/2.38.0 Python/2.7.8 Darwin/14.3.0',
 'X-Amz-Date': '20150702T000750Z',
 'X-Amz-Target': 'CodeDeploy_20141006.GetApplication'}

Body

'{"applicationName": "vault-http"}'

If the region is omitted,then it connects as you would expect.

from the request:

Headers

{'Content-Length': '33',
 'Content-Type': 'application/x-amz-json-1.1',
 'Host': 'codedeploy.us-east-1.amazonaws.com',
 'X-Amz-Target': 'CodeDeploy_20141006.GetApplication'}

this is boto 2.38.0

The major difference I can see is that the endpoint uses DefaultRegionEndpoint with a value of "codedeploy.us-east-1.amazonaws.com" rather than ec2.us-east-1.amazonaws.com.

Am I misusing the library? To work around this issue I'm doing this hack:

cd_conn = boto.connect_codedeploy(profile_name=profile_name)
cd_region = boto.regioninfo.RegionInfo(
    cd_conn, name=region_name, endpoint='codedeploy.' + region_name + '.amazonaws.com'
)
cd_conn.region = cd_region
@jamesls
Copy link
Member

jamesls commented Jul 2, 2015

You can use the connect_to_region() to connect to a specific region for an AWS Service:

>>> import boto.codedeploy
>>> client = boto.codedeploy.connect_to_region('us-east-1')
>>> client.list_applications()

Let me know if that isn't working for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants