fix: Add intrinsic support for AWS::Serverless::Api BasePath property#3808
Closed
reedham-aws wants to merge 5 commits intoaws:developfrom
Closed
fix: Add intrinsic support for AWS::Serverless::Api BasePath property#3808reedham-aws wants to merge 5 commits intoaws:developfrom
reedham-aws wants to merge 5 commits intoaws:developfrom
Conversation
seshubaws
reviewed
Aug 28, 2025
seshubaws
previously approved these changes
Aug 28, 2025
Vandita2020
reviewed
Aug 28, 2025
7efc3e8 to
d23f981
Compare
Vandita2020
approved these changes
Aug 28, 2025
valerena
reviewed
Aug 28, 2025
| mapping_basepath = path if normalize_basepath else basepath | ||
| logical_id = "{}{}{}".format(self.logical_id, path, "BasePathMapping") | ||
| if is_intrinsic(basepath): | ||
| mapping_basepath = basepath |
Contributor
There was a problem hiding this comment.
So the parameter NormalizeBasePath is not used anymore if the BasePath is passed as an intrinsic?
| logical_id = "{}{}{}".format(self.logical_id, path, "BasePathMapping") | ||
| if is_intrinsic(basepath): | ||
| mapping_basepath = basepath | ||
| logical_id = self.logical_id + "BasePathMapping" |
Contributor
There was a problem hiding this comment.
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?
| CertificateArn: !Ref MyDomainCert | ||
| EndpointConfiguration: !Ref EndpointConf | ||
| BasePath: [/get, /fetch] | ||
| BasePath: !Sub '${AWS::Region}-api' |
Contributor
There was a problem hiding this comment.
Can you still keep the list, but do with intrinsics instead?
Something like
Suggested change
| BasePath: !Sub '${AWS::Region}-api' | |
| BasePath: | |
| - !Sub '${AWS::Region}-get' | |
| - !Sub '${AWS::Region}-fetch' |
| 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): |
Contributor
There was a problem hiding this comment.
Thoughts on adding this same support on http_api_generator.py file?
Contributor
Author
|
Closed due to realization that we don't actually want to support intrinsics for |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available
N/a
Description of changes
The
BasePathattribute ofAws::Serverless::Apidoes not currently accept!Subas a parameter, instead leaving it as blank or returningNone. As an example,Transforms to the below, without the actual BasePath being added.
After updates
With the updates to allow intrinsics for this property, the output now looks like:
Description of how you validated changes
Manually ran the transform with and without the updated changes and compared the templates.
Updated the transform tests to include this new case. I didn't add any new tests because there are other locations that have
BasePathwithout the intrinsics, so I figured it was fine to add this in theapi_with_basic_custom_domain_intrinsicstests.Also confirmed that the added tests failed with the older transform version.
Checklist
Examples?
Please reach out in the comments if you want to add an example. Examples will be
added to
sam initthrough aws/aws-sam-cli-app-templates.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.