-
Notifications
You must be signed in to change notification settings - Fork 3
/
template.yml
executable file
·180 lines (158 loc) · 5.39 KB
/
template.yml
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
AWSTemplateFormatVersion: 2010-09-09
Transform:
- AWS::Serverless-2016-10-31
# Template Information
Description: "Google Home and Alexa bridge for IoT Core"
# Template Metadata
Metadata:
AWS::ServerlessRepo::Application:
Name: eliot
Description: "Google Home and Alexa bridge for IoT Core"
Author: Fabio Gollinucci
SpdxLicenseId: GPL-3.0-only
LicenseUrl: LICENSE
ReadmeUrl: README.md
HomePageUrl: https://github.com/eliot-iot/eliot/blob/master/README.md
SourceCodeUrl: https://github.com/eliot-iot/eliot
Labels: ['eliot', 'alexa', 'google', 'google-home', 'google-assistant', 'iot', 'iot-core', 'home-automation']
# Template Parameters
Parameters:
ClientId:
Type: String
Description: "OAuth2 client ID"
MinLength: 20
AllowedPattern: ".+"
ConstraintDescription: "Client ID is required and must have at least 20 chars"
NoEcho: true
ClientSecret:
Type: String
Description: "OAuth2 client secret"
MinLength: 40
AllowedPattern: ".+"
ConstraintDescription: "Client secret is required and must have at least 40 chars"
NoEcho: true
GoogleProjectId:
Type: String
Description: "Google Project ID"
Default: ""
GoogleJwt:
Type: String
Description: "Google JWT token"
NoEcho: true
Default: ""
AlexaSkillId:
Type: String
Description: "Alexa Skill ID"
Default: ""
AlexaClientId:
Type: String
Description: "Alexa Client ID"
NoEcho: true
Default: ""
AlexaClientSecret:
Type: String
Description: "Alexa Client Secret"
NoEcho: true
Default: ""
AlexaEndpoint:
Type: String
Description: "Alexa Endpoint"
Default: "Europe"
AllowedValues:
- NorthAmerica
- Europe
- FarEast
# Flag Conditions
Conditions:
IsAlexaActive:
Fn::Not: [!Equals [!Ref "AlexaSkillId", ""]]
IsGoogleSmartHomeActive:
Fn::Not: [!Equals [!Ref "GoogleProjectId", ""]]
# Template Resources
Resources:
# Event bus
EventBus:
Type: AWS::Events::EventBus
Properties:
Name: !Sub "${AWS::StackName}-events"
# Layers
layers:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: "arn:aws:serverlessrepo:${AWS::Region}:597720084096:applications/eliot-layers"
SemanticVersion: 1.0.0
# Services
oauth2:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: "arn:aws:serverlessrepo:${AWS::Region}:597720084096:applications/eliot-oauth2"
SemanticVersion: 1.0.0
Parameters:
CommonDependenciesLayerArn: !GetAtt layers.Outputs.CommonDependenciesLayerArn
ClientId: !Ref ClientId
ClientSecret: !Ref ClientSecret
GoogleProjectId: !Ref GoogleProjectId
EventBus: !Ref EventBus
iot:
Type: AWS::Serverless::Application
Properties:
Location:
ApplicationId: "arn:aws:serverlessrepo:${AWS::Region}:597720084096:applications/eliot-iot"
SemanticVersion: 1.0.0
Parameters:
CommonDependenciesLayerArn: !GetAtt layers.Outputs.CommonDependenciesLayerArn
IoTDependenciesLayerArn: !GetAtt layers.Outputs.IoTDependenciesLayerArn
EventBus: !Ref EventBus
google:
Type: AWS::Serverless::Application
Condition: IsGoogleSmartHomeActive
Properties:
Location:
ApplicationId: "arn:aws:serverlessrepo:${AWS::Region}:597720084096:applications/eliot-google"
SemanticVersion: 1.0.0
Parameters:
CommonDependenciesLayerArn: !GetAtt layers.Outputs.CommonDependenciesLayerArn
GoogleDependenciesLayerArn: !GetAtt layers.Outputs.GoogleDependenciesLayerArn
GoogleProjectId: !Ref GoogleProjectId
GoogleJwt: !Ref GoogleJwt
OAuth2EndpointUrl: !GetAtt oauth2.Outputs.ApiEndpointUrl
OAuth2EndpointArn: !GetAtt oauth2.Outputs.ApiEndpointArn
IoTEndpointUrl: !GetAtt iot.Outputs.ApiEndpointUrl
IoTEndpointArn: !GetAtt iot.Outputs.ApiEndpointArn
EventBus: !Ref EventBus
alexa:
Type: AWS::Serverless::Application
Condition: IsAlexaActive
Properties:
Location:
ApplicationId: "arn:aws:serverlessrepo:${AWS::Region}:597720084096:applications/eliot-alexa"
SemanticVersion: 1.0.0
Parameters:
CommonDependenciesLayerArn: !GetAtt layers.Outputs.CommonDependenciesLayerArn
AlexaSkillId: !Ref AlexaSkillId
AlexaClientId: !Ref AlexaClientId
AlexaClientSecret: !Ref AlexaClientSecret
AlexaEndpoint: !Ref AlexaEndpoint
OAuth2EndpointUrl: !GetAtt oauth2.Outputs.ApiEndpointUrl
OAuth2EndpointArn: !GetAtt oauth2.Outputs.ApiEndpointArn
IoTEndpointUrl: !GetAtt iot.Outputs.ApiEndpointUrl
IoTEndpointArn: !GetAtt iot.Outputs.ApiEndpointArn
EventBus: !Ref EventBus
# Template outputs
Outputs:
OAuth2AuthorizationEndpoint:
Value: !Sub "${oauth2.Outputs.ApiEndpointUrl}/authorization"
Description: OAuth2 - Authorization Endpoint URL
OAuth2TokenEndpoint:
Value: !Sub "${oauth2.Outputs.ApiEndpointUrl}/token"
Description: OAuth2 - Token Endpoint URL
GoogleSmartHomeFulfillmentEndpoint:
Value: !Sub "${google.Outputs.ApiEndpointUrl}/fulfillment"
Description: Google Smart Home - Fulfillment Endpoint URL
Condition: IsGoogleSmartHomeActive
AlexaLambdaARN:
Value: !GetAtt alexa.Outputs.FulfillmentFunctionArn
Description: Alexa - Fulfillment Lambda Function ARN
Condition: IsAlexaActive