Skip to content
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

SAM: accessing s3 via api gateway doesn't work #2773

Closed
Basile001 opened this issue Mar 22, 2021 · 3 comments
Closed

SAM: accessing s3 via api gateway doesn't work #2773

Basile001 opened this issue Mar 22, 2021 · 3 comments
Labels
stage/pm-review Waiting for review by our Product Manager, please don't work on this yet type/feature Feature request

Comments

@Basile001
Copy link

Hello,

SAM version:
C:\Users\Basile Grandperret>sam --version
SAM CLI, version 1.21.1C:\Users\Basile Grandperret>sam --version
SAM CLI, version 1.21.1

Today I tried to deploy my serverless stack locally with SAM but I encounter an error when I try to reach a static file in a S3 bucket via api - gateway. I will firstly post the message error and then I will try to explain my conf.

2021-03-19 14:41:29 * Running on http://127.0.0.1:8080/ (Press CTRL+C to quit)
Exception on /atlassian-connect.json
Traceback (most recent call last):
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\flask\app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\flask\app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\flask\app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\flask\_compat.py", line 39, in reraise
raise value
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\flask\app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\flask\app.py", line 1936, in dispatch_request
return self.view_functionshttp://rule.endpoint(**req.view_args)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\local\apigw\local_apigw_service.py", line 317, in _request_handler
self.lambda_runner.invoke(route.function_name, event, stdout=stdout_stream_writer, stderr=self.stderr)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\local\lib\local_lambda.py", line 101, in invoke
function = self.provider.get(function_identifier)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\providers\sam_function_provider.py", line 73, in get
raise ValueError("Function name is required")

My conf :
what appear in the console after > sam local start-api :

Mounting *********** at http://127.0.0.1:8080/api/********* [POST]
Mounting ***********-token-refresh at http://127.0.0.1:8080/api/****** [GET]
Mounting *********** at http://127.0.0.1:8080/api/***************{proxy+} [GET]
Mounting c*********** at http://127.0.0.1:8080/api/************ [GET, POST, PUT]
Mounting c***********e at http://127.0.0.1:8080/api/******************/{id} [DELETE, GET, PUT]
Mounting c***********e at http://127.0.0.1:8080/api/*****************/{id}/{proxy+} [POST, PUT]
Mounting c***********e at http://127.0.0.1:8080/api/**********************/{proxy+} [GET]
Mounting c***********r at http://127.0.0.1:8080/api/counters [GET]
Mounting None at http://127.0.0.1:8080/v1/webhook [POST]
Mounting None at http://127.0.0.1:8080/v1/postfunction [POST]
**Mounting None at http://127.0.0.1:8080/atlassian-connect.json [GET]**
Mounting None at http://127.0.0.1:8080/static/{proxy+} [GET]
Mounting ***********-html at http://127.0.0.1:8080/c*********** [GET]

In the integration request of the end point (all is generated by CDK of course) :

Integration type : AWS service
AWS service: S3
Method : Get
path override: *********************************A-Z/descriptors/atlassian-connect.json

template.yaml :

CSCLOCALRESOURCEATLASSIANCONNECTGET831FFFD1:
Type: AWS::ApiGateway::Method
Properties:
HttpMethod: GET
ResourceId:
Ref: CSCLOCALRESOURCEATLASSIANCONNECT0B5E68ED
RestApiId:
Ref: CSCLOCALAPI417A8661
*****
******
***
Integration:
*****
Type: AWS
Uri:
Fn::Join:
- ""
- - "arn:"
- Ref: AWS::Partition
- :apigateway:us-east-1:s3:path/
- Ref: CSCLOCALBUCKETfilebucket1C920510
- /descriptors/atlassian-connect.json

In local I have a directory with asset.**********, in the directory my file atlassian-connect.json. I have also the zipped lambda and calling them seems to work fine.

Thanks in advance.

Kind regards,
Basile GRANDPERRET

@moelasmar moelasmar transferred this issue from aws/serverless-application-model Mar 28, 2021
@moelasmar
Copy link
Contributor

SAM CLI command sam local start-api is only able to locally simulate the calls to API gateway that only integrate with Lambda functions.

@moelasmar moelasmar added stage/pm-review Waiting for review by our Product Manager, please don't work on this yet type/bug type/feature Feature request and removed type/bug labels Mar 28, 2021
@jfuss
Copy link
Contributor

jfuss commented Feb 7, 2023

SAM CLI does not emulate S3. #3265 may be of interest for this.

Closing as this isn't something we support and Plugins would be the way we would in the future.

@jfuss jfuss closed this as completed Feb 7, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2023

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage/pm-review Waiting for review by our Product Manager, please don't work on this yet type/feature Feature request
Projects
None yet
Development

No branches or pull requests

3 participants