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

fix: initialize the the sar boto3 client only if it's needed #697

Merged
merged 1 commit into from
Dec 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions samtranslator/plugins/application/serverless_app_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ def __init__(self, sar_client=None, wait_for_template_active_status=False, valid
super(ServerlessAppPlugin, self).__init__(ServerlessAppPlugin.__name__)
self._applications = {}
self._in_progress_templates = []
if sar_client:
self._sar_client = sar_client
else:
self._sar_client = boto3.client('serverlessrepo')
self._sar_client = sar_client
self._wait_for_template_active_status = wait_for_template_active_status
self._validate_only = validate_only

Expand Down Expand Up @@ -89,6 +86,9 @@ def on_before_transform_template(self, template_dict):
key = (app_id, semver)
if key not in self._applications:
try:
# Lazy initialization of the client- create it when it is needed
if not self._sar_client:
self._sar_client = boto3.client('serverlessrepo')
service_call(app_id, semver, key, logical_id)
except InvalidResourceException as e:
# Catch all InvalidResourceExceptions, raise those in the before_resource_transform target.
Expand Down