-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPublishToEVent_Updated
52 lines (50 loc) · 1.17 KB
/
PublishToEVent_Updated
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import json
import boto3
from datetime import datetime
def lambda_handler(event, context):
# TODO implement
print(event)
client= boto3.client('events')
response = client.create_event_bus(
Name='travel_data_by_code',
Tags=[
{
'Key': 'sealid',
'Value': '110397'
},
]
)
response = client.put_rule(
Name='Event_rule_by_code',
EventPattern='{"detail": {\
"source": ["orxe", "maui"],\
"object": ["orders", "transactions"]\
}}'
,
State='ENABLED',
Description='Event_rule_by_code',
#,RoleArn='string',
Tags=[
{
'Key': 'sealid',
'Value': '110397'
},
],
EventBusName='traveleventbus'
)
response = client.put_events(
Entries=[{
'Time': datetime(2015, 1, 1),
'Source': 'orxe',
'Resources': [],
'DetailType': "test_send_events",
'Detail': json.dumps(event),
'EventBusName': "arn:aws:events:us-east-1:211631851183:event-bus/traveleventbus"
},
]
)
return response
# {
# 'statusCode': 200,
# 'body': json.dumps('Hello from Lambda!')
# }