From 1ece59e3040b42e0dcddbdb1fa05eb6cd22888fa Mon Sep 17 00:00:00 2001 From: Jacob Fuss <32497805+jfuss@users.noreply.github.com> Date: Thu, 13 May 2021 17:03:28 -0500 Subject: [PATCH 1/4] Revert "fix: Crash when using an invalid method in open api (#2001)" (#2021) This reverts commit d57b1329e1b99169f2d5ca59c1c41eee66b33750. From 47c56439926119f7c7f7ef8adf3611c78366175f Mon Sep 17 00:00:00 2001 From: Jacob Fuss <32497805+jfuss@users.noreply.github.com> Date: Tue, 18 May 2021 13:56:01 -0500 Subject: [PATCH 2/4] fix: Increase PageSize of ListPolicies Paginator (#2033) SAM runs within a Lambda function and loads IAM Managed Policies once per Lambda. Previous to this, SAM would call IAM 9 times which could cause throttling by IAM. With this change, we update the MaxItems from the default of 100 to the max (1000). In local testing, this has shown a 0.6 second reduction in the latency in calling IAM. Co-authored-by: Jacob Fuss --- samtranslator/translator/managed_policy_translator.py | 6 +++++- tests/translator/test_managed_policies_translator.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/samtranslator/translator/managed_policy_translator.py b/samtranslator/translator/managed_policy_translator.py index 0b5d1f78f0..a4020084af 100644 --- a/samtranslator/translator/managed_policy_translator.py +++ b/samtranslator/translator/managed_policy_translator.py @@ -7,15 +7,19 @@ class ManagedPolicyLoader(object): def __init__(self, iam_client): self._iam_client = iam_client self._policy_map = None + self.max_items = 1000 def load(self): if self._policy_map is None: LOG.info("Loading policies from IAM...") + paginator = self._iam_client.get_paginator("list_policies") # Setting the scope to AWS limits the returned values to only AWS Managed Policies and will # not returned policies owned by any specific account. # http://docs.aws.amazon.com/IAM/latest/APIReference/API_ListPolicies.html#API_ListPolicies_RequestParameters - page_iterator = paginator.paginate(Scope="AWS") + # Note(jfuss): boto3 PaginationConfig MaxItems does not control the number of items returned from the API + # call. This is actually controlled by PageSize. + page_iterator = paginator.paginate(Scope="AWS", PaginationConfig={"PageSize": self.max_items}) name_to_arn_map = {} for page in page_iterator: diff --git a/tests/translator/test_managed_policies_translator.py b/tests/translator/test_managed_policies_translator.py index 3337af663e..195db3a380 100644 --- a/tests/translator/test_managed_policies_translator.py +++ b/tests/translator/test_managed_policies_translator.py @@ -32,4 +32,4 @@ def test_load(): assert actual == expected iam.get_paginator.assert_called_once_with("list_policies") - paginator.paginate.assert_called_once_with(Scope="AWS") + paginator.paginate.assert_called_once_with(Scope="AWS", PaginationConfig={"PageSize": 1000}) From 77692b7dc8c312e389c6136ce7df3f98000979f6 Mon Sep 17 00:00:00 2001 From: _sam <3804518+aahung@users.noreply.github.com> Date: Wed, 19 May 2021 15:54:28 -0700 Subject: [PATCH 3/4] Revert "Issue 1508 remove check requiring identity ... (#1577)" (#2038) This reverts commit 0eb3630410ae569503513e52670ece61dc4d4301. This change caused regression, reverting until the bug is fixed. bug: `ReauthorizeEvery` can be a `dict` when intrinsic functions are used. From 82456cbc851cfba4f4c779c69b2e19da0679242e Mon Sep 17 00:00:00 2001 From: Mathieu Grandis <73313235+mgrandis@users.noreply.github.com> Date: Wed, 23 Jun 2021 14:06:16 -0700 Subject: [PATCH 4/4] chore: bump version to 1.37.0 (#2068) --- samtranslator/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samtranslator/__init__.py b/samtranslator/__init__.py index 4a1dc255bf..9483ec4860 100644 --- a/samtranslator/__init__.py +++ b/samtranslator/__init__.py @@ -1 +1 @@ -__version__ = "1.36.0" +__version__ = "1.37.0"