Skip to content

Commit 6d85045

Browse files
committed
Ops
1 parent e3868cb commit 6d85045

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

ops/deploy/fetch-env.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
echo "🔐 Fetching .env from AWS Secrets Manager..."
4+
5+
# Replace with your actual secret name
6+
SECRET_NAME="aws-laravel-code-pipeline"
7+
REGION="ap-south-1"
8+
PROJECT_PATH="/mnt/aws-laravel-code-pipeline"
9+
10+
# Fetch secret string and save to .env
11+
aws secretsmanager get-secret-value \
12+
--secret-id "$SECRET_NAME" \
13+
--region "$REGION" \
14+
--query SecretString \
15+
--output text > "$PROJECT_PATH"/.env
16+
17+
# Secure permissions
18+
chmod 640 "$PROJECT_PATH"/.env
19+
chown ec2-user:www-data "$PROJECT_PATH"/.env
20+
21+
echo "✅ .env successfully fetched and saved."

0 commit comments

Comments
 (0)