-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix: Add intrinsic support for AWS::Serverless::Api BasePath property #3808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
60c401c
01e3062
bb9c0c8
10eb1ad
d23f981
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -535,13 +535,13 @@ def _construct_api_domain( # noqa: PLR0912, PLR0915 | |
|
||
self._set_optional_domain_properties(domain) | ||
|
||
basepaths: Optional[List[str]] | ||
basepaths: Optional[List[Any]] | ||
basepath_value = self.domain.get("BasePath") | ||
# Create BasepathMappings | ||
if self.domain.get("BasePath") and isinstance(basepath_value, str): | ||
if isinstance(basepath_value, str) or is_intrinsic(basepath_value): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thoughts on adding this same support on http_api_generator.py file? |
||
basepaths = [basepath_value] | ||
elif self.domain.get("BasePath") and isinstance(basepath_value, list): | ||
basepaths = cast(Optional[List[Any]], basepath_value) | ||
elif isinstance(basepath_value, list): | ||
basepaths = basepath_value | ||
reedham-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else: | ||
basepaths = None | ||
|
||
|
@@ -554,13 +554,19 @@ def _construct_api_domain( # noqa: PLR0912, PLR0915 | |
basepath_mapping = self._create_basepath_mapping(api_domain_name, rest_api, None, None) | ||
basepath_resource_list.extend([basepath_mapping]) | ||
else: | ||
sam_expect(basepaths, self.logical_id, "Domain.BasePath").to_be_a_list_of(ExpectedType.STRING) | ||
if not is_intrinsic(basepaths[0]): | ||
sam_expect(basepaths, self.logical_id, "Domain.BasePath").to_be_a_list_of(ExpectedType.STRING) | ||
for basepath in basepaths: | ||
# Remove possible leading and trailing '/' because a base path may only | ||
# contain letters, numbers, and one of "$-_.+!*'()" | ||
path = "".join(e for e in basepath if e.isalnum()) | ||
mapping_basepath = path if normalize_basepath else basepath | ||
logical_id = "{}{}{}".format(self.logical_id, path, "BasePathMapping") | ||
if is_intrinsic(basepath): | ||
mapping_basepath = basepath | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the parameter |
||
logical_id = self.logical_id + "BasePathMapping" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what happens if there are different base paths all defined with intrinsics? Will they just have the same logical id? Should we add some sort of hash for the intrinsic values here, so we actually create different resources? |
||
else: | ||
# Remove possible leading and trailing '/' because a base path may only | ||
# contain letters, numbers, and one of "$-_.+!*'()" | ||
path = "".join(e for e in basepath if e.isalnum()) | ||
mapping_basepath = path if normalize_basepath else basepath | ||
logical_id = "{}{}{}".format(self.logical_id, path, "BasePathMapping") | ||
|
||
basepath_mapping = self._create_basepath_mapping( | ||
api_domain_name, rest_api, logical_id, mapping_basepath | ||
) | ||
|
@@ -810,7 +816,7 @@ def _create_basepath_mapping( | |
api_domain_name: PassThrough, | ||
rest_api: ApiGatewayRestApi, | ||
logical_id: Optional[str], | ||
basepath: Optional[str], | ||
basepath: Optional[Any], | ||
reedham-aws marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) -> ApiGatewayBasePathMapping: | ||
|
||
basepath_mapping: ApiGatewayBasePathMapping | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -58,7 +58,7 @@ Resources: | |||||||||
DomainName: !Sub 'example-${AWS::Region}.com' | ||||||||||
CertificateArn: !Ref MyDomainCert | ||||||||||
EndpointConfiguration: !Ref EndpointConf | ||||||||||
BasePath: [/get, /fetch] | ||||||||||
BasePath: !Sub '${AWS::Region}-api' | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you still keep the list, but do with intrinsics instead? Something like
Suggested change
|
||||||||||
MutualTlsAuthentication: | ||||||||||
TruststoreUri: !Ref MyMTLSUri | ||||||||||
TruststoreVersion: !Ref MyMTLSVersion | ||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.