serverless-localstack
serverless-localstack copied to clipboard
Getting error while deploy serverless stack
I am following serverless-localstack example to test my server-less app.
serverless.yml
service:
name: aws-node-typescript-sqs-standard
plugins:
- serverless-webpack
- serverless-localstack
custom:
localstack:
stages:
# list of stages for which the plugin should be enabled
- local
host: http://localhost # optional - LocalStack host to connect to
edgePort: 4566 # optional - LocalStack edge port to connect to
autostart: true # optional - Start LocalStack in Docker on Serverless deploy
lambda:
# Enable this flag to improve performance
mountCode: True
docker:
# Enable this
provider:
name: aws
runtime: nodejs12.x
region: us-east-1
deploymentBucket:
name: test-node-typescript-bucket
serverSideEncryption: AES256
# role: DefaultLambdaRole
iam:
role: arn:aws:iam::000000000000:policy/aws-node-typescript-sqs-standard-local-us-east-1-lambdaRole
deploymentRole: arn:aws:iam::000000000000:policy/aws-node-typescript-sqs-standard-local-us-east-1-lambdaRole
functions:
sender:
handler: handler.sender
events:
- http:
method: post
path: sender
receiver:
handler: handler.receiver
events:
- sqs:
arn:
Fn::GetAtt:
- receiverQueue
- Arn
resources:
Resources:
receiverQueue:
Type: AWS::SQS::Queue
Properties:
QueueName: receiverQueue
###Error while executing: SLS_DEBUG=* sls deploy --stage local
ServerlessError: An error occurred: aws-node-typescript-sqs-standard-local - undefined.
at /home/pravin/.nvm/versions/node/v12.16.3/lib/node_modules/serverless/lib/plugins/aws/lib/monitorStack.js:94:23
at processTicksAndRejections (internal/process/task_queues.js:97:5)
###Localstack logs
2021-05-04T14:54:41:WARNING:localstack.utils.cloudformation.template_deployer: Error calling <bound method ClientCreator._create_api_method.<locals>._api_call of <botocore.client.Lambda object at 0x7f96ca8e23d0>> with params: {'FunctionName': 'aws-node-typescript-sqs-standard-local-sender', 'Runtime': 'nodejs12.x', 'Role': 'arn:aws:iam::000000000000:policy/aws-node-typescript-sqs-standard-local-us-east-1-lambdaRole', 'Handler': 'handler.sender', 'Code': {'S3Bucket': '__local__', 'S3Key': '/mnt/e/project/codebase/serverless-examples/aws-node-typescript-sqs-standard'}, 'Timeout': 6, 'MemorySize': 1024} for resource: {'Type': 'AWS::Lambda::Function', 'Properties': {'Code': {'S3Bucket': '__local__', 'S3Key': '/mnt/e/project/codebase/serverless-examples/aws-node-typescript-sqs-standard'}, 'Handler': 'handler.sender', 'Runtime': 'nodejs12.x', 'FunctionName': 'aws-node-typescript-sqs-standard-local-sender', 'MemorySize': 1024, 'Timeout': 6, 'Role': 'arn:aws:iam::000000000000:policy/aws-node-typescript-sqs-standard-local-us-east-1-lambdaRole'}, 'DependsOn': ['SenderLogGroup'], 'LogicalResourceId': 'SenderLambdaFunction', 'PhysicalResourceId': None, '_state_': {}}
Here's what I would try:
- Remove resources in serverless.yml and create your queue using the command line
- Use a .env config to inject the arn for your queue in sender/receiver
If cloudformation fails, just work around it. It's supposed to help manage your resources. But if it fails to do so, just manage the resources yourself or in a different way.
Here's my sqs trigger handler:
sqs: {
handler: 'handler.sqs',
events: [{
sqs: {
arn: 'arn:aws:sqs:ddblocal:000000000000:myproject-dev',
}
}]
}
@pravin-raha did you manage to resolve that error?
Nope, but it did worked with older localstack build localstack:0.12.3
The same issue with localstack:0.12.3
@kherkeladze, I have managed to resolve that with localstack:0.12.3. There can be bad YAML identation. localstack Docker container logs are more verbose with that issue.
I hit this same error and resolved it by setting LAMBDA_REMOTE_DOCKER=false. Image 0.12.3 spit out an error indicating that it was required, and applying that against latest resolved it for me.
I was having the same problem and search for a good answer and found 1. The name of the service was too long and deleted some characters and it worked. Not sure why localstack doesnt accept long service names but for now it work.
same with localstack:1.2.0 😕
It worked once, I stopped the service and this error popped up.
service: my-app
frameworkVersion: '2 || 3'
plugins:
- serverless-python-requirements
- serverless-localstack
custom:
localstack:
stages:
# list of stages for which the plugin should be enabled
- local
host: http://localhost # optional - LocalStack host to connect to
edgePort: 4566 # optional - LocalStack edge port to connect to
autostart: true # optional - Start LocalStack in Docker on Serverless deploy
networks: #optional - attaches the list of networks to the localstack docker container after startup
- host
- overlay
- localstack-net
lambda:
# Enable this flag to improve performance
mountCode: false # specify either "true", or a relative path to the root Lambda mount path
docker:
# Enable this flag to run "docker ..." commands as sudo
sudo: False
pythonRequirements:
fileName: requirements.txt
dockerizePip: false
provider:
name: aws
runtime: python3.8
lambdaHashingVersion: '20201221'
functions:
get-user:
handler: handler.get_user
events:
- http:
path: /users/{user_id}
method: get
create-user:
handler: handler.create_user
events:
- http:
path: /users
method: post
package:
exclude:
- './**'
include:
- './handler.py'
resources:
Resources:
UsersTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: userId
AttributeType: S
KeySchema:
- AttributeName: userId
KeyType: HASH
ProvisionedThroughput:
ReadCapacityUnits: 1
WriteCapacityUnits: 1
TableName: Users
Hi @omersi,
apologizes for the late reply! Do you still get an error with the latest localstack version?
This issue seems to be stale. As we didn't get any response in two months, we are closing this issue now. Please feel free to reopen if it still persists, and provide updates logs and details.