fix lambda endpoint parsing (#1395)
* fix endpoint parsing * add new unittest * finish test
This commit is contained in:
parent
2faffc96de
commit
941d817da4
3 changed files with 80 additions and 9 deletions
|
|
@ -100,9 +100,21 @@ class Subscription(BaseModel):
|
|||
requests.post(self.endpoint, json=post_data)
|
||||
elif self.protocol == 'lambda':
|
||||
# TODO: support bad function name
|
||||
function_name = self.endpoint.split(":")[-1]
|
||||
region = self.arn.split(':')[3]
|
||||
lambda_backends[region].send_message(function_name, message, subject=subject)
|
||||
# http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html
|
||||
arr = self.endpoint.split(":")
|
||||
region = arr[3]
|
||||
qualifier = None
|
||||
if len(arr) == 7:
|
||||
assert arr[5] == 'function'
|
||||
function_name = arr[-1]
|
||||
elif len(arr) == 8:
|
||||
assert arr[5] == 'function'
|
||||
qualifier = arr[-1]
|
||||
function_name = arr[-2]
|
||||
else:
|
||||
assert False
|
||||
|
||||
lambda_backends[region].send_message(function_name, message, subject=subject, qualifier=qualifier)
|
||||
|
||||
def _matches_filter_policy(self, message_attributes):
|
||||
# TODO: support Anything-but matching, prefix matching and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue