From b52d7155678017340fd39711b335ec2c582d6783 Mon Sep 17 00:00:00 2001 From: Kevin C Date: Tue, 22 Oct 2019 17:31:06 -0400 Subject: [PATCH] add change_set_id to cloudformation output (#63752) * Add change_set_id to the cloudformation module output when a change set is created * Add module return documentation for change_set_id * changelog --- .../fragments/63752-cloudformation-return-changeset-id.yaml | 2 ++ lib/ansible/modules/cloud/amazon/cloudformation.py | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 changelogs/fragments/63752-cloudformation-return-changeset-id.yaml diff --git a/changelogs/fragments/63752-cloudformation-return-changeset-id.yaml b/changelogs/fragments/63752-cloudformation-return-changeset-id.yaml new file mode 100644 index 00000000000..0448396b853 --- /dev/null +++ b/changelogs/fragments/63752-cloudformation-return-changeset-id.yaml @@ -0,0 +1,2 @@ +minor_changes: + - cloudformation - Return change_set_id in the cloudformation output if a change set was created. diff --git a/lib/ansible/modules/cloud/amazon/cloudformation.py b/lib/ansible/modules/cloud/amazon/cloudformation.py index 365114203f2..1bcf1f85725 100644 --- a/lib/ansible/modules/cloud/amazon/cloudformation.py +++ b/lib/ansible/modules/cloud/amazon/cloudformation.py @@ -291,6 +291,11 @@ log: returned: always type: list sample: ["updating stack"] +change_set_id: + description: The ID of the stack change set if one was created + returned: I(state=present) and I(create_changeset=true) + type: str + sample: "arn:aws:cloudformation:us-east-1:012345678901:changeSet/Ansible-StackName-f4496805bd1b2be824d1e315c6884247ede41eb0" stack_resources: description: AWS stack resources and their status. List of dictionaries, one dict per resource. returned: state == present @@ -449,6 +454,7 @@ def create_changeset(module, stack_params, cfn, events_limit): # Lets not hog the cpu/spam the AWS API time.sleep(1) result = stack_operation(cfn, stack_params['StackName'], 'CREATE_CHANGESET', events_limit) + result['change_set_id'] = cs['Id'] result['warnings'] = ['Created changeset named %s for stack %s' % (changeset_name, stack_params['StackName']), 'You can execute it using: aws cloudformation execute-change-set --change-set-name %s' % cs['Id'], 'NOTE that dependencies on this stack might fail due to pending changes!']