-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·49 lines (42 loc) · 1.46 KB
/
setup.sh
File metadata and controls
executable file
·49 lines (42 loc) · 1.46 KB
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
#!/usr/bin/env bash
set -euo pipefail
# Workshop auth token endpoint — organizer publishes token here on event day.
# The URL points to a time-limited S3 object; replace before each workshop.
TOKEN_URL="${WORKSHOP_TOKEN_URL:-https://localstack-artifacts-internal.s3.amazonaws.com/ls-workshop/auth-token}"
if [ -z "${LOCALSTACK_AUTH_TOKEN:-}" ]; then
echo "Fetching LocalStack auth token from: $TOKEN_URL"
TOKEN=$(curl -fsSL "$TOKEN_URL")
export LOCALSTACK_AUTH_TOKEN="$TOKEN"
echo "export LOCALSTACK_AUTH_TOKEN=$TOKEN" >> "${HOME}/.bashrc"
echo "export LOCALSTACK_AUTH_TOKEN=$TOKEN" >> "${HOME}/.zshrc" 2>/dev/null || true
echo "Token set."
else
echo "Using existing LOCALSTACK_AUTH_TOKEN."
fi
echo ""
echo "Configuring AWS CLI default profile for LocalStack..."
mkdir -p "${HOME}/.aws"
cat > "${HOME}/.aws/credentials" << 'EOF'
[default]
aws_access_key_id = test
aws_secret_access_key = test
EOF
cat > "${HOME}/.aws/config" << 'EOF'
[default]
region = us-east-1
endpoint_url = http://localhost:4566
output = json
EOF
echo "AWS CLI profile configured."
echo ""
echo "Starting LocalStack..."
localstack start -d
echo ""
echo "Waiting for LocalStack to be ready..."
localstack wait -t 60
echo ""
echo "Verifying..."
aws s3 ls > /dev/null && echo "OK: aws CLI connected (via default profile)"
curl -sf http://localhost:4566/_localstack/health | python3 -m json.tool | grep -q '"running"' && echo "OK: health check passed"
echo ""
echo "Setup complete. Proceed to module 01."