2
2
import re
3
3
import shutil
4
4
import subprocess
5
+ import json
5
6
6
7
import click
7
8
import yaml
@@ -149,9 +150,42 @@ def add_logging(es_host):
149
150
with open (sls_config_path , 'w' ) as outf :
150
151
yaml .dump (sls_config , outf , indent = 1 )
151
152
152
- @stac_updater .command (name = 'deploy' , short_help = "deploy service to aws" )
153
+ @stac_updater .command (name = 'deploy' , short_help = "deploy service to aws. " )
153
154
def deploy ():
154
155
subprocess .call ("docker build . -t stac-updater:latest" , shell = True )
155
156
subprocess .call ("docker run --rm -v $PWD:/home/stac_updater -it stac-updater:latest package-service.sh" , shell = True )
156
157
subprocess .call ("npm install serverless-pseudo-parameters" , shell = True )
157
- subprocess .call ("sls deploy -v" , shell = True )
158
+ subprocess .call ("sls deploy -v" , shell = True )
159
+
160
+ @stac_updater .command (name = 'info' , short_help = "prints information about your service." )
161
+ def info ():
162
+ info = {}
163
+ with open (sls_config_path , 'r' ) as f :
164
+ sls_config = yaml .unsafe_load (f )
165
+ static_updaters = [sls_config ['functions' ][x ] for x in sls_config ['functions' ] if x .endswith ('update_collection' )]
166
+ if len (static_updaters ) > 0 :
167
+ info .update ({
168
+ 'static_collections' : [{
169
+ 'root' : x ['environment' ]['COLLECTION_ROOT' ],
170
+ 'path' : x ['environment' ]['PATH' ],
171
+ 'filename' : x ['environment' ]['FILENAME' ],
172
+ 'eventSource' : list (x ['events' ])[0 ]
173
+ } for x in static_updaters ]
174
+ })
175
+
176
+ if notification_topic_name in sls_config ['resources' ]['Resources' ]:
177
+ info .update ({
178
+ 'notifications' : {
179
+ 'topicArn' : 'arn:aws:sns:#{AWS::Region}:#{AWS::AccountId}:' + notification_topic_name
180
+ }
181
+ })
182
+
183
+ if 'es_log_ingest' in sls_config ['functions' ]:
184
+ info .update ({
185
+ 'logging' : {
186
+ 'host' : sls_config ['functions' ]['es_log_ingest' ]['environment' ]['ES_HOST' ],
187
+ 'logGroups' : [x ['cloudwatchLog' ]['logGroup' ] for x in sls_config ['functions' ]['es_log_ingest' ]['events' ]]
188
+ }
189
+ })
190
+
191
+ print (json .dumps (info , indent = 1 ))
0 commit comments