Creating a script to launch already passing the environemnt variables.

This commit is contained in:
Filipi Fuchter
2025-11-27 16:34:43 -03:00
parent 625d56e8fa
commit e891f05bb9
2 changed files with 58 additions and 0 deletions

View File

@@ -59,6 +59,9 @@ Deploy your configured bot to Amazon Bedrock AgentCore Runtime for production ho
```bash ```bash
agentcore launch --env OPENAI_API_KEY=... --env DEEPGRAM_API_KEY=... --env CARTESIA_API_KEY=... # -a <agent_name> (if multiple agents configured) agentcore launch --env OPENAI_API_KEY=... --env DEEPGRAM_API_KEY=... --env CARTESIA_API_KEY=... # -a <agent_name> (if multiple agents configured)
# or just use this script, which will read and send all environment variables
./scripts/launch.sh
``` ```
You should see commands related to tailing logs printed to the console. Copy and save them for later use. You should see commands related to tailing logs printed to the console. Copy and save them for later use.
@@ -89,6 +92,12 @@ Paste the log tailing command you received when deploying your bot to AgentCore
aws logs tail /aws/bedrock-agentcore/runtimes/bot1-0uJkkT7QHC-DEFAULT --log-stream-name-prefix "2025/11/19/[runtime-logs]" --follow aws logs tail /aws/bedrock-agentcore/runtimes/bot1-0uJkkT7QHC-DEFAULT --log-stream-name-prefix "2025/11/19/[runtime-logs]" --follow
``` ```
## Removing your local agent
```bash
agentcore destroy
```
## Running Locally ## Running Locally
You can also run your bot locally, using either the SmallWebRTC or Daily transport. You can also run your bot locally, using either the SmallWebRTC or Daily transport.

View File

@@ -0,0 +1,49 @@
#!/bin/bash
# Script to dynamically read all variables from .env file and launch agentcore
# Check if .env file exists
if [ ! -f ".env" ]; then
echo "Error: .env file not found in current directory"
echo "Please create a .env file with your environment variables"
exit 1
fi
# Start building the agentcore launch command
LAUNCH_CMD="agentcore launch"
echo "Loading environment variables from .env file..."
# Read each line from .env file and process it
while IFS= read -r line || [ -n "$line" ]; do
# Skip empty lines and comments
if [[ -z "$line" || "$line" =~ ^[[:space:]]*# ]]; then
continue
fi
# Check if line contains an equals sign (valid env var format)
if [[ "$line" =~ ^[^=]+=[^=]*$ ]]; then
# Extract variable name and value
VAR_NAME=$(echo "$line" | cut -d'=' -f1 | xargs)
VAR_VALUE=$(echo "$line" | cut -d'=' -f2- | xargs)
# Skip if variable name or value is empty
if [[ -n "$VAR_NAME" && -n "$VAR_VALUE" ]]; then
# Add to launch command
LAUNCH_CMD="$LAUNCH_CMD --env $VAR_NAME=$VAR_VALUE"
echo " Added: $VAR_NAME"
fi
fi
done < ".env"
# Check if any environment variables were added
if [[ "$LAUNCH_CMD" == "agentcore launch" ]]; then
echo "Warning: No valid environment variables found in .env file"
echo "Make sure your .env file contains variables in the format: KEY=value"
exit 1
fi
# Execute the command
echo ""
echo "Executing: $LAUNCH_CMD"
eval "$LAUNCH_CMD"