From 069a35cebe9c519f802cb2be35fa8c7f3aab9e09 Mon Sep 17 00:00:00 2001 From: ccggeo Date: Wed, 6 Dec 2023 16:47:30 +0000 Subject: [PATCH 1/3] fix - check stack is ready for cc to be created --- plugins/modules/cloudformation.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/modules/cloudformation.py b/plugins/modules/cloudformation.py index 1f200a703fc..30ea273744c 100644 --- a/plugins/modules/cloudformation.py +++ b/plugins/modules/cloudformation.py @@ -595,6 +595,12 @@ def check_mode_changeset(module, stack_params, cfn): stack_params.pop("ClientRequestToken", None) try: + for _i in range(60): # total time 5 min + # check stack is ready to have a change set created + stack = get_stack_facts(module, cfn, stack_name, raise_errors=True) + if stack["StackStatus"] == "UPDATE_COMPLETE": + break + time.sleep(5) change_set = cfn.create_change_set(aws_retry=True, **stack_params) for _i in range(60): # total time 5 min description = cfn.describe_change_set(aws_retry=True, ChangeSetName=change_set["Id"]) From 96f0343e86e7cb7c2479b8ca696fc680ade3c868 Mon Sep 17 00:00:00 2001 From: ccggeo Date: Wed, 6 Dec 2023 17:20:10 +0000 Subject: [PATCH 2/3] fix / access stack name properly --- plugins/modules/cloudformation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudformation.py b/plugins/modules/cloudformation.py index 30ea273744c..fa02a57989a 100644 --- a/plugins/modules/cloudformation.py +++ b/plugins/modules/cloudformation.py @@ -597,7 +597,7 @@ def check_mode_changeset(module, stack_params, cfn): try: for _i in range(60): # total time 5 min # check stack is ready to have a change set created - stack = get_stack_facts(module, cfn, stack_name, raise_errors=True) + stack = get_stack_facts(module, cfn, stack_params['StackName'], raise_errors=True) if stack["StackStatus"] == "UPDATE_COMPLETE": break time.sleep(5) From 91fbbf39a7cf86ab90700e294682242059b1fb78 Mon Sep 17 00:00:00 2001 From: ccggeo Date: Thu, 7 Dec 2023 08:37:23 +0000 Subject: [PATCH 3/3] fix / use complete postfix to catch create stack status --- plugins/modules/cloudformation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/cloudformation.py b/plugins/modules/cloudformation.py index fa02a57989a..34ff0557d0e 100644 --- a/plugins/modules/cloudformation.py +++ b/plugins/modules/cloudformation.py @@ -598,7 +598,7 @@ def check_mode_changeset(module, stack_params, cfn): for _i in range(60): # total time 5 min # check stack is ready to have a change set created stack = get_stack_facts(module, cfn, stack_params['StackName'], raise_errors=True) - if stack["StackStatus"] == "UPDATE_COMPLETE": + if stack["StackStatus"].endswith('_COMPLETE'): break time.sleep(5) change_set = cfn.create_change_set(aws_retry=True, **stack_params)