diff --git a/CHANGELOG.md b/CHANGELOG.md index 551f6ae..50f4c38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 --- +## [1.10.1] - 2023-05-31 + +### 1.10.1 Fixed + +- Added paginators to boto3 calls in batchfold environment class to address issue with deploying multiple stacks. + +--- + ## [1.10.0] - 2023-05-25 ### 1.10.0 Added diff --git a/src/batchfold/batchfold_environment.py b/src/batchfold/batchfold_environment.py index c180c25..aac6fe4 100644 --- a/src/batchfold/batchfold_environment.py +++ b/src/batchfold/batchfold_environment.py @@ -46,24 +46,46 @@ def load_latest_root_stack(self) -> str: "ROLLBACK_COMPLETE", "UPDATE_COMPLETE", ] - for stack in cfn.list_stacks(StackStatusFilter=stack_status_filter)["StackSummaries"]: - if "batch-protein-folding-cfn-root.yaml" in stack.get("TemplateDescription", []): - batchfold_stacks.append((stack["CreationTime"], stack["StackId"])) - return sorted(batchfold_stacks, key = lambda x: x[0], reverse=True)[0][1] + + paginator = cfn.get_paginator("list_stacks") + pages = paginator.paginate(StackStatusFilter=stack_status_filter) + + for page in pages: + for stack in page["StackSummaries"]: + if "batch-protein-folding-cfn-root.yaml" in stack.get( + "TemplateDescription", [] + ): + batchfold_stacks.append((stack["CreationTime"], stack["StackId"])) + return sorted(batchfold_stacks, key=lambda x: x[0], reverse=True)[0][1] @nested_stacks.default def load_nested_stacks(self) -> List: cfn = self.boto_session.client("cloudformation") - resources = cfn.list_stack_resources(StackName=self.stack_id).get("StackResourceSummaries", []) - return [ x.get("PhysicalResourceId", []) for x in resources if x.get("ResourceType", []) == "AWS::CloudFormation::Stack" ] + + paginator = cfn.get_paginator("list_stack_resources") + pages = paginator.paginate(StackName=self.stack_id) + resources = [] + + for page in pages: + resources.append(page.get("StackResourceSummaries", [])) + + return [ + x.get("PhysicalResourceId", []) + for x in resources + if x.get("ResourceType", []) == "AWS::CloudFormation::Stack" + ] @stack_outputs.default def load_stack_outputs(self) -> List: cfn = self.boto_session.client("cloudformation") stack_outputs = [] for nested_stack in self.nested_stacks: - stack_outputs.extend(cfn.describe_stacks(StackName=nested_stack).get("Stacks")[0].get("Outputs", [])) - return(stack_outputs) + stack_outputs.extend( + cfn.describe_stacks(StackName=nested_stack) + .get("Stacks")[0] + .get("Outputs", []) + ) + return stack_outputs def get_stack_outputs(self, filter: str = "") -> Dict: """Get a dict of the cloudformation stack outputs, optionally with key filtered by a string""" @@ -141,4 +163,3 @@ def list_jobs( all_jobs[queue.name] = jobs return all_jobs -