import streamlit as st
import boto3
import json
# AWS Lambda client
lambda_client = boto3.client("lambda", region_name="your-region") # Replace with actual region
# Function to fetch active Jupyter notebooks (Mocked List, Replace with actual API call)
def get_active_notebooks():
return ["notebook-1", "notebook-2", "notebook-3"] # Replace with actual source
# Function to invoke Lambda
def trigger_lambda(notebook_name, action):
payload = {"notebook_name": notebook_name, "action": action}
response = lambda_client.invoke(
FunctionName="your-lambda-function-name", # Replace with actual Lambda function name
InvocationType="RequestResponse",
Payload=json.dumps(payload),
)
return json.loads(response["Payload"].read())
# Streamlit UI
st.title("Jupyter Notebook Manager")
# Dropdown for active notebooks
notebooks = get_active_notebooks()
selected_notebook = st.selectbox("Select Notebook:", notebooks)
# Action selection
action = st.radio("Action:", ["Start", "Stop"])
# Trigger button
if st.button(f"{action} Notebook"):
result = trigger_lambda(selected_notebook, action.lower())
st.success(f"Lambda Response: {result}")
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (0)