Repository: localstack/localstack

Issue:
CreationTime for cloudformation stacks is always a fixed value
## Issue description
When creating a CloudFormation stack, the `CreationDate` is always `2011-05-23T15:47:44Z`

## Steps to reproduce
1. Prepare a CloudFormation file, for example
```yml
AWSTemplateFormatVersion: 2010-09-09
Description: My Stack
Resources:
  LambdaCodeBucket:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: my-bucket
```
2. Create a new stack based on this file, I used the command:
```bash
awslocal cloudformation create-stack --stack-name gch --template-body file://stack.yml
```
3. List all the created stacks and confirm the `CreationDate` is not a present date
```
awslocal cloudformation list-stacks
```
```
{
    "StackSummaries": [
        {
            "StackId": "arn:aws:cloudformation:us-east-1:000000000000:stack/stack/27187f13-a645-40a0-8788-62d502358216",
            "StackName": "stack",
            "TemplateDescription": "My Stack",
            "CreationTime": "2011-05-23T15:47:44Z",
            "StackStatus": "CREATE_COMPLETE"
        }
    ]
}
```


Discussion:

Resolving patch:
diff --git a/localstack/services/cloudformation/cloudformation_listener.py b/localstack/services/cloudformation/cloudformation_listener.py
--- a/localstack/services/cloudformation/cloudformation_listener.py
+++ b/localstack/services/cloudformation/cloudformation_listener.py
@@ -8,7 +8,7 @@
 from six.moves.urllib import parse as urlparse
 from samtranslator.translator.transform import transform as transform_sam
 from localstack.utils.aws import aws_stack
-from localstack.utils.common import to_str, obj_to_xml, safe_requests, run_safe
+from localstack.utils.common import to_str, obj_to_xml, safe_requests, run_safe, timestamp
 from localstack.utils.analytics import event_publisher
 from localstack.utils.cloudformation import template_deployer
 from localstack.services.generic_proxy import ProxyListener
@@ -117,6 +117,13 @@ def get_template_body(req_data):
     raise Exception('Unable to get template body from input: %s' % req_data)
 
 
+def fix_hardcoded_creation_date(response):
+    search = '<CreationTime>2011-05-23T15:47:44Z</CreationTime>'
+    replace = '<CreationTime>%s</CreationTime>' % timestamp()
+    response._content = to_str(response._content or '').replace(search, replace)
+    response.headers['Content-Length'] = str(len(response._content))
+
+
 class ProxyListenerCloudFormation(ProxyListener):
 
     def forward_request(self, method, path, data, headers):
@@ -178,6 +185,7 @@ def return_response(self, method, path, data, headers, response):
 
         if response._content:
             aws_stack.fix_account_id_in_arns(response)
+            fix_hardcoded_creation_date(response)
 
     def _list_stack_names(self):
         client = aws_stack.connect_to_service('cloudformation')
diff --git a/localstack/services/dynamodb/dynamodb_listener.py b/localstack/services/dynamodb/dynamodb_listener.py
--- a/localstack/services/dynamodb/dynamodb_listener.py
+++ b/localstack/services/dynamodb/dynamodb_listener.py
@@ -4,7 +4,7 @@
 import logging
 import threading
 from binascii import crc32
-from requests.models import Response
+from requests.models import Request, Response
 from localstack import config
 from localstack.utils.aws import aws_stack, aws_responses
 from localstack.utils.common import to_bytes, to_str, clone
@@ -69,6 +69,11 @@ def forward_request(self, method, path, data, headers):
                 if 'ResourceNotFoundException' in str(e):
                     return get_table_not_found_error()
                 raise
+            # Fix incorrect values if ReturnValues==ALL_OLD and ReturnConsumedCapacity is
+            # empty, see https://github.com/localstack/localstack/issues/2049
+            if data.get('ReturnValues') == 'ALL_OLD' and not data.get('ReturnConsumedCapacity'):
+                data['ReturnConsumedCapacity'] = 'TOTAL'
+                return Request(data=json.dumps(data), method=method, headers=headers)
         elif action == '%s.DescribeTable' % ACTION_PREFIX:
             # Check if table exists, to avoid error log output from DynamoDBLocal
             table_names = ddb_client.list_tables()['TableNames']


Test patch: