File tree Expand file tree Collapse file tree 3 files changed +13
-13
lines changed
localstack/services/cloudformation
tests/aws/services/cloudformation/api Expand file tree Collapse file tree 3 files changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -86,15 +86,15 @@ def convert_s3_to_local_url(url: str) -> str:
86
86
headers = {"host" : url_parsed .netloc }
87
87
bucket_name , key_name = extract_bucket_name_and_key_from_headers_and_path (headers , path )
88
88
89
- if not bucket_name or not key_name :
90
- if url_parsed .scheme != "s3" and not (
91
- url_parsed .netloc .startswith ("s3." ) or ".s3." in url_parsed .netloc
92
- ):
93
- raise ValidationError ("TemplateURL must be a supported URL." )
89
+ if url_parsed .scheme == "s3" :
94
90
raise ValidationError (
95
91
f"S3 error: Domain name specified in { url_parsed .netloc } is not a valid S3 domain"
96
92
)
97
93
94
+ if not bucket_name or not key_name :
95
+ if not (url_parsed .netloc .startswith ("s3." ) or ".s3." in url_parsed .netloc ):
96
+ raise ValidationError ("TemplateURL must be a supported URL." )
97
+
98
98
# note: make sure to normalize the bucket name here!
99
99
bucket_name = normalize_bucket_name (bucket_name )
100
100
local_url = f"{ config .service_url ('s3' )} /{ bucket_name } /{ key_name } "
Original file line number Diff line number Diff line change @@ -55,15 +55,15 @@ def test_create_stack_from_s3_template_url(
55
55
"""
56
56
)
57
57
58
- aws_client .s3 .put_object (Bucket = bucket_name , Key = "template.yml" , Body = to_bytes (template ))
58
+ aws_client .s3 .put_object (Bucket = bucket_name , Key = "test/ template.yml" , Body = to_bytes (template ))
59
59
60
60
match url_style :
61
61
case "s3_url" :
62
- template_url = f"s3://{ bucket_name } /template.yml"
62
+ template_url = f"s3://{ bucket_name } /test/ template.yml"
63
63
case "http_path" :
64
- template_url = f"https://s3.amazonaws.com/{ bucket_name } /template.yml"
64
+ template_url = f"https://s3.amazonaws.com/{ bucket_name } /test/ template.yml"
65
65
case "http_host" :
66
- template_url = f"https://{ bucket_name } .s3.amazonaws.com/template.yml"
66
+ template_url = f"https://{ bucket_name } .s3.amazonaws.com/test/ template.yml"
67
67
case "http_invalid" :
68
68
# note: using an invalid (non-existing) URL here, but in fact all non-S3 HTTP URLs are invalid in real AWS
69
69
template_url = "https://example.com/dummy.yml"
Original file line number Diff line number Diff line change 25
25
}
26
26
},
27
27
"tests/aws/services/cloudformation/api/test_templates.py::test_create_stack_from_s3_template_url[s3_url]" : {
28
- "recorded-date" : " 08 -10-2023, 16:15:04 " ,
28
+ "recorded-date" : " 11 -10-2023, 00:03:44 " ,
29
29
"recorded-content" : {
30
30
"create-error" : {
31
31
"Error" : {
41
41
}
42
42
},
43
43
"tests/aws/services/cloudformation/api/test_templates.py::test_create_stack_from_s3_template_url[http_path]" : {
44
- "recorded-date" : " 08 -10-2023, 16:15:14 " ,
44
+ "recorded-date" : " 11 -10-2023, 00:03:53 " ,
45
45
"recorded-content" : {
46
46
"matching-topic" : [
47
47
{
51
51
}
52
52
},
53
53
"tests/aws/services/cloudformation/api/test_templates.py::test_create_stack_from_s3_template_url[http_host]" : {
54
- "recorded-date" : " 08 -10-2023, 16:15:24 " ,
54
+ "r
7832
ecorded-date" : " 11 -10-2023, 00:04:02 " ,
55
55
"recorded-content" : {
56
56
"matching-topic" : [
57
57
{
61
61
}
62
62
},
63
63
"tests/aws/services/cloudformation/api/test_templates.py::test_create_stack_from_s3_template_url[http_invalid]" : {
64
- "recorded-date" : " 08 -10-2023, 16:15:26 " ,
64
+ "recorded-date" : " 11 -10-2023, 00:04:04 " ,
65
65
"recorded-content" : {
66
66
"create-error" : {
67
67
"Error" : {
You can’t perform that action at this time.
0 commit comments