Skip to content

Commit

Permalink
fix: Fetch S3 credentials for S3 upload of crash dumps (#747)
Browse files Browse the repository at this point in the history
Using the details given by https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-iam-roles.html we will fetch key and secret given the container IAM roles
  • Loading branch information
filipecabaco authored Nov 22, 2023
1 parent 22e277d commit a4eec52
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Realtime.MixProject do
def project do
[
app: :realtime,
version: "2.25.38",
version: "2.25.39",
elixir: "~> 1.14.0",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,
Expand Down
9 changes: 7 additions & 2 deletions tailscale/wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,24 @@ export ERL_CRASH_DUMP=/tmp/erl_crash.dump

function upload_crash_dump_to_s3 {
EXIT_CODE=${?:-0}

bucket=$ERL_CRASH_DUMP_S3_BUCKET
s3Key=$ERL_CRASH_DUMP_S3_KEY
s3Secret=$ERL_CRASH_DUMP_S3_SECRET
s3Host=$ERL_CRASH_DUMP_S3_HOST
s3Port=$ERL_CRASH_DUMP_S3_PORT

if [ "${AWS_CONTAINER_CREDENTIALS_RELATIVE_URI-}" ]; then
response=$(curl -s http://169.254.170.2$AWS_CONTAINER_CREDENTIALS_RELATIVE_URI)
s3Key=$(echo "$response" | grep -o '"AccessKeyId": *"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"')
s3Secret=$(echo "$response" | grep -o '"SecretAccessKey": *"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"')
fi

filePath=${ERL_CRASH_DUMP_FOLDER:-tmp}/$(date +%s)_${ERL_CRASH_DUMP_FILE_NAME:-erl_crash.dump}

if [ -f "${ERL_CRASH_DUMP_FOLDER:-tmp}/${ERL_CRASH_DUMP_FILE_NAME:-erl_crash.dump}" ]; then
mv ${ERL_CRASH_DUMP_FOLDER:-tmp}/${ERL_CRASH_DUMP_FILE_NAME:-erl_crash.dump} $filePath

resource="/${bucket}${filePath}"
resource="/${bucket}/realtime/crash_dumps${filePath}"

contentType="application/octet-stream"
dateValue=$(date -R)
Expand Down

0 comments on commit a4eec52

Please sign in to comment.