From c031f8c46093f15de6b4dcc035b0ad13831b20d7 Mon Sep 17 00:00:00 2001 From: Jesse Bacon Date: Wed, 5 Mar 2025 16:25:36 -0500 Subject: [PATCH] Update playbook_gather_resources.yml app_resources_list creation was inside of the loop logic which caused the values to reset each time a new stack was interrogated. Depending on the order which the stacks were searched, the results may or may not have included the resources from the stack walab-ops-sample-application. --- .../Code/templates/playbook_gather_resources.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/static/Operations/200_Automating_operations_with_playbooks_and_runbooks/Code/templates/playbook_gather_resources.yml b/static/Operations/200_Automating_operations_with_playbooks_and_runbooks/Code/templates/playbook_gather_resources.yml index 28b7602a4..c3356d8fc 100644 --- a/static/Operations/200_Automating_operations_with_playbooks_and_runbooks/Code/templates/playbook_gather_resources.yml +++ b/static/Operations/200_Automating_operations_with_playbooks_and_runbooks/Code/templates/playbook_gather_resources.yml @@ -118,8 +118,8 @@ Resources: # Search CloufFormation Stacks for tag cfnclient = boto3.client('cloudformation', region_name = region ) list = cfnclient.list_stacks(StackStatusFilter=['CREATE_COMPLETE','ROLLBACK_COMPLETE','UPDATE_COMPLETE','UPDATE_ROLLBACK_COMPLETE','IMPORT_COMPLETE','IMPORT_ROLLBACK_COMPLETE'] ) + app_resources_list = [] for stack in list['StackSummaries']: - app_resources_list = [] stack_name = stack['StackName'] stack_details = cfnclient.describe_stacks(StackName=stack_name) stack_info = stack_details['Stacks'][0] @@ -135,9 +135,8 @@ Resources: 'Type': resource['ResourceType'] } ) - result = app_resources_list + return app_resources_list - return result def handler(event, context): result = {} arn = event['CloudWatchAlarmARN'] @@ -156,4 +155,4 @@ Resources: resources = locate_app_resources_by_tag(tag_value,alarm['Region']) result['ApplicationStackResources'] = json.dumps(resources) - return result \ No newline at end of file + return result