-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathpackaged.yaml
69 lines (68 loc) · 1.83 KB
/
packaged.yaml
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
AWSTemplateFormatVersion: '2010-09-09'
Description: 'lambda-iot-rule
'
Outputs:
ApiURL:
Description: API endpoint URL for Prod environment
Value:
Fn::Sub: https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/
Parameters:
PublishTopic:
Default: topic_1
Description: (Required) Provide a topic to publish on. The default will publish
on topic_1
Type: String
SubscribeTopic:
Default: topic_2
Description: (Required) Provide a topic for the IoT rule to query. The default
will trigger on any message published to topic_2
Type: String
Resources:
MyTable:
Type: AWS::Serverless::SimpleTable
TopicPublisher:
Properties:
CodeUri: s3://sar-moheeb-zara-aws/4949ad71178fd3d56f8af634a4c0359e
Environment:
Variables:
PUBLISH_TOPIC:
Ref: PublishTopic
Events:
PostResource:
Properties:
Method: post
Path: /publish
Type: Api
Handler: app.handler
Policies:
- Statement:
- Action:
- iot:Publish
- iot:DescribeEndpoint
Effect: Allow
Resource: '*'
Version: '2012-10-17'
Runtime: nodejs10.x
Type: AWS::Serverless::Function
TopicSubscriber:
Properties:
CodeUri: s3://sar-moheeb-zara-aws/df8ba6fcd03c22bcbd2d6df9daade17d
Environment:
Variables:
TABLE_NAME:
Ref: MyTable
Events:
IoT:
Properties:
AwsIotSqlVersion: 2016-03-23
Sql:
Fn::Sub: SELECT * FROM '${SubscribeTopic}'
Type: IoTRule
Handler: app.handler
Policies:
- DynamoDBCrudPolicy:
TableName:
Ref: MyTable
Runtime: nodejs10.x
Type: AWS::Serverless::Function
Transform: AWS::Serverless-2016-10-31