-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Conditionals, Refs, etc. in template yaml don't appear to be evaluated #194
Comments
Unfortunately SAM Local does not evaluate CloudFormation conditionals. CFN intrinsic functions has a lot of dense logic which is not practical to evaluate in its entirety. You can instead override the value of this param with a |
And there are no plans to support any intrinsic functions in the future? |
No, we do have plans. In fact, I am thinking of adding full support for a small subset of intrinsic functions. Today we have a half-baked support for many intrinsics. Can you explain your use case further? What do you think would be good set of intrinsics to support? |
For the use case described above I'm satisfied with your recommendation of using However, I tried using those intrinsic functions to toggle between "bundle.zip" and "." for #195, and that didn't work. I believe that just supporting the Condition Functions would let me get that to work as expected, but as I said in that ticket I'm happy with a different solution if there's a better one. I'll close this, since I have no use case that requires this as a solution and you've answered my question of "is this supposed to work?" Thank you for your help! |
Should this caveat be mentioned in the documentation? It took a lot of searching to hunt down this closed Git issue. Maybe mention under Project Status or a new section on limitations/caveats? |
One other note: the workaround as described here is out of date/incorrect. Need to override all environment variables via a file. I tested that you can override just some of the variables, you do not need to specify them all https://github.com/awslabs/aws-sam-local#environment-variable-file |
@sanathkr I need to deploy a lambda fn to 2 different AWS accounts. In one, I need to specify a VpcConfig, in the other, I don't/can't. Simply replacing the values with empty strings in the latter case won't work. The entire block needs to be removed:
|
This just got me. Took a while to figure out what the problem was! No errors, just silently blanking out my environment vars. After I found this, I created an env.json file to use just for local dev, but this should be in big letters in the documentation somewhere (or better yet, fixed!) |
oh my god, same thing happened to me just now, took me hours to figure out why, the error message was not very helpful:
I was using I was getting |
This is the most horrible mis-feature I have heard of in a long long time. I've spent TWO HOURS trying to figure out why references don't work. Only to find out that because I'm testing locally they were never going to work anyway? Testing locally is uselessly and completely broken if things like !Ref don't work. If you're not going to support this, please take away the pretense of support for local testing. It is a lie. |
@JasonHenriksen I apologize on behalf of the team for the poor experience you have had. Can you explain what you are trying to do further and what version of SAM CLI you are using? For context, SAM CLI does support Happy to talk directly with you on Slack, as well. Could be easier than going back and forth on through an issue. |
@jfuss So specifically, I wanted to use SAM to allocate a bucket, and pass the name of the bucket as needed by the aws-sdk into a node lambda. I was only testing locally and I tried every possible example to do that I could find to do that. I spent literally hours trying to do this, and I didn't bother to try it on the cloud, because my thinking was "if it doesn't work locally what's the point of trying it on the server." Really, the promise of local testing is that it does replicate what cloudformation does on a local box. Especially for brand new users like me who are just learning this stuff. I have zero experience with cloudformation. I am starting out brand new with SAM, and from my perspective, every single example of how to pass template variables around just mysteriously does not work. So here are my asks:
The idea of local run is a huge win when it works. I am thankful to your team for putting in the time and effort. However, SAM and CloudFormation are your API. If there are parts of that API that you are leaving unimplemented, you really really need to provide an error message saying so. Thanks again for all your work and your response to my message.
|
I agree with the comments above that this should at least be mentioned in the documentation. |
@jfuss, guess who ran into this almost five years after this issue was created. This guy! It might be useful to put a note about testing locally with SAM somewhere in the documentation. |
I can see references being a problem, but conditionals really ought to be supported |
I expected the conditional here to produce "some value" when run with sam local and the EnvType parameter unset or set to "test". Instead it produced no value. My function sees the environment variable "TABLE" as holding an empty string.
There's an error in the output of
sam local start-api
when using this template:ERROR: json: cannot unmarshal array into Go struct field AWSServerlessFunction_FunctionEnvironment.Variables of type string
. Converting the array style!Equals
and!If
to theirEquals:
andIf:
equivalents merely changes the error to 'cannot unmarshal object into...'The text was updated successfully, but these errors were encountered: