-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Support Ref in OpenApiVersion #2377
Comments
@nikitasius Does this only happen locally? |
hi, just tested, nope:
|
i.e. |
Looking at the code, SAM only validates against constant values therefore intrinsics are not supported for this field. See;
What is your use case here, where you need dynamic value of Open API version? Thanks! |
i just want to generate configs using btw, 3.0.3 or 3.0.0 passing fine the regex
Well, guess in this case it's a bug in SAM tool. Becase you allow to use "sam's unique only" features but you don't properly filter the configs. |
@nikitasius This comes down to how/where intrinsics are resolved. CloudFormation does not resolve intrinsics before calling SAM (or any CloudFormation Macro), so SAM has to re-implement behavior. We don't have a consistency here and tend to try not to resolve things, so we don't have to handle re-implementing resolving. So yes, your string passes the regex but SAM actually gets the Is there any reason you want to define this in a parameter? Usually they are for things that change often, which I assume this does not? Maybe I am missing some other use case that make this value. I only ask because of the above comment on where intrinsics get resolved, it would be nice if CloudFormation would just do a pass before calling SAM but that is a complete aside here. |
@j0lly to be honest i don't want to create philosophic discussions to be or not to be, etc. As i told before, i build a parameter set and use it. |
@nikitasius It helps us understand the use-case and the why. I understand the view point of just make this work but there are reasons (as described above) it doesn't work today. With that, this is a feature request to add Ref support and the way you will need to do this today is by providing inline and not using intrinsic functions. |
thanks. Yep i provide it as is w/o !Ref have no choice :) |
Can you try adding This works: Transform:
- AWS::LanguageExtensions
- AWS::Serverless-2016-10-31
Parameters:
MyParameter:
Type: String
Default: 3.0.0
Resources:
MyApi:
Type: AWS::Serverless::Api
Properties:
OpenApiVersion: !Ref MyParameter
StageName: prod
MyFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs16.x
Handler: index.handler
InlineCode: console.log("hi!")
Events:
ApiEvent:
Type: Api
Properties:
Method: GET
Path: /
RestApiId: !Ref MyApi |
Closing in favor of #2533. |
Description:
I add a param
OpenApiVersionParam
with a value3.0.3
and it doesn't pass the validationsam validate
Steps to reproduce:
and below in
Resources
:FAILS:
WORK:
Observed result:
Fails:
Error: [InvalidResourceException('DebugApi', "The OpenApiVersion value must be of the format '3.0.0'.")] ('DebugApi', "The OpenApiVersion value must be of the format '3.0.0'.")
Expected result:
Should work.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
Linux pentagon 5.10.0-13-amd64 #1 SMP Debian 5.10.106-1 (2022-03-17) x86_64 GNU/Linux
sam --version
:SAM CLI, version 1.46.0
eu-west-1
The text was updated successfully, but these errors were encountered: