From 6b173d9fb1a2f3f5123108248e8d6b1d11234e1d Mon Sep 17 00:00:00 2001 From: Benjamin Morris Date: Tue, 29 Aug 2023 16:55:22 -0700 Subject: [PATCH 1/4] externalize rdklib versions --- pyproject.toml | 2 +- rdk/__init__.py | 2 +- rdk/rdk.py | 20 ++------------------ rdk/rdklib_versions.yaml | 19 +++++++++++++++++++ 4 files changed, 23 insertions(+), 20 deletions(-) create mode 100644 rdk/rdklib_versions.yaml diff --git a/pyproject.toml b/pyproject.toml index 11b7261..6f54dc4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ # or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. [tool.poetry] name = "rdk" -version = "0.17.0" +version = "0.17.1" description = "Rule Development Kit CLI for AWS Config" authors = [ "AWS RDK Maintainers ", diff --git a/rdk/__init__.py b/rdk/__init__.py index 538c2f4..98471f4 100644 --- a/rdk/__init__.py +++ b/rdk/__init__.py @@ -6,4 +6,4 @@ # # or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -MY_VERSION = "0.17.0" +MY_VERSION = "0.17.1" diff --git a/rdk/rdk.py b/rdk/rdk.py index 3185840..a57e67b 100644 --- a/rdk/rdk.py +++ b/rdk/rdk.py @@ -57,24 +57,8 @@ test_ci_filename = "test_ci.json" event_template_filename = "test_event_template.json" -RDKLIB_LAYER_VERSION = { - "ap-southeast-1": "28", - "ap-south-1": "5", - "us-east-2": "5", - "us-east-1": "5", - "us-west-1": "4", - "us-west-2": "4", - "ap-northeast-2": "5", - "ap-southeast-2": "5", - "ap-northeast-1": "5", - "ca-central-1": "5", - "eu-central-1": "5", - "eu-west-1": "5", - "eu-west-2": "4", - "eu-west-3": "5", - "eu-north-1": "5", - "sa-east-1": "5", -} +rdklib_versions_filepath = os.path.join(os.path.dirname(__file__), "rdklib_versions.yaml") +RDKLIB_LAYER_VERSION = yaml.safe_load(open(rdklib_versions_filepath).read()).get("rdklib_layer_versions") RDKLIB_LAYER_SAR_ID = "arn:aws:serverlessrepo:ap-southeast-1:711761543063:applications/rdklib" diff --git a/rdk/rdklib_versions.yaml b/rdk/rdklib_versions.yaml new file mode 100644 index 0000000..c1eb322 --- /dev/null +++ b/rdk/rdklib_versions.yaml @@ -0,0 +1,19 @@ +# This file should be updated to contain the latest stable Lambda layer from the rdklib SAM application +# Layers are published to each region, which is why some have more versions than others +rdklib_layer_versions: + ap-southeast-1: "65" + ap-south-1: "5" + us-east-2: "5" + us-east-1: "5" + us-west-1: "4" + us-west-2: "4" + ap-northeast-2: "5" + ap-southeast-2: "5" + ap-northeast-1: "5" + ca-central-1: "5" + eu-central-1: "5" + eu-west-1: "5" + eu-west-2: "4" + eu-west-3: "5" + eu-north-1: "5" + sa-east-1: "5" From a8513128de647ff229a3de80d2a8e7a5e759a744 Mon Sep 17 00:00:00 2001 From: Benjamin Morris Date: Tue, 26 Sep 2023 17:58:42 -0700 Subject: [PATCH 2/4] add method for auto updating rdklib versions --- pyproject.toml | 2 +- rdk/rdklib_versions.yaml | 38 ++++++++++++++++++++------------------ update_rdklib_versions.py | 27 +++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 19 deletions(-) create mode 100644 update_rdklib_versions.py diff --git a/pyproject.toml b/pyproject.toml index 6f54dc4..77d9192 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -113,7 +113,7 @@ boto3 = "^1.26.139" pyyaml = "^6.0" [tool.poetry.group.dev.dependencies] -rdklib = "^0.3.0" +rdklib = "^0.3" black = "^22.12.0" pydocstyle = "^6.3.0" isort = {extras = ["toml"], version = "^5.11.4"} diff --git a/rdk/rdklib_versions.yaml b/rdk/rdklib_versions.yaml index c1eb322..c2f2148 100644 --- a/rdk/rdklib_versions.yaml +++ b/rdk/rdklib_versions.yaml @@ -1,19 +1,21 @@ -# This file should be updated to contain the latest stable Lambda layer from the rdklib SAM application -# Layers are published to each region, which is why some have more versions than others + +# This file should be updated to contain the latest stable Lambda layer from the rdklib SAM application. +# Layers are published to each region, which is why some have more versions than others. +# This file was automatically generated by update_rdklib_versions.py; check for accuracy before deploying. rdklib_layer_versions: - ap-southeast-1: "65" - ap-south-1: "5" - us-east-2: "5" - us-east-1: "5" - us-west-1: "4" - us-west-2: "4" - ap-northeast-2: "5" - ap-southeast-2: "5" - ap-northeast-1: "5" - ca-central-1: "5" - eu-central-1: "5" - eu-west-1: "5" - eu-west-2: "4" - eu-west-3: "5" - eu-north-1: "5" - sa-east-1: "5" + ap-northeast-1: 17 + ap-northeast-2: 17 + ap-south-1: 17 + ap-southeast-1: 76 + ap-southeast-2: 15 + ca-central-1: 17 + eu-central-1: 16 + eu-north-1: 16 + eu-west-1: 17 + eu-west-2: 13 + eu-west-3: 17 + sa-east-1: 17 + us-east-1: 18 + us-east-2: 77 + us-west-1: 15 + us-west-2: 16 diff --git a/update_rdklib_versions.py b/update_rdklib_versions.py new file mode 100644 index 0000000..94eb792 --- /dev/null +++ b/update_rdklib_versions.py @@ -0,0 +1,27 @@ +import yaml +import boto3 + +with open("rdk/rdklib_versions.yaml", "r") as f: + # read the file + regions = yaml.safe_load(f) + +version_dict = {"rdklib_layer_versions": {}} +for region in regions["rdklib_layer_versions"]: + lambda_client = boto3.client( + "lambda", + config=boto3.session.Config(region_name=region), + ) + latest_version = lambda_client.list_layer_versions(LayerName="rdklib-layer", MaxItems=1)["LayerVersions"][0][ + "Version" + ] + version_dict["rdklib_layer_versions"][region] = latest_version + +with open("rdk/rdklib_versions.yaml", "w") as f: + f.write( + """ +# This file should be updated to contain the latest stable Lambda layer from the rdklib SAM application. +# Layers are published to each region, which is why some have more versions than others. +# This file was automatically generated by update_rdklib_versions.py; check for accuracy before deploying. +""" + ) + f.write(yaml.dump(version_dict)) From 300486dbaf162e9b25ddcc88e979212423376309 Mon Sep 17 00:00:00 2001 From: Benjamin Morris Date: Tue, 26 Sep 2023 18:04:01 -0700 Subject: [PATCH 3/4] bump version, include rtd --- .readthedocs.yaml.off => .readthedocs.yaml | 0 pyproject.toml | 2 +- rdk/__init__.py | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename .readthedocs.yaml.off => .readthedocs.yaml (100%) diff --git a/.readthedocs.yaml.off b/.readthedocs.yaml similarity index 100% rename from .readthedocs.yaml.off rename to .readthedocs.yaml diff --git a/pyproject.toml b/pyproject.toml index 77d9192..22e3fdd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ # or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. [tool.poetry] name = "rdk" -version = "0.17.1" +version = "0.17.2" description = "Rule Development Kit CLI for AWS Config" authors = [ "AWS RDK Maintainers ", diff --git a/rdk/__init__.py b/rdk/__init__.py index 98471f4..09725be 100644 --- a/rdk/__init__.py +++ b/rdk/__init__.py @@ -6,4 +6,4 @@ # # or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -MY_VERSION = "0.17.1" +MY_VERSION = "0.17.2" From e5ff45f00b5bf71f88f310476c2d9d09393b7911 Mon Sep 17 00:00:00 2001 From: Benjamin Morris Date: Tue, 26 Sep 2023 18:11:12 -0700 Subject: [PATCH 4/4] send dependencies to rtd --- .readthedocs.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 82311f5..9b23c7a 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -18,6 +18,6 @@ mkdocs: # We recommend specifying your dependencies to enable reproducible builds: # https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html -# python: -# install: -# - requirements: docs/requirements.txt +python: + install: + - requirements: docs/requirements.txt