-
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
Unsupported intrinsic functions #2533
Comments
@tariromukute If I'm understanding correctly the problem you're encountering is |
Awesome. Thanks @hoffa for reproducing the issue and for creating an issue for it. I will try the |
This breaks Resources:
FooFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: !Sub "target/foo-bar-functions-${Ver}.jar"
Handler: com.example.FooBar::foo SAM gives me an error:
If I try the workaround noted here of adding
The problem is that SAM is not updating the |
If the AWS::LanguageExtensions transform is the solution, is that transform available in all regions where the serverless transform is available? |
I've been using the language extension to workaround this issue with using |
Hi @davidchatz, feel free to create an issue in aws-sam-cli repository on this. |
I am coming from #1616. |
I just now ran into same situation while trying to pass "TimeoutSeconds" as integer in |
Hi, I'm having a very simple problem: Events:
Status:
Type: HttpApi
Properties:
ApiId: !Ref HttpApi
Method: get
Path: !Sub "/${Version}/status" I cannot use |
@carlosleon-wl .. you can use the workaround mentioned in this issue. Add the
|
The problem
Some properties have limited support for intrinsic functions (e.g.
Ref
,Fn::GetAtt
,Fn::If
, etc.).Using unsupported intrinsic functions in such properties can cause issues with deployment.
Why it happens
AWS SAM is a AWS CloudFormation macro; it receives a SAM template as input (as-is, along with the intrinsic functions), and returns a CloudFormation template which is then deployed by CloudFormation.
This means that SAM is unable to resolve some intrinsic functions. For example, an
!If
condition with aRef
to a stack parameter is resolvable (SAM has access to the stack parameters), but aRef
to a stack resource is not (as the transform happens before deployment). Furthermore, SAM supports limited intrinsic function resolution for only some properties.It's not an issue for properties that are passed as-is to properties of the underlying CloudFormation resources, but it becomes an issue when SAM must know the value for its transform logic.
Workarounds
Add the
AWS::LanguageExtensions
transformThe
AWS::LanguageExtensions
transform will resolve intrinsic functions if the value is known whenTransform
s are run.Replace:
With:
The AWS SAM CLI currently doesn't process
AWS::LanguageExtensions
locally, so it won't work where local transforms are needed.Note
There is a known issue where
AWS::Serverless-2016-10-31
andAWS::LanguageExtensions
can conflict; see aws-cloudformation/cfn-language-discussion#109.Use a pass-through property, if available
Pass-through properties are passed directly to the underlying CloudFormation resources, hence intrinsic functions work. Check the "AWS CloudFormation compatibility" notice under properties to see whether the property is passed as-is to an underlying CloudFormation resource.
For example for the
Schedule
event type, use theState
property instead ofEnabled
.Use raw CloudFormation
If nothing else works, you can always switch to using the underlying CloudFormation resources directly. Since they are not processed by SAM, CloudFormation will be able to resolve the intrinsic functions.
You can get the transformed CloudFormation template of a stack
<my-stack>
using:aws cloudformation get-template --query TemplateBody --change-set-name "$(aws cloudformation describe-stacks --query 'Stacks[0].ChangeSetId' --output text --stack-name <my-stack>)"
Which you can then use to replace the affected resources.
See also #3007 (comment) for other ways of transforming a SAM template into a CloudFormation template.
The text was updated successfully, but these errors were encountered: