InlineCode not working for sam invoke
See original GitHub issueDescription:
Trying to add InlineCode (node) in the tamplate file. Getting an error:
Invoking app.lambdaHandler (nodejs10.x)
Traceback (most recent call last):
File "/usr/local/bin/sam", line 8, in <module>
sys.exit(cli())
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/samcli/lib/telemetry/metric.py", line 152, in wrapped
raise exception # pylint: disable=raising-bad-type
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/samcli/lib/telemetry/metric.py", line 121, in wrapped
return_value = func(*args, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/samcli/lib/utils/version_checker.py", line 42, in wrapped
actual_result = func(*args, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/samcli/cli/main.py", line 90, in wrapper
return func(*args, **kwargs)
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/samcli/commands/local/invoke/cli.py", line 81, in cli
do_cli(
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/samcli/commands/local/invoke/cli.py", line 167, in do_cli
context.local_lambda_runner.invoke(
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/samcli/commands/local/lib/local_lambda.py", line 120, in invoke
config = self.get_invoke_config(function)
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/samcli/commands/local/lib/local_lambda.py", line 163, in get_invoke_config
code_abs_path = resolve_code_path(self.cwd, function.codeuri)
File "/usr/local/Cellar/aws-sam-cli/1.21.1/libexec/lib/python3.8/site-packages/samcli/lib/utils/codeuri.py", line 43, in resolve_code_path
if not os.path.isabs(codeuri):
File "/usr/local/Cellar/python@3.8/3.8.8_1/Frameworks/Python.framework/Versions/3.8/lib/python3.8/posixpath.py", line 62, in isabs
s = os.fspath(s)
TypeError: expected str, bytes or os.PathLike object, not NoneType
Steps to reproduce:
- setup hello world example with sam init
- add InlineCode property to HelloWorldFunction Relevant part of the template:
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
# CodeUri: hello-world/
InlineCode: |
exports.handler = async (event) => {
return {
statusCode: 200,
headers: {'Content-Type':'application/json'},
body: "hello"
}
}
Handler: app.lambdaHandler
Runtime: nodejs10.x
Events:
HelloWorld:
Type: Api
Properties:
Path: /hello
Method: get
Observed result:
Getting error above
Expected result:
Function should run
Additional environment details (Ex: Windows, Mac, Amazon Linux etc)
- OS: Macos 11.2.3
sam --version
: SAM CLI, version 1.21.1
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Function - AWS Serverless Application Model
This property addresses a problem that occurs when an AWS SAM template has ... The object that describes event invoke configuration on a...
Read more >Output FunctionUrl from AWS::Serverless::Function with URL
I saw the AWS::Lambda::Url resource created by SAM but was not sure if it was accessible from the untransformed template. Add your answer....
Read more >Getting started with the AWS SAM CLI | by Aveek Das
With the help of this utility, you can easily define your resources and get those deployed to any environment in the AWS without...
Read more >AWS SAM for a serverless Java application - Medium
Now let's create a POJO class for our data model. To simplify work with DynamoDB, let's use AWS SDK version 2 for Java,...
Read more >Introduction to SAM Part II: Template and architecture
CloudFormation recognises a top-level template key Transform: AWS::Serverless-2016-10-31 and invokes the SAM Translator if it is found.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry my bad, just confirmed that local invoke with inline code is not yet supported! Will view this as a feature request. But please keep using this style of handler for inline functions, thanks! @mihaa1
Duplicate of https://github.com/aws/aws-sam-cli/issues/790 Closing