Skip to content

Commit ea87602

Browse files
committed
Add SDK runner scripts
- run-sdk.sh: shared runner with prereq checks for all 11 languages - *-sdk.sh: per-tutorial thin wrappers (3 lines each) - Usage: bash s3-gettingstarted-sdk.sh python
1 parent 6be9655 commit ea87602

File tree

11 files changed

+82
-0
lines changed

11 files changed

+82
-0
lines changed

run-sdk.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
# Shared SDK runner — sourced by each tutorial's *-sdk.sh script.
3+
set -eo pipefail
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[1]}")" && pwd)"
5+
LANG="${1:-}"
6+
usage() {
7+
echo "Usage: $(basename "${BASH_SOURCE[1]}") <language>"
8+
echo " python|py, javascript|js, java, go, ruby|rb, dotnet|cs, rust|rs, kotlin|kt, swift, php, cpp"
9+
echo ""
10+
echo "Available:"
11+
for d in "$SCRIPT_DIR"/*/; do [ -d "$d" ] && basename "$d" | grep -qvE '^\.' && echo " $(basename "$d")"; done
12+
exit 1
13+
}
14+
[ -z "$LANG" ] && usage
15+
case "$LANG" in
16+
python|py) DIR="python" ;; javascript|js|node) DIR="javascript" ;; java) DIR="java" ;;
17+
go|golang) DIR="go" ;; ruby|rb) DIR="ruby" ;; dotnet|csharp|cs) DIR="dotnet" ;;
18+
rust|rs) DIR="rust" ;; kotlin|kt) DIR="kotlin" ;; swift) DIR="swift" ;;
19+
php) DIR="php" ;; cpp|c++) DIR="cpp" ;; *) echo "Unknown: $LANG"; usage ;;
20+
esac
21+
LANG_DIR="$SCRIPT_DIR/$DIR"
22+
[ ! -d "$LANG_DIR" ] && echo "No $DIR example for this tutorial." && usage
23+
check_cmd() { command -v "$1" > /dev/null 2>&1 || { echo "Required: $1 not installed. Install: $2"; exit 1; }; }
24+
case "$DIR" in
25+
python) check_cmd python3 "https://python.org/downloads/"; cd "$LANG_DIR"
26+
[ ! -d ".venv" ] && python3 -m venv .venv; source .venv/bin/activate; pip install -q -r requirements.txt
27+
echo "$ python3 scenario_getting_started.py"; echo ""; python3 scenario_getting_started.py ;;
28+
javascript) check_cmd node "https://nodejs.org/"; cd "$LANG_DIR"
29+
[ ! -d "node_modules" ] && npm install --quiet
30+
echo "$ node scenarios/getting-started.js"; echo ""; node scenarios/getting-started.js ;;
31+
java) check_cmd mvn "https://maven.apache.org/install.html"; cd "$LANG_DIR"
32+
echo "$ mvn -q compile exec:java"; mvn -q compile exec:java 2>&1 ;;
33+
go) check_cmd go "https://go.dev/dl/"; cd "$LANG_DIR"
34+
echo "$ go run scenarios/getting_started.go"; echo ""; go run scenarios/getting_started.go ;;
35+
ruby) check_cmd ruby "https://ruby-lang.org/"; cd "$LANG_DIR"
36+
[ ! -f "Gemfile.lock" ] && bundle install --quiet
37+
echo "$ ruby scenario_getting_started.rb"; echo ""; ruby scenario_getting_started.rb ;;
38+
dotnet) check_cmd dotnet "https://dotnet.microsoft.com/download"; cd "$LANG_DIR"
39+
echo "$ dotnet run"; echo ""; dotnet run ;;
40+
rust) check_cmd cargo "https://rustup.rs/"; cd "$LANG_DIR"
41+
echo "$ cargo run --bin scenario"; echo ""; cargo run --bin scenario ;;
42+
kotlin) check_cmd java "https://aws.amazon.com/corretto/"; cd "$LANG_DIR"
43+
echo "$ ./gradlew run"; chmod +x gradlew 2>/dev/null; ./gradlew run --quiet ;;
44+
swift) check_cmd swift "https://swift.org/download/"; cd "$LANG_DIR"
45+
echo "$ swift run"; echo ""; swift run ;;
46+
php) check_cmd php "https://php.net/downloads"; cd "$LANG_DIR"
47+
[ ! -d "vendor" ] && composer install --quiet
48+
echo "$ php GettingStartedScenario.php"; echo ""; php GettingStartedScenario.php ;;
49+
cpp) check_cmd cmake "https://cmake.org/download/"; cd "$LANG_DIR"
50+
mkdir -p build && cd build; echo "$ cmake .. && make && ./scenario"
51+
cmake .. -DCMAKE_BUILD_TYPE=Release > /dev/null 2>&1; make -j > /dev/null 2>&1 && ./scenario ;;
52+
esac
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# Run the SDK example for this tutorial. Usage: bash lightsail-gs-sdk.sh <language>
3+
source "$(cd "$(dirname "$0")/../.." && pwd)/run-sdk.sh" "$@"

tuts/002-vpc-gs/vpc-gs-sdk.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# Run the SDK example for this tutorial. Usage: bash vpc-gs-sdk.sh <language>
3+
source "$(cd "$(dirname "$0")/../.." && pwd)/run-sdk.sh" "$@"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# Run the SDK example for this tutorial. Usage: bash s3-gettingstarted-sdk.sh <language>
3+
source "$(cd "$(dirname "$0")/../.." && pwd)/run-sdk.sh" "$@"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# Run the SDK example for this tutorial. Usage: bash cloudmap-custom-attributes-sdk.sh <language>
3+
source "$(cd "$(dirname "$0")/../.." && pwd)/run-sdk.sh" "$@"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# Run the SDK example for this tutorial. Usage: bash cloudfront-gettingstarted-sdk.sh <language>
3+
source "$(cd "$(dirname "$0")/../.." && pwd)/run-sdk.sh" "$@"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# Run the SDK example for this tutorial. Usage: bash vpc-private-servers-gs-sdk.sh <language>
3+
source "$(cd "$(dirname "$0")/../.." && pwd)/run-sdk.sh" "$@"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# Run the SDK example for this tutorial. Usage: bash vpc-ipam-gs-sdk.sh <language>
3+
source "$(cd "$(dirname "$0")/../.." && pwd)/run-sdk.sh" "$@"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# Run the SDK example for this tutorial. Usage: bash cloudmap-service-discovery-sdk.sh <language>
3+
source "$(cd "$(dirname "$0")/../.." && pwd)/run-sdk.sh" "$@"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
# Run the SDK example for this tutorial. Usage: bash batch-fargate-sdk.sh <language>
3+
source "$(cd "$(dirname "$0")/../.." && pwd)/run-sdk.sh" "$@"

0 commit comments

Comments
 (0)