Repository navigation
fix: EB Firebase 인증 파일 자동 생성 #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| secret_id="daytodo/firebase-service-account" | ||
| aws_region="${AWS_REGION:-ap-northeast-2}" | ||
| credential_dir="/opt/daytodo" | ||
| credential_path="${credential_dir}/firebase-service-account.json" | ||
|
|
||
| install -d -m 0750 -o root -g webapp "${credential_dir}" | ||
|
|
||
| temporary_path="$(mktemp "${credential_dir}/firebase-service-account.json.XXXXXX")" | ||
| trap 'rm -f "${temporary_path}"' EXIT | ||
|
|
||
| aws secretsmanager get-secret-value \ | ||
| --secret-id "${secret_id}" \ | ||
| --region "${aws_region}" \ | ||
| --query SecretString \ | ||
| --output text \ | ||
| --no-cli-pager > "${temporary_path}" | ||
|
|
||
| test -s "${temporary_path}" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
file=".platform/hooks/predeploy/10-firebase-credentials.sh"
printf '%s\n' "--- hook ---"
cat -n "$file"
printf '%s\n' "--- related references ---"
rg -n --hidden -S \
'temporary_path|FIREBASE|GoogleCredentials|getApplicationDefault|firebase|jq|webapp' \
-g '!node_modules' -g '!dist' -g '!build' . | head -300
printf '%s\n' "--- jq availability ---"
if command -v jq >/dev/null 2>&1; then
jq --version
else
echo "jq: unavailable"
fiRepository: DayTodo/DayTodo_BE Length of output: 5369 🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' "--- deployment configuration ---"
git ls-files | rg '(^|/)(Dockerfile|docker-compose|.*ebextensions.*|.*platform.*|.*workflow.*|.*ya?ml$|.*json$)' | head -300
printf '%s\n' "--- validator and platform references ---"
rg -n --hidden -S \
'jq|yum|dnf|apt|amazon linux|platform|Elastic Beanstalk|aws-elasticbeanstalk|predeploy|SecretString' \
.platform .ebextensions-dev .github README.md build.gradle 2>/dev/null || true
printf '%s\n' "--- proposed jq predicate behavior ---"
python3 - <<'PY'
import json
from pathlib import Path
fixtures = {
"valid service account": {
"type": "service_account",
"project_id": "p",
"client_email": "x@example.com",
"private_key": "-----BEGIN PRIVATE KEY-----\\nkey\\n-----END PRIVATE KEY-----\\n",
},
"malformed JSON": '{"type":"service_account"',
"unrelated object": {"kind": "config", "value": "not credentials"},
"nonempty scalar": "secret",
"missing private_key": {
"type": "service_account",
"project_id": "p",
"client_email": "x@example.com",
},
}
for name, value in fixtures.items():
path = Path("/tmp") / ("firebase-" + name.replace(" ", "-") + ".json")
if isinstance(value, str) and value.startswith("{"):
path.write_text(value)
else:
path.write_text(json.dumps(value))
print(f"{name}: {path}")
PY
predicate='
type == "object" and
.type == "service_account" and
(.project_id | type == "string") and
(.client_email | type == "string") and
(.private_key | type == "string")
'
for file in /tmp/firebase-*.json; do
if jq -e "$predicate" "$file" >/dev/null 2>&1; then
printf 'accepted: %s\n' "$file"
else
printf 'rejected: %s\n' "$file"
fi
doneRepository: DayTodo/DayTodo_BE Length of output: 1565 🌐 Web query:
💡 Result: The jq command-line JSON processor is not preinstalled on AWS Elastic Beanstalk platforms running Amazon Linux 2 [1][2][3]. Because jq is frequently required to parse configuration data or environment variables on these platforms [4][1][5][3], users must explicitly include it in their environment configuration. To install jq on an Elastic Beanstalk environment using Amazon Linux 2, you can add it to your.ebextensions configuration file using the packages key [2][3][6]: packages: yum: jq: [] While Elastic Beanstalk documentation now recommends using Buildfile, Procfile, and platform hooks for configuration on Amazon Linux 2 environments [7], adding jq via.ebextensions remains a standard and widely used approach for ensuring the tool is available on the instance [1][3][6]. Citations:
🏁 Script executed: #!/bin/bash
set -eu
printf '%s\n' "--- deployment workflow ---"
cat -n .github/workflows/dev-deploy.yml
printf '%s\n' "--- Elastic Beanstalk configuration ---"
for file in .ebextensions-dev/00-makefiles.config .ebextensions-dev/01-set-timezone.config; do
printf '%s\n' "--- $file ---"
cat -n "$file"
done
printf '%s\n' "--- credential path consumers and environment wiring ---"
rg -n --hidden -S \
'GOOGLE_APPLICATION_CREDENTIALS|firebase-service-account|credential_path|/opt/daytodo|FIREBASE_ENABLED|GoogleCredentials' \
. \
-g '!node_modules' -g '!dist' -g '!build'Repository: DayTodo/DayTodo_BE Length of output: 4412 Validate the Firebase service-account JSON before installation.
🤖 Prompt for AI Agents |
||
| chown root:webapp "${temporary_path}" | ||
| chmod 0640 "${temporary_path}" | ||
| mv -f "${temporary_path}" "${credential_path}" | ||
|
|
||
| trap - EXIT | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: DayTodo/DayTodo_BE
Length of output: 5790
🏁 Script executed:
Repository: DayTodo/DayTodo_BE
Length of output: 9313
🏁 Script executed:
Repository: DayTodo/DayTodo_BE
Length of output: 348
Skip credential retrieval when Firebase is disabled.
The predeploy hook always calls Secrets Manager.
FIREBASE_ENABLEDdefaults tofalse, andFirebaseConfigloads only whenfirebase.enabled=true. Add a guard before credential setup so disabled environments do not require the secret or IAM permission.🤖 Prompt for AI Agents