Try polling swift object before creating stack

Change-Id: I185d13c8c89df7ee27a7b4740d8895b3367fafa6
Closes-bug: #1491773
diff --git a/functional/test_aws_stack.py b/functional/test_aws_stack.py
index de8c6b8..ba4883f 100644
--- a/functional/test_aws_stack.py
+++ b/functional/test_aws_stack.py
@@ -15,6 +15,7 @@
 import random
 
 from oslo_log import log as logging
+import requests
 from six.moves.urllib import parse
 from swiftclient import utils as swiftclient_utils
 import yaml
@@ -103,7 +104,18 @@
         tempurl = swiftclient_utils.generate_temp_url(path, timeout,
                                                       key, 'GET')
         sw_url = parse.urlparse(oc.url)
-        return '%s://%s%s' % (sw_url.scheme, sw_url.netloc, tempurl)
+        full_url = '%s://%s%s' % (sw_url.scheme, sw_url.netloc, tempurl)
+
+        def download():
+            r = requests.get(full_url)
+            LOG.info('GET: %s -> %s' % (full_url, r.status_code))
+            return r.status_code == requests.codes.ok
+
+        # make sure that the object is available.
+        test.call_until_true(self.conf.build_timeout,
+                             self.conf.build_interval, download)
+
+        return full_url
 
     def test_nested_stack_create(self):
         url = self.publish_template(self.nested_name, self.nested_template)