[Feature] Local support for integration type Mock
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
I'm trying to create a mock method integration and test it in the local environment. I was able to build and start the following example but I'm getting the following error when trying to hit the endpoint.
Do you know if there is anything else that I need to configure in order to have it working in my local environment?
Sam version
```
$ sam --version
SAM CLI, version 1.78.0
```
Error
```
Exception on / [GET]
Traceback (most recent call last):
File "/usr/local/Cellar/aws-sam-cli/1.78.0/libexec/lib/python3.11/site-packages/flask/app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.78.0/libexec/lib/python3.11/site-packages/flask/app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.78.0/libexec/lib/python3.11/site-packages/flask/app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.78.0/libexec/lib/python3.11/site-packages/flask/app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.78.0/libexec/lib/python3.11/site-packages/samcli/local/apigw/local_apigw_service.py", line 364, in _request_handler
self.lambda_runner.invoke(route.function_name, event, stdout=stdout_stream_writer, stderr=self.stderr)
File "/usr/local/Cellar/aws-sam-cli/1.78.0/libexec/lib/python3.11/site-packages/samcli/commands/local/lib/local_lambda.py", line 113, in invoke
function = self.provider.get(function_identifier)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/Cellar/aws-sam-cli/1.78.0/libexec/lib/python3.11/site-packages/samcli/lib/providers/sam_function_provider.py", line 118, in get
raise ValueError("Function name is required")
ValueError: Function name is required
2023-04-05 14:42:40 127.0.0.1 - - [05/Apr/2023 14:42:40] "GET / HTTP/1.1" 502 -
```
template.yamñ
```yaml
RootMethodGet:
Type: AWS::ApiGateway::Method
Properties:
RestApiId: !Ref AppApi
ResourceId: !GetAtt AppApi.RootResourceId
HttpMethod: GET
AuthorizationType: NONE
Integration:
Type: MOCK
RequestTemplates:
application/json: '{"statusCode": 200}'
IntegrationResponses:
- StatusCode: 200
PassthroughBehavior: WHEN_NO_MATCH
MethodResponses:
- StatusCode: 200
ResponseModels:
application/json: Empty
```
Contributor guide
Assessment
This issue has not been assessed yet.