Skip to content
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

add caching for ssm parameters and datadog values #124

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

EvanBrown96
Copy link

We ran into an issue with too many Session objects being created, and pulling AIMS credentials from SSM every time. This change adds caching for parameters pulled from SSM and values pulled from datadog.

else:
raise AlEnvException() from e

self._setup_aws_resources(source)

def get(self, key, default=None, format='decoded', type=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should be get_from_dynamodb, and the other should be get_from_ssm - as it's not clear just looking at

self._access_key_id = env.get_parameter('access_key_id', decrypt=True)
self._secret_key = env.get_parameter('secret_access_key', decrypt=True)
except Exception as e:
logger.debug(f"Did not initialise aims credentials via SSM for {self._service_name} because {e}")
if self._access_key_id is None or self._secret_key is None:
try:
# if that doesn't work, attempt dynamodb
env = AlEnv(self._service_name, "aims_authc", "dynamodb")
self._access_key_id = env.get('access_key_id')
self._secret_key = env.get('secret_access_key')
why one uses env.get and one uses env.get_parameter


def _make_ssm_key(self, option_key):
return f"/deployments/{self.stack_name}/{self._get_region()}/env-settings/{self.application_name}/{self._make_client_option_key(option_key)}"
return f"/deployments/{self._get_stack_name()}/{self._get_region()}/env-settings/{self.application_name}/{self._make_client_option_key(option_key)}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding to https://github.com/alertlogic/alertlogic-sdk-python#readme the paths we search for in dynamodb / ssm.

Also, it's probably future work, but it would be nice to be able to specify those paths in ~/.alertlogic/config

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants