File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
workshops/serverless-testing-workshop/demo-app Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change 12
12
import uuid
13
13
import time
14
14
import requests
15
+ import boto3
15
16
import streamlit as st
16
17
from streamlit_js_eval import streamlit_js_eval
17
18
18
19
# Initialize Contexts
19
20
if 'api_endpoint_url' not in st .session_state :
20
- if os .path .isfile ("config.json" ):
21
+ try :
22
+ cfn_client = boto3 .client ('cloudformation' )
23
+ response = cfn_client .describe_stacks (StackName = os .environ .get ('BACKEND_STACK_NAME' ,'urs-backend' ))
24
+ for output in response ['Stacks' ][0 ]['Outputs' ]:
25
+ if output ['OutputKey' ] == 'ApiEndpoint' :
26
+ st .session_state ['api_endpoint_url' ] = output ['OutputValue' ]
27
+ except :
28
+ print ("Failed to get API Endpoint from CloudFormation Stack" )
29
+
30
+ if os .path .isfile ("config.json" ) and 'api_endpoint_url' not in st .session_state :
21
31
with open ("config.json" ,"r" ,encoding = "utf-8" ) as f :
22
32
app_config = json .load (f )
23
33
st .session_state ['api_endpoint_url' ] = app_config ["api_endpoint" ].strip ()
You can’t perform that action at this time.
0 commit comments