Repository: aws/aws-cli

Issue:
--output text results in "None" while --output json gives correct result on cloudformation changesets
Hi,

the following gives "CREATE_COMPLETE" which is correct

`aws cloudformation describe-change-set --change-set-name website-production-alb-a-1-0-7 --stack-name website-production-alb-a`

while this gives "None" which is incorrect

`aws cloudformation describe-change-set --change-set-name website-production-alb-a-1-0-7 --stack-name website-production-alb-a --output text`

`aws --version`
`aws-cli/1.16.110 Python/3.7.2 Darwin/18.2.0 botocore/1.12.100`

colleague has aws-cli/1.16.1 which also gives correct result on text.



Discussion:
I have also noticed this problem, same version, but linux. 
Iterating through versions using pip --user installs, I can see that this regression was introduced in release version 1.16.108
Try using --no-paginate switch to the command and see if it resolves the issue.
@sriramho 
it does, thanks!

But y?!
@konstantinj - Thank you for reporting the behavior. I was able to reproduce the issue and confirmed it as a bug. We are looking into getting this resolved. 

Followings are the commands were used to reproduce the problem:
```
$ aws cloudformation describe-change-set --change-set-name mychangeset --stack-name mystack --output text

$ aws cloudformation describe-change-set --change-set-name mychangeset --stack-name mystack --output text --no-paginate
```
I found CLI version 1.16.100 gives correct result but returns ```none``` with version 1.16.110.  If the option ```--no-paginate``` is used with  version 1.16.110 it returns the correct result.


Resolving patch:
diff --git a/awscli/formatter.py b/awscli/formatter.py
--- a/awscli/formatter.py
+++ b/awscli/formatter.py
@@ -231,8 +231,12 @@ def __call__(self, command_name, response, stream=None):
         try:
             if is_response_paginated(response):
                 result_keys = response.result_keys
-                for page in response:
-                    current = {}
+                for i, page in enumerate(response):
+                    if i > 0:
+                        current = {}
+                    else:
+                        current = response.non_aggregate_part
+
                     for result_key in result_keys:
                         data = result_key.search(page)
                         set_value_from_jmespath(


Test patch:
diff --git a/tests/unit/output/test_text_output.py b/tests/unit/output/test_text_output.py
--- a/tests/unit/output/test_text_output.py
+++ b/tests/unit/output/test_text_output.py
@@ -77,6 +77,70 @@ def test_text_response(self):
             'ENGINEDEFAULTS\tNone\n')
 
 
+class TestDescribeChangesets(BaseAWSCommandParamsTest):
+
+    def setUp(self):
+        super(TestDescribeChangesets, self).setUp()
+        self.first_parsed_response = {
+            'Capabilities': ['CAPABILITY_IAM'],
+            'ChangeSetId': (
+                'arn:aws:cloudformation:us-west-2:12345:changeSet'
+                '/mychangeset/12345'
+            ),
+            'ChangeSetName': 'mychangeset',
+            'Changes': [{"ChangeId": "1"}],
+            'CreationTime': '2019-04-08T14:21:53.765Z',
+            'ExecutionStatus': 'AVAILABLE',
+            'NotificationARNs': [],
+            'RollbackConfiguration': {'RollbackTriggers': []},
+            'StackId': (
+                'arn:aws:cloudformation:us-west-2:12345:stack'
+                '/MyStack/12345'
+            ),
+            'StackName': 'MyStack',
+            'Status': 'CREATE_COMPLETE',
+            'NextToken': "more stuff"
+        }
+        self.second_parsed_response = {
+            'Capabilities': ['CAPABILITY_IAM'],
+            'ChangeSetId': (
+                'arn:aws:cloudformation:us-west-2:12345:changeSet'
+                '/mychangeset/12345'
+            ),
+            'ChangeSetName': 'mychangeset',
+            'Changes': [{"ChangeId": "2"}],
+            'CreationTime': '2019-04-08T14:21:53.765Z',
+            'ExecutionStatus': 'AVAILABLE',
+            'NotificationARNs': [],
+            'RollbackConfiguration': {'RollbackTriggers': []},
+            'StackId': (
+                'arn:aws:cloudformation:us-west-2:12345:stack'
+                '/MyStack/12345'
+            ),
+            'StackName': 'MyStack',
+            'Status': 'CREATE_COMPLETE'
+        }
+        self.parsed_responses = [
+            self.first_parsed_response,
+            self.second_parsed_response,
+        ]
+
+    def test_non_aggregate_keys(self):
+        output = self.run_cmd(
+            ('cloudformation describe-change-set --change-set-name mychangeset'
+             ' --stack-name MyStack --output text'),
+            expected_rc=0
+        )[0]
+        self.assertEqual(
+            output,
+            ("arn:aws:cloudformation:us-west-2:12345:changeSet/mychangeset/"
+             "12345\tmychangeset\t2019-04-08T14:21:53.765Z\tNone\tAVAILABLE"
+             "\tNone\tarn:aws:cloudformation:us-west-2:12345:stack/MyStack"
+             "/12345\tMyStack\tCREATE_COMPLETE\tNone\tNone\n"
+             "CAPABILITIES\tCAPABILITY_IAM\nCHANGES\t1\nCHANGES\t2\n")
+        )
+
+
 class CustomFormatter(Formatter):
     def __call__(self, operation, response, stream=None):
         self.stream = self._get_default_stream()