localstack / serverless-localstack

⚡ Serverless plugin for running against LocalStack
514 stars 83 forks source link

"sls deploy" not deploying simple serverless app to localstack and no visible errors #148

Closed r-ramaraja closed 9 months ago

r-ramaraja commented 3 years ago

I am learning how to use localstack to test my serverless app.

I started with a simple serverless app created from a template,

serverless create --template aws-nodejs

Here's the handler,

'use strict';

module.exports.hello = async (event) => {
  return {
    statusCode: 200,
    body: JSON.stringify(
      {
        message: 'Go Serverless v1.0! Your function executed successfully!',
        input: event,
      },
      null,
      2
    ),
  };

  // Use this code if you don't use the http event with the LAMBDA-PROXY integration
  // return { message: 'Go Serverless v1.0! Your function executed successfully!', event };
};

Then I installed serverless-localstack,

npm install --save-dev serverless-localstack

I have already installed localstack using pip.

This is my serverless.yml file,

service: localstack-lambda

plugins:
  - serverless-localstack

custom:
  localstack:
    debug: true
    host: http://localhost
    edgePort: 4566
    autostart: true  # optional - Start LocalStack in Docker on Serverless deploy
    docker:
      # Enable this flag to run "docker ..." commands as sudo
      sudo: False

frameworkVersion: '2'

provider:
  name: aws
  runtime: nodejs12.x

functions:
  hello:
    handler: handler.hello

I have not specified any stages like local, if no stages are specified then serverless-localstack by default will deploy to localstack for dev stage(which is the default)

Now, my expectation is that when I do sls deploy it should create the lambda function in localstack. And when I do aws --endpoint-url=http://localhost:4566 lambda list-functions I should see the created function.

However, what actually happens is that it just ends with what seems like no errors but I see no function being created. Here are the sls deploy logs,

─ ~/Documents/Playground/serverless-localstack                                                                                                       1 ✘  took 4s  at 05:12:15 pm ─╮
╰─ sls deploy                                                                                                                                                                          ─╯
Serverless: config.options_stage: undefined
Serverless: serverless.service.custom.stage: undefined
Serverless: serverless.service.provider.stage: dev
Serverless: config.stage: dev
Serverless: Using serverless-localstack
Serverless: Reconfiguring service acm to use http://localhost:4566
Serverless: Reconfiguring service amplify to use http://localhost:4566
Serverless: Reconfiguring service apigateway to use http://localhost:4566
Serverless: Reconfiguring service apigatewayv2 to use http://localhost:4566
Serverless: Reconfiguring service application-autoscaling to use http://localhost:4566
Serverless: Reconfiguring service appsync to use http://localhost:4566
Serverless: Reconfiguring service athena to use http://localhost:4566
Serverless: Reconfiguring service autoscaling to use http://localhost:4566
Serverless: Reconfiguring service batch to use http://localhost:4566
Serverless: Reconfiguring service cloudformation to use http://localhost:4566
Serverless: Reconfiguring service cloudfront to use http://localhost:4566
Serverless: Reconfiguring service cloudsearch to use http://localhost:4566
Serverless: Reconfiguring service cloudtrail to use http://localhost:4566
Serverless: Reconfiguring service cloudwatch to use http://localhost:4566
Serverless: Reconfiguring service cloudwatchlogs to use http://localhost:4566
Serverless: Reconfiguring service codecommit to use http://localhost:4566
Serverless: Reconfiguring service cognito-idp to use http://localhost:4566
Serverless: Reconfiguring service cognito-identity to use http://localhost:4566
Serverless: Reconfiguring service docdb to use http://localhost:4566
Serverless: Reconfiguring service dynamodb to use http://localhost:4566
Serverless: Reconfiguring service dynamodbstreams to use http://localhost:4566
Serverless: Reconfiguring service ec2 to use http://localhost:4566
Serverless: Reconfiguring service ecr to use http://localhost:4566
Serverless: Reconfiguring service ecs to use http://localhost:4566
Serverless: Reconfiguring service eks to use http://localhost:4566
Serverless: Reconfiguring service elasticache to use http://localhost:4566
Serverless: Reconfiguring service elasticbeanstalk to use http://localhost:4566
Serverless: Reconfiguring service elb to use http://localhost:4566
Serverless: Reconfiguring service elbv2 to use http://localhost:4566
Serverless: Reconfiguring service emr to use http://localhost:4566
Serverless: Reconfiguring service es to use http://localhost:4566
Serverless: Reconfiguring service events to use http://localhost:4566
Serverless: Reconfiguring service firehose to use http://localhost:4566
Serverless: Reconfiguring service glacier to use http://localhost:4566
Serverless: Reconfiguring service glue to use http://localhost:4566
Serverless: Reconfiguring service iam to use http://localhost:4566
Serverless: Reconfiguring service iot to use http://localhost:4566
Serverless: Reconfiguring service iotanalytics to use http://localhost:4566
Serverless: Reconfiguring service iotevents to use http://localhost:4566
Serverless: Reconfiguring service iot-data to use http://localhost:4566
Serverless: Reconfiguring service iot-jobs-data to use http://localhost:4566
Serverless: Reconfiguring service kafka to use http://localhost:4566
Serverless: Reconfiguring service kinesis to use http://localhost:4566
Serverless: Reconfiguring service kinesisanalytics to use http://localhost:4566
Serverless: Reconfiguring service kms to use http://localhost:4566
Serverless: Reconfiguring service lambda to use http://localhost:4566
Serverless: Reconfiguring service logs to use http://localhost:4566
Serverless: Reconfiguring service mediastore to use http://localhost:4566
Serverless: Reconfiguring service neptune to use http://localhost:4566
Serverless: Reconfiguring service organizations to use http://localhost:4566
Serverless: Reconfiguring service qldb to use http://localhost:4566
Serverless: Reconfiguring service rds to use http://localhost:4566
Serverless: Reconfiguring service redshift to use http://localhost:4566
Serverless: Reconfiguring service route53 to use http://localhost:4566
Serverless: Reconfiguring service s3 to use http://localhost:4566
Serverless: Reconfiguring service s3control to use http://localhost:4566
Serverless: Reconfiguring service sagemaker to use http://localhost:4566
Serverless: Reconfiguring service sagemaker-runtime to use http://localhost:4566
Serverless: Reconfiguring service secretsmanager to use http://localhost:4566
Serverless: Reconfiguring service ses to use http://localhost:4566
Serverless: Reconfiguring service sns to use http://localhost:4566
Serverless: Reconfiguring service sqs to use http://localhost:4566
Serverless: Reconfiguring service ssm to use http://localhost:4566
Serverless: Reconfiguring service stepfunctions to use http://localhost:4566
Serverless: Reconfiguring service sts to use http://localhost:4566
Serverless: Reconfiguring service timestream to use http://localhost:4566
Serverless: Reconfiguring service transfer to use http://localhost:4566
Serverless: Reconfiguring service xray to use http://localhost:4566
Serverless: Deprecation warning: Resolution of lambda version hashes was improved with better algorithm, which will be used in next major release.
            Switch to it now by setting "provider.lambdaHashingVersion" to "20201221"
            More Info: https://www.serverless.com/framework/docs/deprecations/#LAMBDA_HASHING_VERSION_V2
Serverless: config.options_stage: undefined
Serverless: serverless.service.custom.stage: undefined
Serverless: serverless.service.provider.stage: dev
Serverless: config.stage: dev
Serverless: config.options_stage: undefined
Serverless: serverless.service.custom.stage: undefined
Serverless: serverless.service.provider.stage: dev
Serverless: config.stage: dev
Serverless: Packaging service...
Serverless: Excluding development dependencies...

 Serverless Error ----------------------------------------

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              14.16.1
     Framework Version:         2.44.0
     Plugin Version:            5.2.0
     SDK Version:               4.2.3
     Components Version:        3.11.0

Either there are no errors here or for some reason it's not visible.

Here are the logs form the localstack container,

 ~/Documents/Playground/serverless-localstack                                                                                                                   ✔  at 05:24:45 pm ─╮
╰─ docker logs -f ac9db5ab5627                                                                                                                                                         ─╯
Waiting for all LocalStack services to be ready
2021-06-05 11:36:13,361 CRIT Supervisor is running as root.  Privileges were not dropped because no user is specified in the config file.  If you intend to run as root, you can set user=root in the config file to avoid this message.
2021-06-05 11:36:13,367 INFO supervisord started with pid 15
2021-06-05 11:36:14,372 INFO spawned: 'dashboard' with pid 21
2021-06-05 11:36:14,375 INFO spawned: 'infra' with pid 22
2021-06-05 11:36:14,379 INFO success: dashboard entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2021-06-05 11:36:14,379 INFO exited: dashboard (exit status 0; expected)
(. .venv/bin/activate; exec bin/localstack start --host)
2021-06-05 11:36:15,386 INFO success: infra entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)
Starting local dev environment. CTRL-C to quit.
Waiting for all LocalStack services to be ready

LocalStack version: 0.12.11
LocalStack Docker container id: ac9db5ab5627
LocalStack build date: 2021-06-04
LocalStack build git hash: 4005365d

2021-06-05T11:36:21:DEBUG:bootstrap.py: Loading plugins - scope "services", module "localstack": <function register_localstack_plugins at 0x7f9d5a5af700>
Starting edge router (https port 4566)...
Starting mock ACM service on http port 4566 ...
Starting mock API Gateway service on http port 4566 ...
Starting mock CloudFormation service on http port 4566 ...
Starting mock CloudWatch service on http port 4566 ...
Starting mock DynamoDB service on http port 4566 ...
Starting mock DynamoDB Streams service on http port 4566 ...
Starting mock EC2 service on http port 4566 ...
Starting mock ES service on http port 4566 ...
Starting mock Firehose service on http port 4566 ...
Starting mock IAM service on http port 4566 ...
Starting mock STS service on http port 4566 ...
Starting mock Kinesis service on http port 4566 ...
Starting mock KMS service on http port 4566 ...
2021-06-05T11:36:21:INFO:localstack.multiserver: Starting multi API server process on port 37957
[2021-06-05 11:36:21 +0000] [23] [INFO] Running on http://0.0.0.0:37957 (CTRL + C to quit)
2021-06-05T11:36:21:INFO:hypercorn.error: Running on http://0.0.0.0:37957 (CTRL + C to quit)
[2021-06-05 11:36:21 +0000] [23] [INFO] Running on https://0.0.0.0:4566 (CTRL + C to quit)
2021-06-05T11:36:21:INFO:hypercorn.error: Running on https://0.0.0.0:4566 (CTRL + C to quit)
2021-06-05 11:36:21,958:API:  * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
2021-06-05 11:36:21,959:API:  * Running on http://172.17.0.2:39623/ (Press CTRL+C to quit)
INFO[2021-06-05 11:36:22.641] Local KMS 3.9.1 (4e5eb289efb23f9059ae4b1f9896bad6c9a499f2)
INFO[2021-06-05 11:36:22.679] No file found at path /init/seed.yaml; skipping seeding.
INFO[2021-06-05 11:36:22.679] Data will be stored in /tmp/local-kms
INFO[2021-06-05 11:36:22.679] Local KMS started on 0.0.0.0:42981
Initializing DynamoDB Local with the following configuration:
Port:   48595
InMemory:       true
DbPath: null
SharedDb:       false
shouldDelayTransientStatuses:   false
CorsParams:     *

Starting mock Lambda service on http port 4566 ...
Starting mock CloudWatch Logs service on http port 4566 ...
Starting mock Redshift service on http port 4566 ...
Starting mock Route53 service on http port 4566 ...
Starting mock S3 service on http port 4566 ...
Starting mock Secrets Manager service on http port 4566 ...
Starting mock SES service on http port 4566 ...
Starting mock SNS service on http port 4566 ...
Starting mock SQS service on http port 4566 ...
Starting mock SSM service on http port 4566 ...
Starting mock Cloudwatch Events service on http port 4566 ...
Listening at http://:::37625
Starting mock StepFunctions service on http port 4566 ...
Starting mock SWF service on http port 4566 ...
Starting mock Resource Groups Tagging API service on http port 4566 ...
Starting mock Resource Groups API service on http port 4566 ...
Starting mock Support service on http port 4566 ...
Step Functions Local
Version: 1.7.6
Build: 2021-03-26
2021-06-05 11:36:24.127: Configure [PORT] to [8083]
2021-06-05 11:36:24.143: Configure [Account] to [000000000000]
2021-06-05 11:36:24.144: Configure [Region] to [us-east-1]
2021-06-05 11:36:24.144: Configure [Lambda Endpoint] to [http://localhost:4566]
2021-06-05 11:36:24.145: Configure [Batch Endpoint] to [http://localhost:4566]
2021-06-05 11:36:24.145: Configure [DynamoDB Endpoint] to [http://localhost:4566]
2021-06-05 11:36:24.145: Configure [ECS Endpoint] to [http://localhost:4566]
2021-06-05 11:36:24.146: Configure [Glue Endpoint] to [http://localhost:4566]
2021-06-05 11:36:24.146: Configure [SageMaker Endpoint] to [http://localhost:4566]
2021-06-05 11:36:24.147: Configure [SQS Endpoint] to [http://localhost:4566]
2021-06-05 11:36:24.147: Configure [SNS Endpoint] to [http://localhost:4566]
2021-06-05 11:36:24.148: Configure [Step Functions Endpoint] to [http://localhost:4566]
2021-06-05 11:36:24.148: Configure [Step Functions Athena] to [http://localhost:4566]
2021-06-05 11:36:24.148: Configure [Step Functions EKS] to [http://localhost:4566]
2021-06-05 11:36:24.167: Loaded credentials from environment
2021-06-05 11:36:24.167: Starting server on port 8083 with account 000000000000, region us-east-1
Jun 05, 2021 11:36:25 AM com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory createSocketFactoryRegistry
WARNING: SSL Certificate checking for endpoints has been explicitly disabled.
Waiting for all LocalStack services to be ready
Jun 05, 2021 11:36:25 AM com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory createSocketFactoryRegistry
WARNING: SSL Certificate checking for endpoints has been explicitly disabled.
Jun 05, 2021 11:36:25 AM com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory createSocketFactoryRegistry
WARNING: SSL Certificate checking for endpoints has been explicitly disabled.
Jun 05, 2021 11:36:25 AM com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory createSocketFactoryRegistry
WARNING: SSL Certificate checking for endpoints has been explicitly disabled.
Jun 05, 2021 11:36:25 AM com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory createSocketFactoryRegistry
WARNING: SSL Certificate checking for endpoints has been explicitly disabled.
Jun 05, 2021 11:36:26 AM com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory createSocketFactoryRegistry
WARNING: SSL Certificate checking for endpoints has been explicitly disabled.
Jun 05, 2021 11:36:26 AM com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory createSocketFactoryRegistry
WARNING: SSL Certificate checking for endpoints has been explicitly disabled.
Jun 05, 2021 11:36:26 AM com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory createSocketFactoryRegistry
WARNING: SSL Certificate checking for endpoints has been explicitly disabled.
Jun 05, 2021 11:36:26 AM com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory createSocketFactoryRegistry
WARNING: SSL Certificate checking for endpoints has been explicitly disabled.
Jun 05, 2021 11:36:26 AM com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory createSocketFactoryRegistry
WARNING: SSL Certificate checking for endpoints has been explicitly disabled.
Jun 05, 2021 11:36:26 AM com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory createSocketFactoryRegistry
WARNING: SSL Certificate checking for endpoints has been explicitly disabled.
Jun 05, 2021 11:36:26 AM com.amazonaws.http.apache.client.impl.ApacheConnectionManagerFactory createSocketFactoryRegistry
WARNING: SSL Certificate checking for endpoints has been explicitly disabled.
Jun 05, 2021 11:36:26 AM com.amazonaws.internal.DefaultServiceEndpointBuilder getServiceEndpoint
INFO: {databrew, us-east-1} was not found in region metadata, trying to construct an endpoint using the standard pattern for this region: 'databrew.us-east-1.amazonaws.com'.
Waiting for all LocalStack services to be ready
Ready.
2021-06-05T11:36:34:INFO:localstack.utils.analytics.profiler: Execution of "start_api_services" took 12755.086183547974ms
2021-06-05T11:36:38:INFO:localstack.services.edge: Unable to find forwarding rule for host "localhost:4566", path "POST /", target header "", auth header "AWS4-HMAC-SHA256 Credential= /20210605/us-east-1/cloudformation/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-security-token, Signature=e87dd28034bc2d712b371bb962b65b364e7549bb05c082476a0f16416d42ba1c", data "b'Action=DescribeStacks&StackName=localstack-lambda-dev&Version=2010-05-15'"
2021-06-05T11:37:02:INFO:localstack.services.edge: Unable to find forwarding rule for host "localhost:4566", path "POST /", target header "", auth header "AWS4-HMAC-SHA256 Credential= /20210605/us-east-1/cloudformation/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-security-token, Signature=bb561b6d3ad75430d504c1d69501427b0e47549e68233f2c12daa0024a75003e", data "b'Action=DescribeStacks&StackName=localstack-lambda-dev&Version=2010-05-15'"

As you can see the localstack container logs have an interesting error?

2021-06-05T11:36:38:INFO:localstack.services.edge: Unable to find forwarding rule for host "localhost:4566", path "POST /", target header "", auth header "AWS4-HMAC-SHA256 Credential= /20210605/us-east-1/cloudformation/aws4_request, SignedHeaders=host;x-amz-content-sha256;x-amz-date;x-amz-security-token, Signature=e87dd28034bc2d712b371bb962b65b364e7549bb05c082476a0f16416d42ba1c", data "b'Action=DescribeStacks&StackName=localstack-lambda-dev&Version=2010-05-15'"

I see a mention of cloudformation but I can verify that it's running. I checked http://localhost:4566/health and got,

{"services": {"apigateway": "running", "cloudformation": "running", "cloudwatch": "running", "dynamodb": "running", "dynamodbstreams": "running", "ec2": "running", "es": "running", "firehose": "running", "iam": "running", "sts": "running", "kinesis": "running", "kms": "running", "lambda": "running", "logs": "running", "redshift": "running", "route53": "running", "s3": "running", "secretsmanager": "running", "ses": "running", "sns": "running", "sqs": "running", "ssm": "running", "events": "running", "stepfunctions": "running", "swf": "running", "resourcegroupstaggingapi": "running", "resource-groups": "running", "support": "running", "acm": "running"}, "features": {"persistence": "disabled", "initScripts": "initialized"}}

I need help in figuring why the lambda function is not created as expected

steffyP commented 9 months ago

Hi @r-ramaraja,

apologies that your issue got lost in the backlog! We are closing the ticket due to inactivity, also assuming the issue was fixed in the meantime. If you still have any issues with the latest localstack version, please reach out!