查明put_events从lambda函数NotFoundException



我已经建立了一个AWS PinPoint项目,我正试图通过从lambda函数发送一个事件来测试它:

import boto3
import datetime
import time
client = boto3.client('pinpoint')
app_id = '1234abcd'
endpoint_id = 'test_endpoint'
address = 'test@test.com'
def lambda_handler(event, context):

response = client.put_events(
ApplicationId = app_id,
EventsRequest={
'BatchItem': {
endpoint_id: {
'Endpoint': {
'ChannelType': 'EMAIL',
'Address': address,
'Attributes': {
'Cart': ['Hat'],
'Purchased': ['No']
}
},
'Events':{
'cart-event-2': {
'Attributes':{
'AddedToCart': 'Hat'
},
'EventType': 'AddToCartEvent',
'Metrics': {
'price': 29.95
},
'Timestamp': datetime.datetime.fromtimestamp(time.time()).isoformat()
}
}
}
} 
}
)
return response

但是我收到一个错误,无法找到资源,即使我可以在Pin Point控制台看到它:

{
"errorMessage": "An error occurred (NotFoundException) when calling the PutEvents operation: Resource not found",
"errorType": "NotFoundException",
"requestId": "xxxxx-xxxxx-xxxx-xxxx-xxxxxxxxx",
"stackTrace": [
"  File "/var/task/lambda_function.py", line 12, in lambda_handlern    response = client.put_events(n",
"  File "/var/runtime/botocore/client.py", line 391, in _api_calln    return self._make_api_call(operation_name, kwargs)n",
"  File "/var/runtime/botocore/client.py", line 719, in _make_api_calln    raise error_class(parsed_response, operation_name)n"
]
}

原来我只是在我的AWS账户上的错误区域。🧠我在一个区域创建了AWS精确项目,但试图从另一个AWS区域向该项目发送事件,这就是为什么我得到NotFoundException。

相关内容

  • 没有找到相关文章

最新更新