adding s3 pre-signed url
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 24s
All checks were successful
Deploy Beta (NATIVE) / deploy (push) Successful in 24s
This commit is contained in:
parent
aa26522f9d
commit
2f64af4746
1 changed files with 26 additions and 3 deletions
|
|
@ -316,8 +316,31 @@ MEDIA_URL = '/media/'
|
|||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||
|
||||
# CloudFront Domain Configuration
|
||||
import boto3
|
||||
import json
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
def load_s3_secrets():
|
||||
secret_name = "arn:aws:secretsmanager:ap-south-2:764709663363:secret:betasupplierdocument-rjF6JE"
|
||||
region_name = "ap-south-2"
|
||||
try:
|
||||
session = boto3.session.Session()
|
||||
client = session.client(service_name='secretsmanager', region_name=region_name)
|
||||
get_secret_value_response = client.get_secret_value(SecretId=secret_name)
|
||||
secrets = json.loads(get_secret_value_response['SecretString'])
|
||||
|
||||
# Inject secrets into environment variables so views.py can use them
|
||||
for key, value in secrets.items():
|
||||
os.environ[key] = str(value)
|
||||
|
||||
return secrets
|
||||
except Exception as e:
|
||||
print(f"Warning: Failed to load S3 secrets from Secrets Manager: {e}")
|
||||
return {}
|
||||
|
||||
s3_secrets = load_s3_secrets()
|
||||
|
||||
AWS_CLOUDFRONT_DOMAIN = os.environ.get('AWS_CLOUDFRONT_DOMAIN', '')
|
||||
USE_S3 = True
|
||||
AWS_STORAGE_BUCKET_NAME = 'betasupplierdocumentstorage'
|
||||
|
||||
USE_S3 = os.environ.get('USE_S3', 'False').lower() == 'true'
|
||||
AWS_STORAGE_BUCKET_NAME = os.environ.get('AWS_STORAGE_BUCKET_NAME', 'betasupplierdocumentstorage')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue