Open ricardoinacio opened 3 years ago
Thanks for the feedback. We will be adding this to our intake for prioritization.
In the meantime, we highly recommend you to use SAM Accelerate to test this in your development environment in the cloud. Here is a helpful video to learn more about it, and here is the documentation for the beta feature. Please let us know if this helps with your testing needs.
I am also experiencing this issue. It's not too bad for environment variables, as I can just overwrite them in the file passed to --env-vars
, but this isn't possible if I use Mappings in an actual function property like Timeout
. SAM Accelerate doesn't help either when I need this template to run entirely locally (for a demo where I won't have internet).
Any update on this?
I came across an issue (reported here) where layers were not being included, and it was because I was using a mapping to provide the layer version. A SAM template is supposed to be an extension of a CloudFormation template, so it somewhat beggars believe that not all of the intrinsic functions that are available in a CF template can be used.
Will this issue be fixed? If so, hopefully it will be soon.
I've been stung by this issue again today, although with the !Sub
intrinsic. I can find previous issues that have been closed by AWS (including #528 and #1038), but these issues have been closed without resolution.
For some it is not appropriate sam sync
, so that cannot be the solution. The sam local
commands have been provided and should be expected to work.
Please provide an update on the overarching issue of intrinsic functions not working with sam local
.
I've just noticed something weird. When I run sam local invoke
with an environment that has an integer value in the map, the corresponding environment variable is empty, but not if it's a string
Mappings:
Environments:
local:
collectionPort: 9200
...
Globals:
Function:
Environment:
Variables:
COLLECTION_PORT: !FindInMap [ Environments, !Ref StageName, collectionPort ]
...
$ sam local invoke ...
...
[INFO] 2023-08-03T17:34:55.361Z ace04caa-7c77-4244-b7ad-db85e23dee42
environ=environ({'AWS_LAMBDA_FUNCTION_MEMORY_SIZE': '1024', '_HANDLER':
'handler.handler', .... 'COLLECTION_PORT': '', ...
Mappings:
Environments:
local:
collectionHost: aos
collectionPort: "9200"
...
Globals:
Function:
Environment:
Variables:
COLLECTION_PORT: !FindInMap [ Environments, !Ref StageName, collectionPort ]
...
$ sam local invoke ...
...
[INFO] 2023-08-03T17:34:55.361Z ace04caa-7c77-4244-b7ad-db85e23dee42
environ=environ({'AWS_LAMBDA_FUNCTION_MEMORY_SIZE': '1024',
'_HANDLER': 'handler.handler', .... 'COLLECTION_PORT': '9200', ...
Description:
I can't make a template.yaml with Mappings work when testing locally, although they will deploy and work as expected.
Steps to reproduce:
sam init --runtime python3.8
template.yaml
sam build --parameter-overrides ParamaterKey=Environment,ParameterValue=test --use-container
sam local start-api --debug
, and it will show unresolved references.Observed result:
curl http://127.0.0.1/hello
and sam will show an error:Expected result:
There shouldn't be unresolved FindInMap causing exceptions, just as it doesn't happen with CloudFormation itself.
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
sam --version
: 1.19.1 and 1.20.0