mirror of
https://github.com/GSA/notifications-admin.git
synced 2025-12-09 06:33:52 -05:00
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>
31 lines
886 B
Python
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()
|