Open EricXDong opened 1 week ago
@EricXDong Thanks for raising the issue.
Every Default member must be a string
is a rule that CloudFormation enforces. And SAM CLI does not support Fn::If
in local invoke. There is previous feature request for this - https://github.com/aws/aws-sam-cli/issues/6205
There are some alternatives you can try:
sam sync
to test on cloud instead of locallyFn::ImportValue
Thanks for your reply and the alternatives @hawflau, hope I can add my voice to the Fn::If
feature request!
Description:
In one project, I'm outputting a Lambda layer:
In a separate project, I want to import this layer:
This works in production, but not locally because
Fn::ImportValue
doesn't work locally. The standard workaround is to use Conditions on a parameter that is overridden on local runs:But this doesn't work because
Fn::If
isn't supported either. Users have run into similar issues where the recommended workaround was to instead define a parameter for the value itself, which is overridden on local runs. Applied to my case, that would be something like:However, this doesn't work because
Every Default member must be a string
, so it seems you can't use intrinsic functions in the default values of parameters.Observed result:
Expected result:
Expect to be able to
!ImportValue
a Lambda layer ARN in production, and override it with a hardcoded ARN in local environment.Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: SAM CLI, version 1.118.0