Skip to content

Commit

Permalink
Add APIs for VPN tunnel between GCP and AWS
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-github-robot authored May 16, 2024
2 parents 3e010e1 + e53573c commit 33ae3ff
Show file tree
Hide file tree
Showing 18 changed files with 2,185 additions and 125 deletions.
2 changes: 2 additions & 0 deletions conf/setup.env
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export SPIDER_CALL_METHOD=REST
export SPIDER_REST_URL=http://localhost:1024/spider
export DRAGONFLY_CALL_METHOD=REST
export DRAGONFLY_REST_URL=http://localhost:9090/dragonfly
export TERRARIUM_CALL_METHOD=REST
export TERRARIUM_REST_URL=http://localhost:8888/terrarium

## Set internal DB config (SQLlite)
export DB_URL=localhost:3306
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ require (
github.com/stretchr/testify v1.8.4
github.com/swaggo/echo-swagger v1.4.1
github.com/swaggo/swag v1.16.3
github.com/tidwall/gjson v1.17.0
github.com/tidwall/gjson v1.17.1
github.com/tidwall/sjson v1.2.5
golang.org/x/crypto v0.22.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
Expand All @@ -30,6 +30,7 @@ require (
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/bwmarrin/snowflake v0.3.0 // indirect
github.com/cloud-barista/cb-log v0.8.0 // indirect
github.com/cloud-barista/mc-terrarium v0.0.6-0.20240516045927-43023b6a0e18 // indirect
github.com/coreos/go-semver v0.3.1 // indirect
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ github.com/cloud-barista/cb-log v0.8.0 h1:ArWCs1EgpoD3ZnBgcC4cAw5ufI/JHmFKfJswlv
github.com/cloud-barista/cb-log v0.8.0/go.mod h1:nGgfTFMPwl1MpCO3FBjexUkNdOYA0BNJoyM9Pd0lMms=
github.com/cloud-barista/cb-store v0.8.0 h1:0K47YEf+K3wx18D+m0XirlDbdTz229XxsTXw6WACjRA=
github.com/cloud-barista/cb-store v0.8.0/go.mod h1:6NuA5TdeVRExd59ULXv6LEhm4EE0ODn9L820g4VqApo=
github.com/cloud-barista/mc-terrarium v0.0.6-0.20240516022714-7bafe50e1df5 h1:4/OX/AF2/f4vtA4JrmAQKtjTDvZP0dcJjoChLNXAhUk=
github.com/cloud-barista/mc-terrarium v0.0.6-0.20240516022714-7bafe50e1df5/go.mod h1:qey9GFrJidyJ3tVfeL/gcImgWLqsF64j/fVmBfaddDI=
github.com/cloud-barista/mc-terrarium v0.0.6-0.20240516045927-43023b6a0e18 h1:tsBHD7Gh+Q0jpZ3NCh4jDM+ozlxFCfpMc2gto+G6tZQ=
github.com/cloud-barista/mc-terrarium v0.0.6-0.20240516045927-43023b6a0e18/go.mod h1:qey9GFrJidyJ3tVfeL/gcImgWLqsF64j/fVmBfaddDI=
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
github.com/coreos/go-semver v0.3.1 h1:yi21YpKnrx1gt5R+la8n5WgS0kCrsPp33dmEyHReZr4=
github.com/coreos/go-semver v0.3.1/go.mod h1:irMmmIw/7yzSRPWryHsK7EYSg09caPQL03VsM8rvUec=
Expand Down Expand Up @@ -287,6 +291,7 @@ github.com/syndtr/goleveldb v1.0.0/go.mod h1:ZVVdQEZoIme9iO1Ch2Jdy24qqXrMMOU6lpP
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.17.0 h1:/Jocvlh98kcTfpN2+JzGQWQcqrPQwDrVEMApx/M5ZwM=
github.com/tidwall/gjson v1.17.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
Expand Down
3 changes: 1 addition & 2 deletions go.work.sum
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,12 @@ github.com/sagikazarmark/crypt v0.17.0/go.mod h1:SMtHTvdmsZMuY/bpZoqokSoChIrcJ/e
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a h1:kAe4YSu0O0UFn1DowNo2MY5p6xzqtJ/wQ7LZynSvGaY=
github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w=
github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
go.etcd.io/etcd/client/v2 v2.305.10/go.mod h1:m3CKZi69HzilhVqtPDcjhSGp+kA1OmbNn0qamH80xjA=
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
Expand Down
4 changes: 2 additions & 2 deletions scripts/runTF.sh → scripts/runTerrarium.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

CONTAINER_NAME_READ="poc-mc-net-tf"
CONTAINER_VERSION="0.0.5"
CONTAINER_NAME_READ="mc-terrarium"
CONTAINER_VERSION="0.0.6"
CONTAINER_PORT="-p 8888:8888"
CONTAINER_DATA_PATH="/app/.tofu"

Expand Down
42 changes: 23 additions & 19 deletions scripts/runTumblebug.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,48 @@ if [[ -n "$external_ip" ]]; then
# If external IP retrieval was successful, prompt user to select the ENDPOINT
echo "Please select endpoints to be used:"
echo "1) Use External IP for all components: $external_ip"
echo "2) Use 'host.docker.internal' to communicate with Spider and Dragonfly containers, 'localhost' for Tumblebug"
echo "2) Use 'localhost' for Tumblebug and use 'host.docker.internal' to communicate with Spider/Dragonfly/Terrarium containers"
read -p "Enter your choice (1 or 2): " user_choice


# Note - EP: Endpoint
case $user_choice in
1)
SP_ENDPOINT=$external_ip
DF_ENDPOINT=$external_ip
TB_ENDPOINT=$external_ip
EP_TUMBLEBUG=$external_ip
EP_SPIDER=$external_ip
EP_DRAGONFLY=$external_ip
EP_TERRARIUM=$external_ip
;;
2)
SP_ENDPOINT="host.docker.internal"
DF_ENDPOINT="host.docker.internal"
TB_ENDPOINT="localhost"
EP_TUMBLEBUG="localhost"
EP_SPIDER="host.docker.internal"
EP_DRAGONFLY="host.docker.internal"
EP_TERRARIUM="host.docker.internal"
;;
*)
echo "Invalid choice, use 'host.docker.internal' and 'localhost' as the default."
SP_ENDPOINT="host.docker.internal"
DF_ENDPOINT="host.docker.internal"
TB_ENDPOINT="localhost"
echo "Invalid choice, use 'localhost' and 'host.docker.internal' as the default."
EP_SPIDER="host.docker.internal"
EP_DRAGONFLY="host.docker.internal"
EP_TUMBLEBUG="localhost"
EP_TERRARIUM="host.docker.internal"
;;
esac
else
# If external IP retrieval failed, default to localhost
echo "Failed to retrieve external IP, use 'host.docker.internal' and 'localhost' as the default."
SP_ENDPOINT="host.docker.internal"
DF_ENDPOINT="host.docker.internal"
TB_ENDPOINT="localhost"
echo "Failed to retrieve external IP, use 'localhost' and 'host.docker.internal' as the default."
EP_TUMBLEBUG="localhost"
EP_SPIDER="host.docker.internal"
EP_DRAGONFLY="host.docker.internal"
EP_TERRARIUM="host.docker.internal"
fi

echo
echo "This script assume CB-Spider container is running in the same host. ($external_ip)"
echo "Note - this script assumes CB-Spider/CB-Dragonfly/MC-Terrarium container is running in the same host. ($external_ip)"
echo

if [ "$user_choice" != "1" ]; then
CONTAINER_ENV="--add-host host.docker.internal:host-gateway -e SPIDER_REST_URL=http://$SP_ENDPOINT:1024/spider -e DRAGONFLY_REST_URL=http://$DF_ENDPOINT:9090/dragonfly -e SELF_ENDPOINT=$TB_ENDPOINT:1323"
CONTAINER_ENV="--add-host host.docker.internal:host-gateway -e SPIDER_REST_URL=http://$EP_SPIDER:1024/spider -e DRAGONFLY_REST_URL=http://$EP_DRAGONFLY:9090/dragonfly -e TERRARIUM_REST_URL=http://$EP_TERRARIUM:8888/terrarium -e SELF_ENDPOINT=$EP_TUMBLEBUG:1323"
else
CONTAINER_ENV="-e SPIDER_REST_URL=http://$SP_ENDPOINT:1024/spider -e DRAGONFLY_REST_URL=http://$DF_ENDPOINT:9090/dragonfly -e SELF_ENDPOINT=$TB_ENDPOINT:1323"
CONTAINER_ENV="-e SPIDER_REST_URL=http://$EP_SPIDER:1024/spider -e DRAGONFLY_REST_URL=http://$EP_DRAGONFLY:9090/dragonfly -e SELF_ENDPOINT=$EP_TUMBLEBUG:1323"
fi

./runContainer.sh "$CONTAINER_NAME_READ" "$CONTAINER_VERSION" "$CONTAINER_PORT" "$CONTAINER_DATA_PATH" "$CONTAINER_ENV"
Loading

0 comments on commit 33ae3ff

Please sign in to comment.