@@ -514,6 +514,7 @@ def update_stack(module, stack_params, cfn, events_limit):
514
514
515
515
def update_termination_protection (module , cfn , stack_name , desired_termination_protection_state ):
516
516
"""updates termination protection of a stack"""
517
+ changed = False
517
518
stack = get_stack_facts (module , cfn , stack_name )
518
519
if stack :
519
520
if stack ["EnableTerminationProtection" ] is not desired_termination_protection_state :
@@ -523,8 +524,10 @@ def update_termination_protection(module, cfn, stack_name, desired_termination_p
523
524
EnableTerminationProtection = desired_termination_protection_state ,
524
525
StackName = stack_name ,
525
526
)
527
+ changed = True
526
528
except botocore .exceptions .ClientError as e :
527
529
module .fail_json_aws (e )
530
+ return changed
528
531
529
532
530
533
def stack_operation (module , cfn , stack_name , operation , events_limit , op_token = None ):
@@ -779,14 +782,17 @@ def main():
779
782
if state == "present" :
780
783
if not stack_info :
781
784
result = create_stack (module , stack_params , cfn , module .params .get ("events_limit" ))
782
- elif module .params .get ("create_changeset" ):
783
- result = create_changeset (module , stack_params , cfn , module .params .get ("events_limit" ))
784
785
else :
786
+ changeset_updated = False
787
+ if module .params .get ("create_changeset" ):
788
+ result = create_changeset (module , stack_params , cfn , module .params .get ("events_limit" ))
789
+ changeset_updated = True
785
790
if module .params .get ("termination_protection" ) is not None :
786
- update_termination_protection (
791
+ result [ "changed" ] = update_termination_protection (
787
792
module , cfn , stack_params ["StackName" ], bool (module .params .get ("termination_protection" ))
788
793
)
789
- result = update_stack (module , stack_params , cfn , module .params .get ("events_limit" ))
794
+ if not changeset_updated :
795
+ result = update_stack (module , stack_params , cfn , module .params .get ("events_limit" ))
790
796
791
797
# format the stack output
792
798
0 commit comments