Files
notifications-admin/app/cloudfoundry_config.py
Carlo Costino fa0a82a92a Remove secure Redis protocol workaround
This changeset removes a workaround that has been in place to account for a small error in the Cloud.gov AWS broker that has recently been fixed.

h/t to @markdboyd for the fix here! https://github.com/cloud-gov/aws-broker/pull/440

Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
2025-10-07 15:11:32 -04:00

31 lines
886 B
Python

import json
import os
class CloudfoundryConfig:
def __init__(self):
self.parsed_services = json.loads(os.environ.get("VCAP_SERVICES") or "{}")
buckets = self.parsed_services.get("s3") or []
self.s3_buckets = {bucket["name"]: bucket["credentials"] for bucket in buckets}
self._empty_bucket_credentials = {
"bucket": "",
"access_key_id": "",
"secret_access_key": "",
"region": "",
}
@property
def redis_url(self):
try:
return self.parsed_services["aws-elasticache-redis"][0]["credentials"][
"uri"
]
except KeyError:
return os.environ.get("REDIS_URL")
def s3_credentials(self, service_name):
return self.s3_buckets.get(service_name) or self._empty_bucket_credentials
cloud_config = CloudfoundryConfig()