-
Notifications
You must be signed in to change notification settings - Fork 0
/
iot.yaml
79 lines (78 loc) · 2.19 KB
/
iot.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
70
71
72
73
74
75
76
77
78
79
AWSTemplateFormatVersion: 2010-09-09
Parameters:
RuleName:
Description: Enter topic rule name
Type: String
Default: simulator_rule
Resources:
ElasticsearchDomain:
Type: AWS::Elasticsearch::Domain
DeletionPolicy: Retain
Properties:
DomainName: !Sub iot-es-${AWS::Region}
ElasticsearchClusterConfig:
DedicatedMasterEnabled: false
InstanceCount: 1
ZoneAwarenessEnabled: false
InstanceType: m3.medium.elasticsearch
EBSOptions:
EBSEnabled: false
SnapshotOptions:
AutomatedSnapshotStartHour: 0
AccessPolicies:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
AWS: '*'
Action: 'es:*'
Resource: '*'
AdvancedOptions:
rest.action.multi.allow_explicit_index: 'true'
AWSESDomainActionPolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
PolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Action: es:ESHttpPut
Resource:
- !GetAtt ElasticsearchDomain.DomainArn
AWSESDomainActionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
- Effect: Allow
Principal:
Service: iot.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
- !Ref AWSESDomainActionPolicy
AWSIoTRule:
Type: AWS::IoT::TopicRule
Properties:
RuleName: !Ref RuleName
TopicRulePayload:
Actions:
- Elasticsearch:
Endpoint: !Join
- ''
- - http://
- !GetAtt ElasticsearchDomain.DomainEndpoint
Id: ${timestamp()}
Index: simulator_index
RoleArn: !GetAtt AWSESDomainActionRole.Arn
Type: simulator_mapping
AwsIotSqlVersion: beta
Description: Iot rule for simulation
RuleDisabled: false
Sql: !Sub SELECT * FROM 'iot/blog/${RuleName}'
Outputs:
IOTRuleName:
Description: IoT Rule Name used to process rules
Value: !Ref RuleName
Export:
Name: IOTRuleName