We encountered a problem after following your example, the yml file from your Github → localstack-demo
We used your example, only change - we defined our own functions in the yml, but we always had the error described in the title. We even tried an experimental function called heakthcheck to check for intactness, and it still doesn’t work
The error occurs when we run the path we received after the deployment : http://localhost:4566/restapis/b6p2p3ekmg/local/_user_request_, and we run inside postman (tried Get and Post requests) with the following link
(same path as after deployment)…/local/requests → matched to the path of our function.
Our yml file , based on your localstack-demo :
service: test
provider:
name: aws
runtime: python3.8
region: us-east-1
stage: ${opt:stage,‘local’}
stackName: backend4
deploymentBucket:
name: ${self:custom.deploymentBucket.${self:provider.stage}}
iam:
role:
statements:
- Effect: Allow
Action:
- s3:*
Resource: !Sub “arn:aws:s3:::${self:custom.archiveBucket.${self:provider.stage}}/*”
custom:
region: us-east-1
accountID: “000000000000”
localstack:
stages: [local]
host: http://127.0.0.1
debug: true
# Note: enable this configuration to automatically start up a LocalStack container in the background
autostart: true
lambda:
mountCode: true
deploymentBucket:
local: localstack-test-bucket
aws: localstack-test-bucket-53194
archiveBucket:
local: archive-bucket
aws: localstack-demo-archive-bucket-53194
syncS3:
- bucketName: ${self:custom.archiveBucket.${self:provider.stage}}
localDir: backend
package:
excludeDevDependencies: true
exclude:
- ./**
- “!backend/"
- "!node_modules/uuid/”
plugins:
- serverless-localstack
- serverless-plugin-common-excludes
- serverless-plugin-include-dependencies
- serverless-deployment-bucket
- serverless-sync-s3
resources:
Resources:
archiveBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:custom.archiveBucket.${self:provider.stage}}
functions:
healthcheck:
handler: backend/main.healthcheck
events:
- http:
path: /requests
method: post
cors: true
- http:
path: /requests
method: get
cors: true
timeout: 120
And it’s the healthcheck function inside the backend/main.healthcheck path:
def healthcheck():
return {
“statusCode”: 200,
“body”: “test”
}
We would appreciate a quick reply, thanks a lot, Andrey