Skip to content

Commit 384ae0a

Browse files
authored
Merge pull request #4402 from sanathkr/fix4364
fix(cloudformation): Support S3 URLs with region names
2 parents 2a6b72f + f628dd3 commit 384ae0a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

awscli/customizations/cloudformation/artifact_exporter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ def do_export(self, resource_id, resource_dict, parent_dir):
438438
template_path = resource_dict.get(self.PROPERTY_NAME, None)
439439

440440
if template_path is None or is_s3_url(template_path) or \
441+
template_path.startswith(self.uploader.s3.meta.endpoint_url) or \
441442
template_path.startswith("https://s3.amazonaws.com/"):
442443
# Nothing to do
443444
return

tests/unit/customizations/cloudformation/test_artifact_exporter.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ class TestArtifactExporter(unittest.TestCase):
210210

211211
def setUp(self):
212212
self.s3_uploader_mock = Mock()
213+
self.s3_uploader_mock.s3.meta.endpoint_url = "https://s3.some-valid-region.amazonaws.com"
213214

214215
def test_parse_s3_url(self):
215216

@@ -746,6 +747,18 @@ def test_export_cloudformation_stack_no_upload_path_is_httpsurl(self):
746747
self.assertEquals(resource_dict[property_name], s3_url)
747748
self.s3_uploader_mock.upload_with_dedup.assert_not_called()
748749

750+
def test_export_cloudformation_stack_no_upload_path_is_s3_region_httpsurl(self):
751+
stack_resource = CloudFormationStackResource(self.s3_uploader_mock)
752+
resource_id = "id"
753+
property_name = stack_resource.PROPERTY_NAME
754+
755+
s3_url = "https://s3.some-valid-region.amazonaws.com/hello/world"
756+
resource_dict = {property_name: s3_url}
757+
758+
stack_resource.export(resource_id, resource_dict, "dir")
759+
self.assertEquals(resource_dict[property_name], s3_url)
760+
self.s3_uploader_mock.upload_with_dedup.assert_not_called()
761+
749762
def test_export_cloudformation_stack_no_upload_path_is_empty(self):
750763
stack_resource = CloudFormationStackResource(self.s3_uploader_mock)
751764
resource_id = "id"

0 commit comments

Comments
 (0)