localstack / aws-cdk-local

Thin wrapper script for using the AWS CDK CLI with LocalStack
Apache License 2.0
267 stars 17 forks source link

LOC-28 ⁃ Unable to deploy onto localstack (but ok on AWS) #11

Closed sync-by-unito[bot] closed 3 years ago

sync-by-unito[bot] commented 3 years ago

Hi,

Trying to deploy onto localstack but getting this exception from serverless, it is kind of weird since the same stack works properly when running sls deploy on AWS.

Localstack: 0.11.4 serverless: 1.81.1 serverless-localstack: 0.4.27

Below is the serverless.yml:

service:
  name: 'jizo-accts'

frameworkVersion:  '>=1.72.0'

plugins:
  - serverless-webpack  
  - serverless-dynamodb-local
  - serverless-offline-sqs
  - serverless-offline  
  - serverless-localstack

custom:
  webpack:
    webpackConfig: './webpack.config.js'
    includeModules: true
  serverless-offline-sqs:
    autoCreate: false
    apiVersion: '2012-11-05'
    endpoint: http://0.0.0.0:4576
    region: us-east-1
    accessKeyId: root
    secretAccessKey: root
    skipCacheInvalidation: false    
  serverless-offline:
    stage:
      -local
    lambdaPort: 4574
  dynamodb:
    stages:
      - local      
    start:
      port: 4569
      inMemory: true
      heapInitial: 128m
      heapMax: 1g
      migrate: true
  localstack:
    docker:
      sudo: false
    debug: true
    endpoints:
      S3: http://localhost:4572
      DynamoDB: http://localhost:4569
      CloudFormation: http://localhost:4581
      Elasticsearch: http://localhost:4571
      ES: http://localhost:4578
      SNS: http://localhost:4575
      SQS: http://localhost:4576
      Lambda: http://localhost:4574
      Kinesis: http://localhost:4568
    host: "http://localhost"
    lambda:
      mountCode: false
    stages:
      - dev

provider:
  name: 'aws'
  apiGateway: 
    minimumCompressionSize: 1024
  environment:
    AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1'
    ML_EXT_LOOPBACK: 'NO'
    ML_EXT_DEBUG: 'YES'
    ML_EXT_SYSENV: ${opt:stage}
    ML_CLOUD_REGION: ${opt:region}       
  runtime: 'nodejs12.x'
  iamRoleStatements:
    - Effect: 'Allow'
      Action:
        - 'sqs:ReceiveMessage'
        - 'sqs:DeleteMessage'
      Resource:
        - "arn:aws:sqs:::${self:service}-${opt:stage}-RescopeQueue"
        - "arn:aws:sqs:::${self:service}-${opt:stage}-UncopeQueue"
    - Effect: 'Allow'
      Action:
        - 'sqs:SendMessage'
      Resource: '*'
    - Effect: 'Allow'
      Action:
        - 'dynamodb:DeleteItem'
        - 'dynamodb:PutItem'
        - 'dynamodb:Query'
        - 'dynamodb:Scan'
      Resource:
        - "arn:aws:dynamodb:::jizo.${opt:stage}.accountsTable"
        - "arn:aws:dynamodb:::jizo.${opt:stage}.identitiesTable"
        - "arn:aws:dynamodb:::jizo.${opt:stage}.acctsAuditTrialTable"
        - "arn:aws:dynamodb:::jizo.${opt:stage}.usersTable"
    - Effect: 'Allow'
      Action: 
        - 's3:GetObject'
      Resource:
        - "arn:aws:s3:::${self:service}.${opt:stage}.identity"
    - Effect: 'Allow'
      Action:
        - 'sns:Public'
      Resource:
        - "arn:aws:sns:::${self:service}-${opt:stage}-registerAccount"
        - "arn:aws:sns:::${self:service}-${opt:stage}-unregisterAccount"
    - Effect: 'Allow'
      Action:
        - 'sns:Subscribe'
      Resource: '*'       

functions:
  rescope:
    handler: src/sqs.rescope
    description: "To handle rescoping account via the invoicing service"
    events:
      - sqs:
          arn: 
            Fn::GetAtt:
              - RescopeQueue
              - Arn            
  unscope:
    handler: src/sqs.unscope
    description: "To handle unscoping account via the invoicing service"
    events:
      - sqs:
          arn: 
            Fn::GetAtt:
              - UnscopeQueue
              - Arn            
  userGet:
    handler: src/lambda.userGet    
    description: 'provide sync call to get user data'
  identify: 
    handler: src/s3.identify
    description: "Trigger identity creation and validation when receiving files upload to bucket"
    events:
      - s3:
        bucket: "${self:service}.${opt:stage}.identity"
        event: s3:ObjectCreate:*          
  router:
    handler: src/http.router
    description: 'primary REST related handlers for this service'
    events:
      - http: 'GET {proxy+}'
      - http: 'POST {proxy+}'
      - http: 'PATCH {proxy+}'
      - http: 'PUT {proxy+}'
      - http: 'DELETE {proxy+}'
      - http: 'OPTIONS {proxy+}'
      - http: 'HEAD {proxy+}'

resources:
  Resources:
    # s3 configuration
    identityBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: "${self:service}.${opt:stage}.identity"

    # dynamodb configuration
    accountsTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: "jizo.${opt:stage}.accountsTable"
        AttributeDefinitions:
          - AttributeName: object_id
            AttributeType: S
        KeySchema:
          - AttributeName: object_id
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
    identitiesTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: "jizo.${opt:stage}.identitiesTable"
        AttributeDefinitions:
          - AttributeName: object_id
            AttributeType: S
        KeySchema:
          - AttributeName: object_id
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1
    acctTrailTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: "jizo.${opt:stage}.acctsAuditTrialTable"
        AttributeDefinitions:
          - AttributeName: object_id
            AttributeType: S
        KeySchema:
          - AttributeName: object_id
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1        
    usersTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: "jizo.${opt:stage}.usersTable"
        AttributeDefinitions:
          - AttributeName: object_id
            AttributeType: S
        KeySchema:
          - AttributeName: object_id
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: 1
          WriteCapacityUnits: 1

    # incoming SQS configuration      
    RescopeQueue:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: "${self:service}-${opt:stage}-RescopeQueue"
        VisibilityTimeout: 1080
        MessageRetentionPeriod: 2160
        RedrivePolicy:
          deadLetterTargetArn: 
            Fn::GetAtt:
              - RescopeBackupQueue
              - Arn
          maxReceiveCount: 3
    RescopeBackupQueue:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: "${self:service}-${opt:stage}-RescopeBackupQueue"
    UnscopeQueue:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: "${self:service}-${opt:stage}-UnscopeQueue"
        VisibilityTimeout: 1080
        MessageRetentionPeriod: 2160
        RedrivePolicy:
          deadLetterTargetArn: 
            Fn::GetAtt:
              - UnscopeBackupQueue
              - Arn
          maxReceiveCount: 3
    UnscopeBackupQueue:
      Type: AWS::SQS::Queue
      Properties:
        QueueName: "${self:service}-${opt:stage}-UnscopeBackupQueue"

    # SNS Definitions
    registerAccountTopic:
      Type: AWS::SNS::Topic
      Properties:
        TopicName: "${self:service}-${opt:stage}-registerAccount"

    unregisterAccountTopic:
      Type: AWS::SNS::Topic
      Properties:
        TopicName: "${self:service}-${opt:stage}-unregisterAccount"

The setup for localstack is as follow:

version: '2.1'
services:
  localstack:
    container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main}"
    image: localstack/localstack:latest
    ports:
      - "4000-4597:4000-4597"
    environment:
      - SERVICES=${SERVICES- }
      # - SERVICES=sts,iam,cloudformation,s3,lambda,sqs,sns,ses,dynamodb,apigateway
      - DEBUG=1
      - DEFAULT_REGION=ap-southeast-1
      - DATA_DIR=${DATA_DIR- }
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR- docker-reuse}
      - KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY- }
      - DOCKER_HOST=unix:///var/run/docker.sock
      - HOST_TMP_FOLDER=${TMPDIR}
      - AWS_EXECUTION_ENV=true
    volumes:
      - "/tmp/localstack:/tmp/localstack"
      - "/var/run/docker.sock:/var/run/docker.sock"

The output from serverless was like this...

Serverless: config.options_stage: dev
Serverless: serverless.service.custom.stage: undefined
Serverless: serverless.service.provider.stage: dev
Serverless: config.stage: dev
Serverless: Using serverless-localstack
Serverless: Reconfiguring service apigateway to use http://localhost:4566
Serverless: Reconfiguring service cloudformation to use http://localhost:4566
Serverless: Reconfiguring service cloudwatch to use http://localhost:4566
Serverless: Reconfiguring service lambda to use http://localhost:4566
Serverless: Reconfiguring service dynamodb to use http://localhost:4566
Serverless: Reconfiguring service kinesis to use http://localhost:4566
Serverless: Reconfiguring service route53 to use http://localhost:4566
Serverless: Reconfiguring service firehose to use http://localhost:4566
Serverless: Reconfiguring service stepfunctions to use http://localhost:4566
Serverless: Reconfiguring service es to use http://localhost:4566
Serverless: Reconfiguring service s3 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 sts to use http://localhost:4566
Serverless: Reconfiguring service iam to use http://localhost:4566
Serverless: Reconfiguring service ssm to use http://localhost:4566
Serverless: Reconfiguring service rds to use http://localhost:4566
Serverless: Reconfiguring service ec2 to use http://localhost:4566
Serverless: Reconfiguring service elasticache to use http://localhost:4566
Serverless: Reconfiguring service kms to use http://localhost:4566
Serverless: Reconfiguring service secretsmanager to use http://localhost:4566
Serverless: Reconfiguring service logs to use http://localhost:4566
Serverless: Reconfiguring service cloudwatchlogs to use http://localhost:4566
Serverless: Reconfiguring service iot 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 ecs to use http://localhost:4566
Serverless: Reconfiguring service eks to use http://localhost:4566
Serverless: Reconfiguring service xray to use http://localhost:4566
Serverless: Reconfiguring service appsync to use http://localhost:4566
Serverless: Reconfiguring service cloudfront to use http://localhost:4566
Serverless: Reconfiguring service athena to use http://localhost:4566
Serverless: Reconfiguring service S3 to use http://localhost:4572
Serverless: Reconfiguring service DynamoDB to use http://localhost:4569
Serverless: Reconfiguring service CloudFormation to use http://localhost:4581
Serverless: Reconfiguring service Elasticsearch to use http://localhost:4571
Serverless: Reconfiguring service ES to use http://localhost:4578
Serverless: Reconfiguring service SNS to use http://localhost:4575
Serverless: Reconfiguring service SQS to use http://localhost:4576
Serverless: Reconfiguring service Lambda to use http://localhost:4574
Serverless: Reconfiguring service Kinesis to use http://localhost:4568
Serverless: Warning: Unable to find plugin named: TypeScriptPlugin
Serverless: Configuration warning:
Serverless:   at 'functions.identify.events[0]': unrecognized property 'bucket'
Serverless:   at 'functions.identify.events[0]': unrecognized property 'event'
Serverless:  
Serverless: If you prefer to not continue ensure "configValidationMode: error" in your config
Serverless: If errors are influenced by an external plugin, enquiry at plugin repository so schema extensions are added (https://www.serverless.com/framework/docs/providers/aws/guide/plugins#extending-validation-schema)
Serverless: If errors seem invalid, please report at https://github.com/serverless/serverless/issues/new?template=bug_report.md
Serverless: If you find this functionality problematic, you may turn it off with "configValidationMode: off" setting
Serverless:  
Serverless: config.options_stage: dev
Serverless: serverless.service.custom.stage: undefined
Serverless: serverless.service.provider.stage: dev
Serverless: config.stage: dev
Serverless: config.options_stage: dev
Serverless: serverless.service.custom.stage: undefined
Serverless: serverless.service.provider.stage: dev
Serverless: config.stage: dev
Serverless: Bundling with Webpack...
Time: 1056ms
Built at: 09/04/2020 01:11:16
            Asset      Size  Chunks                   Chunk Names
      src/http.js  19.6 KiB       0  [emitted]        src/http
  src/http.js.map  80.2 KiB       0  [emitted] [dev]  src/http
    src/lambda.js  13.8 KiB       1  [emitted]        src/lambda
src/lambda.js.map  47.4 KiB       1  [emitted] [dev]  src/lambda
        src/s3.js  8.87 KiB       2  [emitted]        src/s3
    src/s3.js.map  41.9 KiB       2  [emitted] [dev]  src/s3
       src/sqs.js  13.8 KiB       3  [emitted]        src/sqs
   src/sqs.js.map    48 KiB       3  [emitted] [dev]  src/sqs
Entrypoint src/sqs = src/sqs.js src/sqs.js.map
Entrypoint src/lambda = src/lambda.js src/lambda.js.map
Entrypoint src/s3 = src/s3.js src/s3.js.map
Entrypoint src/http = src/http.js src/http.js.map
 [0] external "@leungas/aws-orm" 42 bytes {0} {1} {2} {3} [built]
 [1] external "@leungas/lambda" 42 bytes {0} {1} {3} [built]
 [2] ./src/index.ts + 11 modules 13.5 KiB {0} {1} {2} {3} [built]
     | ./src/index.ts 55 bytes [built]
     | ./src/models/index.ts 151 bytes [built]
     | ./src/factories/index.ts 71 bytes [built]
     | ./src/models/user.ts 3 KiB [built]
     | ./src/models/account.ts 4.03 KiB [built]
     | ./src/models/account.owner.ts 474 bytes [built]
     | ./src/models/identity.ts 935 bytes [built]
     | ./src/models/identity.individual.ts 2.2 KiB [built]
     | ./src/factories/account.factory.ts 485 bytes [built]
     | ./src/factories/identity.factory.ts 1.78 KiB [built]
     | ./src/exceptions/serial.invalid-location.ts 168 bytes [built]
     | ./src/exceptions/serial.invalid-format.ts 181 bytes [built]
 [3] ./src/configuration/infrastructure/queues/dev.json 313 bytes {0} {1} {3} [built]
 [7] ./src/configuration/index.ts 125 bytes {0} {1} {3} [built]
 [8] ./src/configuration/dev.ts 579 bytes {0} {1} {3} [built]
 [9] ./src/configuration/prod.ts 581 bytes {0} {1} {3} [built]
[12] ./src/configuration/local.ts 578 bytes {0} {1} {3} [built]
[13] ./src/middlewares/exception.handler.ts 1.15 KiB {0} {1} [built]
[14] external "aws-sdk" 42 bytes {2} [built]
[15] external "lambda-api" 42 bytes {0} [built]
[16] ./src/http.ts + 17 modules 15.6 KiB {0} [built]
     | ./src/http.ts 3.03 KiB [built]
     | ./src/middlewares/application.loader.ts 288 bytes [built]
     | ./src/controllers/http/account.create.ts 2.16 KiB [built]
     | ./src/middlewares/account.admin.ts 652 bytes [built]
     | ./src/controllers/http/account.delete.ts 859 bytes [built]
     | ./src/controllers/http/account.disable.ts 768 bytes [built]
     | ./src/controllers/http/account.enable.ts 895 bytes [built]
     | ./src/controllers/http/account.settings.get.ts 540 bytes [built]
     | ./src/controllers/http/account.settings.set.ts 623 bytes [built]
     | ./src/controllers/http/user.create.ts 638 bytes [built]
     | ./src/controllers/http/user.delete.ts 656 bytes [built]
     | ./src/controllers/http/user.disable.ts 1.29 KiB [built]
     | ./src/controllers/http/user.enable.ts 1.25 KiB [built]
     | ./src/controllers/http/user.preference.get.ts 468 bytes [built]
     | ./src/controllers/http/user.preference.set.ts 594 bytes [built]
     |     + 3 hidden modules
[17] ./src/sqs.ts + 2 modules 2.55 KiB {3} [built]
     | ./src/sqs.ts 250 bytes [built]
     | ./src/controllers/sqs/account.rescope.ts 1.15 KiB [built]
     | ./src/controllers/sqs/account.unscope.ts 1.15 KiB [built]
[18] ./src/s3.ts + 2 modules 2.4 KiB {2} [built]
     | ./src/s3.ts 128 bytes [built]
     | ./src/controllers/s3/account.identify.ts 2.1 KiB [built]
     | ./src/exceptions/document.bad-cogn.ts 161 bytes [built]
[19] ./src/lambda.ts + 1 modules 1.32 KiB {1} [built]
     | ./src/lambda.ts 107 bytes [built]
     | ./src/controllers/lambda/user.get.ts 1.2 KiB [built]
    + 5 hidden modules
Serverless: WARNING: Could not determine version of module lambda-api
Serverless: WARNING: Could not determine version of module aws-sdk
Serverless: Package lock found - Using locked versions
Serverless: Packing external modules: @leungas/aws-orm@git+https://djonno-admin:y68Yry7zH72NMNFYrvPy@bitbucket.org/djonno-backend/jizoo-core.git, @leungas/lambda@git+https://djonno-admin:y68Yry7zH72NMNFYrvPy@bitbucket.org/djonno-backend/lambda-support.git, lambda-api, aws-sdk
Serverless: WARNING: Could not determine version of module lambda-api
Serverless: WARNING: Could not determine version of module aws-sdk
Serverless: Packaging service...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
.
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service jizo-accts.zip file to S3 (27.96 MB)...
Serverless: Validating template...
Serverless: Skipping template validation: Unsupported in Localstack
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
.
Serverless: Stack update finished...

  Type Error ---------------------------------------------

  TypeError: message.startsWith is not a function
      at /Users/leungas/.nvm/versions/node/v12.18.2/lib/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:506:23
      at processTicksAndRejections (internal/process/task_queues.js:97:5)

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

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

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              12.18.2
     Framework Version:         1.81.1
     Plugin Version:            3.8.2
     SDK Version:               2.3.1
     Components Version:        2.34.9

The error returned at localstack was started with this:

{code} localstack_main | 2020-09-03T17:13:48:ERROR:localstack.services.cloudformation.cloudformation_starter: Unable to parse and create resource "UserGetLambdaVersionPqf01E84DnieuGEURTZ1hUcOiB4rTEKYaCX8RpZiBYs": 'FunctionName' Traceback (most recent call last): localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 268, in parse_and_create_resource localstack_main | return _parse_and_create_resource( localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 340, in _parse_and_create_resource localstack_main | raise moto_create_error localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 322, in _parse_and_create_resource localstack_main | resource = parse_and_create_resource_orig( localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/cloudformation/parsing.py", line 297, in parse_and_create_resource localstack_main | resource = resource_class.create_from_cloudformation_json( localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/awslambda/models.py", line 709, in create_from_cloudformation_json localstack_main | function_name = properties["FunctionName"] localstack_main | KeyError: 'FunctionName' localstack_main | localstack_main | 2020-09-03T17:13:48:DEBUG:localstack.services.cloudformation.cloudformation_listener: Error response for CloudFormation action "DescribeStackResource" (500) POST /: b'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n500 Internal Server Error\n

Internal Server Error

\n

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

\n' localstack_main | 2020-09-03T17:13:48:WARNING:localstack.utils.cloudformation.template_deployer: Unable to get details for resource "ApiGatewayRestApi" in CloudFormation stack "jizo-accts-dev": Unable to parse response (syntax error: line 1, column 54), invalid XML received. Further retries may succeed: localstack_main | b'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n500 Internal Server Error\n

Internal Server Error

\n

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

\n' localstack_main | 2020-09-03T17:13:48:ERROR:localstack.services.cloudformation.cloudformation_starter: Unable to parse and create resource "ApiGatewayResourceProxyVar": None Traceback (most recent call last): localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 268, in parse_and_create_resource localstack_main | return _parse_and_create_resource( localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 404, in _parse_and_create_resource localstack_main | update_resource_id( localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 469, in update_resource_id localstack_main | backend.apis[api_id].resources.pop(resource.id, None) localstack_main | KeyError: None localstack_main | localstack_main | 2020-09-03T17:13:48:ERROR:localstack.services.cloudformation.cloudformation_starter: Unable to parse and create resource "ApiGatewayMethodProxyVarGet": None Traceback (most recent call last): localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 268, in parse_and_create_resource localstack_main | return _parse_and_create_resource( localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 297, in _parse_and_create_resource localstack_main | resource_tuple = parsing.parse_resource(logical_id, resource_json, resources_map) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/cloudformation/parsing.py", line 267, in parse_resource localstack_main | resource_json = clean_json(resource_json, resources_map) localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 245, in clean_json localstack_main | result = clean_json_orig(resource_json, resources_map) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/cloudformation/parsing.py", line 200, in clean_json localstack_main | cleaned_val = clean_json(value, resources_map) localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 245, in clean_json localstack_main | result = clean_json_orig(resource_json, resources_map) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/cloudformation/parsing.py", line 200, in clean_json localstack_main | cleaned_val = clean_json(value, resources_map) localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 245, in clean_json localstack_main | result = clean_json_orig(resource_json, resources_map) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/cloudformation/parsing.py", line 93, in clean_json localstack_main | resource = resources_map[resource_json["Ref"]] localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/cloudformation/parsing.py", line 424, in getitem localstack_main | new_resource = parse_and_create_resource( localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 268, in parse_and_create_resource localstack_main | return _parse_and_create_resource( localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 404, in _parse_and_create_resource localstack_main | update_resource_id( localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 469, in update_resource_id localstack_main | backend.apis[api_id].resources.pop(resource.id, None) localstack_main | KeyError: None localstack_main | localstack_main | 2020-09-03 17:13:48,955:API: Error on request: localstack_main | Traceback (most recent call last): localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 323, in run_wsgi localstack_main | execute(self.server.app) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 312, in execute localstack_main | application_iter = app(environ, start_response) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/server.py", line 167, in call localstack_main | return backend_app(environ, start_response) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2464, in call localstack_main | return self.wsgi_app(environ, start_response) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app localstack_main | response = self.handle_exception(e) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function localstack_main | return cors_after_request(app.make_response(f(_args, _kwargs))) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception localstack_main | reraise(exc_type, exc_value, tb) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise localstack_main | raise value localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app localstack_main | response = self.full_dispatch_request() localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request localstack_main | rv = self.handle_user_exception(e) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function localstack_main | return cors_after_request(app.make_response(f(_args, _kwargs))) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception localstack_main | reraise(exc_type, exc_value, tb) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise localstack_main | raise value localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request localstack_main | rv = self.dispatch_request() localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request localstack_main | return self.view_functionsrule.endpoint localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/core/utils.py", line 146, in call localstack_main | result = self.callback(request, request.url, {}) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/core/responses.py", line 202, in dispatch localstack_main | return cls()._dispatch(_args, _kwargs) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/core/responses.py", line 312, in _dispatch localstack_main | return self.call_action() localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/core/responses.py", line 397, in call_action localstack_main | response = method() localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 886, in describe_stack_resource localstack_main | for stack_resource in stack.stack_resources: localstack_main | File "/usr/lib/python3.8/_collectionsabc.py", line 762, in _iter__ localstack_main | yield self._mapping[key] localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/cloudformation/parsing.py", line 424, in getitem localstack_main | new_resource = parse_and_create_resource( localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 268, in parse_and_create_resource localstack_main | return _parse_and_create_resource( localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 340, in _parse_and_create_resource localstack_main | raise moto_create_error localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 322, in _parse_and_create_resource localstack_main | resource = parse_and_create_resource_orig( localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/cloudformation/parsing.py", line 297, in parse_and_create_resource localstack_main | resource = resource_class.create_from_cloudformation_json( localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/awslambda/models.py", line 709, in create_from_cloudformation_json localstack_main | function_name = properties["FunctionName"] localstack_main | KeyError: 'FunctionName' localstack_main | 2020-09-03T17:13:48:DEBUG:localstack.services.cloudformation.cloudformation_listener: Error response for CloudFormation action "UpdateStack" (500) POST /: b'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">\n500 Internal Server Error\n

Internal Server Error

\n

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

\n' localstack_main | 2020-09-03 17:13:48,979:API: Error on request: localstack_main | Traceback (most recent call last): localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 323, in run_wsgi localstack_main | execute(self.server.app) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/werkzeug/serving.py", line 312, in execute localstack_main | application_iter = app(environ, start_response) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/server.py", line 167, in call localstack_main | return backend_app(environ, start_response) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2464, in call localstack_main | return self.wsgi_app(environ, start_response) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app localstack_main | response = self.handle_exception(e) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function localstack_main | return cors_after_request(app.make_response(f(_args,
_kwargs))) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception localstack_main | reraise(exc_type, exc_value, tb) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise localstack_main | raise value localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app localstack_main | response = self.full_dispatch_request() localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_d

┆Issue is synchronized with this Jira Task by Unito

sync-by-unito[bot] commented 3 years ago

➤ Mohit Alonja commented:

leungas Thank you for reporting this issue, Can you please give it a try with a latest release or latest docker image? We have tried to reproduce it (using events also), but we are not able to. Also, recently our upstream package spulec/moto ( https://github.com/spulec/moto/commit/49d92861c0acaa006052a7a94355a5870cdc92d5#diff-9497eee72b94d2373afce2e63017ec39 )(commit) has done singificant cloudformation refactoring. This might have solved this issue already. Thanks.

sync-by-unito[bot] commented 3 years ago

➤ Danilo Pereira commented:

Similar issues happening here.

Serverless: Load command interactiveCli Serverless: Load command config Serverless: Load command config:credentials Serverless: Load command config:tabcompletion Serverless: Load command config:tabcompletion:install Serverless: Load command config:tabcompletion:uninstall Serverless: Load command create Serverless: Load command install Serverless: Load command package Serverless: Load command deploy Serverless: Load command deploy:function Serverless: Load command deploy:list Serverless: Load command deploy:list:functions Serverless: Load command invoke Serverless: Load command invoke:local Serverless: Load command info Serverless: Load command logs Serverless: Load command metrics Serverless: Load command print Serverless: Load command remove Serverless: Load command rollback Serverless: Load command rollback:function Serverless: Load command slstats Serverless: Load command plugin Serverless: Load command plugin Serverless: Load command plugin:install Serverless: Load command plugin Serverless: Load command plugin:uninstall Serverless: Load command plugin Serverless: Load command plugin:list Serverless: Load command plugin Serverless: Load command plugin:search Serverless: Load command config Serverless: Load command config:credentials Serverless: Load command rollback Serverless: Load command rollback:function Serverless: Load command upgrade Serverless: Load command uninstall Serverless: Load command requirements Serverless: Load command requirements:clean Serverless: Load command requirements:install Serverless: Load command requirements:cleanCache Serverless: Load command deploy Serverless: Load command login Serverless: Load command logout Serverless: Load command generate-event Serverless: Load command test Serverless: Load command dashboard Serverless: Load command output Serverless: Load command output:get Serverless: Load command output:list Serverless: Load command param Serverless: Load command param:get Serverless: Load command param:list Serverless: Load command studio

Serverless Warning --------------------------------------

A valid environment variable to satisfy the declaration 'env:SHOPPER_PLAN_TOPIC_ARN' could not be found.

Serverless Warning --------------------------------------

A valid environment variable to satisfy the declaration 'env:SHOPPER_PLAN_TOPIC_ARN' could not be found.

Serverless: [AWS ssm 400 0.698s 0 retries] getParameter({ Name: '/aws/reference/secretsmanager/local/mysql_application_credentials', WithDecryption: true })

Serverless Warning --------------------------------------

A valid SSM parameter to satisfy the declaration 'ssm:/aws/reference/secretsmanager/local/mysql_application_credentials~true' could not be found.

Serverless Warning --------------------------------------

A valid SSM parameter to satisfy the declaration 'ssm:/aws/reference/secretsmanager/local/mysql_application_credentials~true' could not be found.

Serverless Warning --------------------------------------

A valid SSM parameter to satisfy the declaration 'ssm:/aws/reference/secretsmanager/local/mysql_application_credentials~true' could not be found.

Serverless Warning --------------------------------------

A valid SSM parameter to satisfy the declaration 'ssm:/aws/reference/secretsmanager/local/mysql_application_credentials~true' could not be found.

Serverless Warning --------------------------------------

A valid SSM parameter to satisfy the declaration 'ssm:/aws/reference/secretsmanager/local/mysql_application_credentials~true' could not be found.

Serverless Warning --------------------------------------

A valid SSM parameter to satisfy the declaration 'ssm:/aws/reference/secretsmanager/local/mysql_application_credentials~true' could not be found.

Serverless: Invoke deploy Serverless: Invoke package Serverless: Invoke aws:common:validate Serverless: Using serverless-localstack Serverless: Warning: Unable to find plugin named: TypeScriptPlugin Serverless: Invoke aws:common:cleanupTempDir Serverless: Generating requirements.txt from Pipfile... Serverless: Parsed requirements.txt from Pipfile in /home/danilo/Code/clubbi/delivery-planner/.serverless/requirements.txt... Serverless: Using static cache of requirements found at /home/danilo/.cache/serverless-python-requirements/1712547e4ebdc05b79e5a71087615c045868cd578fcdd896a3b4c43256850d20_slspyc ... Serverless: Packaging service... Serverless: Excluding development dependencies... Serverless: Injecting required Python packages to package... Serverless: Invoke aws:package:finalize Serverless: Invoke aws:common:moveArtifactsToPackage Serverless: Invoke aws:common:validate Serverless: Invoke aws:deploy:deploy Serverless: [AWS cloudformation 200 0.032s 0 retries] describeStacks({ StackName: 'orders-local' }) Serverless: [AWS cloudformation 200 0.016s 0 retries] describeStackResource({ StackName: 'orders-local', LogicalResourceId: 'ServerlessDeploymentBucket' }) Serverless: [AWS s3 200 0.022s 0 retries] listObjectsV2({ Bucket: 'orders-local-serverlessdeploymentbucket-rhk27u1y2suv', Prefix: 'serverless/orders/local' }) Serverless: [AWS s3 200 0.034s 0 retries] headObject({ Bucket: 'orders-local-serverlessdeploymentbucket-rhk27u1y2suv', Key: 'serverless/orders/local/1601993915002-2020-10-06T14:18:35.002Z/orders.zip' }) Serverless: [AWS s3 200 0.038s 0 retries] headObject({ Bucket: 'orders-local-serverlessdeploymentbucket-rhk27u1y2suv', Key: 'serverless/orders/local/1601993915002-2020-10-06T14:18:35.002Z/compiled-cloudformation-template.json' }) Serverless: [AWS lambda 404 0.019s 0 retries] getFunction({ FunctionName: 'local-generate_shopper_plan' }) Serverless: [AWS lambda 404 0.025s 0 retries] getFunction({ FunctionName: 'local-save_order' }) Serverless: [AWS lambda 404 0.01s 0 retries] getFunction({ FunctionName: 'local-send_shopper_plan_email' }) Serverless: [AWS sts 200 0.019s 0 retries] getCallerIdentity({}) Serverless: Uploading CloudFormation file to S3... Serverless: [AWS s3 200 0.018s 0 retries] putObject({ Body: <Buffer 7b 22 41 57 53 54 65 6d 70 6c 61 74 65 46 6f 72 6d 61 74 56 65 72 73 69 6f 6e 22 3a 22 32 30 31 30 2d 30 39 2d 30 39 22 2c 22 44 65 73 63 72 69 70 74 ... 9478 more bytes>, Bucket: 'orders-local-serverlessdeploymentbucket-rhk27u1y2suv', Key: 'serverless/orders/local/1601994111990-2020-10-06T14:21:51.990Z/compiled-cloudformation-template.json', ContentType: 'application/json', Metadata: { filesha256: '7L9dGoFR2uDBFpxTRkEpQZTG8uUalVPLoKnohyIl4v8=' } }) Serverless: Uploading artifacts... Serverless: Uploading service orders.zip file to S3 (27.62 MB)... Serverless: [AWS s3 200 0.037s 0 retries] createMultipartUpload({ Bucket: 'orders-local-serverlessdeploymentbucket-rhk27u1y2suv', Key: 'serverless/orders/local/1601994111990-2020-10-06T14:21:51.990Z/orders.zip', ContentType: 'application/zip', Metadata: { filesha256: 'cIAqq1Ikop+0Fruhq9QyuyVdX9GfmnYNX1ILklYT56U=' } }) Serverless: [AWS s3 200 0.29s 0 retries] uploadPart({ Body: <Buffer 16 03 8a 9c 07 14 29 0c 81 74 cc af b9 65 11 c4 ba 95 ff 73 20 6b 30 fa d1 bb d5 da 82 fd 93 f9 24 73 3a 57 a4 3b 48 40 ad db 22 57 a3 92 d9 f4 c1 9b ... 5242830 more bytes>, ContentLength: 5242880, PartNumber: 2, Bucket: 'orders-local-serverlessdeploymentbucket-rhk27u1y2suv', Key: 'serverless/orders/local/1601994111990-2020-10-06T14:21:51.990Z/orders.zip', UploadId: 'q78JQ8E2rybcCHW3Bb8Vu372QTCJNPUu9PtpLld0vc0xl7VlaNX3EqA' }) Serverless: [AWS s3 200 0.341s 0 retries] uploadPart({ Body: <Buffer 49 2a fe 3f 66 d4 16 85 51 09 14 b1 8f 5c d0 d9 d2 54 6d 1c 63 7f 9f 82 fd aa 73 4c 52 c5 39 e2 d5 f4 52 63 82 14 8e c0 1e d1 0f dc fc 52 35 41 ca 1d ... 5242830 more bytes>, ContentLength: 5242880, PartNumber: 3, Bucket: 'orders-local-serverlessdeploymentbucket-rhk27u1y2suv', Key: 'serverless/orders/local/1601994111990-2020-10-06T14:21:51.990Z/orders.zip', UploadId: 'q78JQ8E2rybcCHW3Bb8Vu372QTCJNPUu9PtpLld0vc0xl7VlaNX3EqA' }) Serverless: [AWS s3 200 0.358s 0 retries] uploadPart({ Body: <Buffer 50 4b 03 04 0a 00 00 00 08 00 00 00 21 00 b5 47 7a cc 76 00 00 00 18 01 00 00 12 00 00 00 6c 61 6d 62 64 61 5f 68 61 6e 64 6c 65 72 73 2e 70 79 75 ce ... 5242830 more bytes>, ContentLength: 5242880, PartNumber: 1, Bucket: 'orders-local-serverlessdeploymentbucket-rhk27u1y2suv', Key: 'serverless/orders/local/1601994111990-2020-10-06T14:21:51.990Z/orders.zip', UploadId: 'q78JQ8E2rybcCHW3Bb8Vu372QTCJNPUu9PtpLld0vc0xl7VlaNX3EqA' }) Serverless: [AWS s3 200 0.125s 0 retries] uploadPart({ Body: <Buffer 17 42 bd f2 1c 4a b4 c7 bc 26 54 a9 39 64 ea 00 f8 58 ba a2 54 7e d0 6d f0 6f 17 c8 f7 d4 84 fa cd 93 7a 30 ee ad fc 19 e0 5e d4 81 06 7d 13 3d 94 0d ... 2745289 more bytes>, ContentLength: 2745339, PartNumber: 6, Bucket: 'orders-local-serverlessdeploymentbucket-rhk27u1y2suv', Key: 'serverless/orders/local/1601994111990-2020-10-06T14:21:51.990Z/orders.zip', UploadId: 'q78JQ8E2rybcCHW3Bb8Vu372QTCJNPUu9PtpLld0vc0xl7VlaNX3EqA' }) Serverless: [AWS s3 200 0.279s 0 retries] uploadPart({ Body: <Buffer 4b 6e a0 24 39 b7 59 ca 9e a6 6c f5 ed 92 6b bf b7 bd c2 6f aa 19 c2 1e 4a d5 ef 22 c5 f7 2b 3a 0d 11 51 54 34 05 88 f6 bb 8e 40 54 14 ec 7d 8f c6 ad ... 5242830 more bytes>, ContentLength: 5242880, PartNumber: 5, Bucket: 'orders-local-serverlessdeploymentbucket-rhk27u1y2suv', Key: 'serverless/orders/local/1601994111990-2020-10-06T14:21:51.990Z/orders.zip', UploadId: 'q78JQ8E2rybcCHW3Bb8Vu372QTCJNPUu9PtpLld0vc0xl7VlaNX3EqA' }) Serverless: [AWS s3 200 0.33s 0 retries] uploadPart({ Body: <Buffer 3c 0a 10 4e b5 01 7d 4b a3 93 ba 61 97 c6 63 db c7 e1 05 eb de 11 c2 b8 88 5b 1f 2b bf 52 01 22 28 40 93 70 ed e0 1d 1e 2b af 42 c9 6f 80 fe 87 fe be ... 5242830 more bytes>, ContentLength: 5242880, PartNumber: 4, Bucket: 'orders-local-serverlessdeploymentbucket-rhk27u1y2suv', Key: 'serverless/orders/local/1601994111990-2020-10-06T14:21:51.990Z/orders.zip', UploadId: 'q78JQ8E2rybcCHW3Bb8Vu372QTCJNPUu9PtpLld0vc0xl7VlaNX3EqA' }) Serverless: [AWS s3 200 0.036s 0 retries] completeMultipartUpload({ MultipartUpload: { Parts: [ { ETag: '"6201b1ced4a8827de3c34443040c0a32"', PartNumber: 1 }, { ETag: '"5de6ba5d00fbf3ecb6f65841c588888f"', PartNumber: 2 }, { ETag: '"b5481faffd2cb4de02309efdedd0d60e"', PartNumber: 3 }, { ETag: '"7a6deb5c005eaf26c09900eb64fcb64a"', PartNumber: 4 }, { ETag: '"191faca21ed3d1c4c24797609c02e04b"', PartNumber: 5 }, { ETag: '"fc694d2c5134d0aabf319d71ad1970c4"', PartNumber: 6 },

] }, Bucket: 'orders-local-serverlessdeploymentbucket-rhk27u1y2suv', Key: 'serverless/orders/local/1601994111990-2020-10-06T14:21:51.990Z/orders.zip', UploadId: 'q78JQ8E2rybcCHW3Bb8Vu372QTCJNPUu9PtpLld0vc0xl7VlaNX3EqA' }) Serverless: Validating template... Serverless: Skipping template validation: Unsupported in Localstack Serverless: Updating Stack... Serverless: [AWS cloudformation 200 0.181s 0 retries] updateStack({ StackName: 'orders-local', Capabilities: [ 'CAPABILITY_IAM', 'CAPABILITY_NAMED_IAM', length: 2 ], Parameters: [ length: 0 ], TemplateURL: 'https://s3.amazonaws.com/orders-local-serverlessdeploymentbucket-rhk27u1y2suv/serverless/orders/local/1601994111990-2020-10-06T14:21:51.990Z/compiled-cloudformation-template.json', Tags: [ { Key: 'STAGE', Value: 'local' }, length: 1 ] }) Serverless: Checking Stack update progress... Serverless: [AWS cloudformation 200 0.039s 0 retries] describeStackEvents({ StackName: 'arn:aws:cloudformation:us-east-1:000000000000:stack/orders-local/46a8d068-3b88-4255-9b65-ab955c2761e9' }) . Serverless: Stack update finished... Serverless: Invoke aws:info Serverless: [AWS cloudformation 200 0.033s 0 retries] describeStacks({ StackName: 'orders-local' }) Serverless: [AWS cloudformation 500 0.621s 3 retries] listStackResources({ StackName: 'orders-local', NextToken: undefined })

Type Error ---------------------------------------------

TypeError: message.startsWith is not a function at /home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:816:23 at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:97:5) From previous event: at persistentRequest (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:743:7) at Object.promiseGenerator (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:798:7) at Queue._dequeue (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/node_modules/promise-queue/lib/index.js:153:30) at /home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/node_modules/promise-queue/lib/index.js:109:18 From previous event: at Queue.add (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/node_modules/promise-queue/lib/index.js:94:16) at AwsProvider.request (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:797:39) at LocalstackPlugin.interceptRequest (/home/danilo/Code/clubbi/delivery-planner/node_modules/serverless-localstack/src/index.js:518:17) at AwsProvider.providerRequest [as request] (/home/danilo/Code/clubbi/delivery-planner/node_modules/serverless-localstack/src/index.js:391:22) at AwsInfo.getResourceCount (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/plugins/aws/info/getResourceCount.js:11:26) From previous event: at Object.aws:info:gatherData [as hook] (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/plugins/aws/info/index.js:53:12) at /home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/classes/PluginManager.js:510:55 From previous event: at PluginManager.invoke (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/classes/PluginManager.js:510:22) at PluginManager.spawn (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/classes/PluginManager.js:530:17) at AwsInfo. (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/plugins/aws/info/index.js:45:48) From previous event: at Object.deploy:deploy [as hook] (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/plugins/aws/info/index.js:41:30) at /home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/classes/PluginManager.js:510:55 From previous event: at PluginManager.invoke (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/classes/PluginManager.js:510:22) at /home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/classes/PluginManager.js:545:24 From previous event: at PluginManager.run (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/classes/PluginManager.js:545:8) at /home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/Serverless.js:168:33 From previous event: at Serverless.run (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/lib/Serverless.js:155:74) at /home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/scripts/serverless.js:50:26 at processImmediate (internal/timers.js:456:21) From previous event: at Object. (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/scripts/serverless.js:50:4) at Module._compile (internal/modules/cjs/loader.js:1137:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10) at Module.load (internal/modules/cjs/loader.js:985:32) at Function.Module._load (internal/modules/cjs/loader.js:878:14) at Module.require (internal/modules/cjs/loader.js:1025:19) at require (internal/modules/cjs/helpers.js:72:18) at Object. (/home/danilo/.nvm/versions/node/v12.18.3/lib/node_modules/serverless/bin/serverless.js:47:1) at Module._compile (internal/modules/cjs/loader.js:1137:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10) at Module.load (internal/modules/cjs/loader.js:985:32) at Function.Module._load (internal/modules/cjs/loader.js:878:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47

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

Your Environment Information --------------------------- Operating System: linux Node Version: 12.18.3 Framework Version: 2.4.0 Plugin Version: 4.0.4 SDK Version: 2.3.2 Components Version: 3.2.1

sync-by-unito[bot] commented 3 years ago

➤ Doggy commented:

Also seeing this TypeError: message.startsWith is not a function error. Deleting the old docker image seems to be working for me.

sync-by-unito[bot] commented 3 years ago

➤ Danilo Pereira commented:

joedevgee can you please tell me your image ID?

My is 5b792b1d1ef2

sync-by-unito[bot] commented 3 years ago

➤ msteve-tokzu commented:

I'm also seeing this when I try to deploy multiple cognito triggers using the CDK in the latest localstack pull (as of today).

When I try to deploy to localstack with cdklocal I get the following error:

localstack_main | 2020-10-27T20:26:42:WARNING:localstack.utils.cloudformation.template_deployer: Error calling <bound method ClientCreator._create_api_method.._api_call of <botocore.client.Lambda object at 0x7fec4952e790>> with params: {'Action': 'lambda:InvokeFunction', 'Principal': 'cognito-idp.amazonaws.com', 'StatementId': '576273f1'} for resource: {'Type': 'AWS::Lambda::Permission', 'Properties': {'Action': 'lambda:InvokeFunction', 'Principal': 'cognito-idp.amazonaws.com'}, 'Metadata': {'aws:cdk:path': 'ReproStack/cogsignup/PreSignUpCognito'}} localstack_main | 2020-10-27T20:26:42:ERROR:localstack.services.cloudformation.cloudformation_starter: Unable to parse and create resource "cogsignupPreSignUpCognito639C1C9E": Parameter validation failed: localstack_main | Missing required parameter in input: "FunctionName" Traceback (most recent call last): localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 283, in parse_and_create_resource localstack_main | return parseand_create_resource( localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 395, in parseand_create_resource localstack_main | result = deploy_func(logical_id, resource_map_new, stack_name=stack_name) localstack_main | File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1163, in deploy_resource localstack_main | return execute_resource_action(resource_id, resources, stack_name, ACTION_CREATE) localstack_main | File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1206, in execute_resource_action localstack_main | result = configure_resource_via_sdk(resource_id, resources, resource_type, func, stack_name) localstack_main | File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1292, in configure_resource_via_sdk localstack_main | raise e localstack_main | File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1289, in configure_resource_via_sdk localstack_main | result = function(params) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 357, in apicall localstack_main | return self._make_api_call(operation_name, kwargs) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 648, in makeapi_call localstack_main | request_dict = self._convert_to_request_dict( localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/client.py", line 696, in convertto_request_dict localstack_main | request_dict = self._serializer.serialize_to_request( localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/botocore/validate.py", line 297, in serialize_to_request localstack_main | raise ParamValidationError(report=report.generate_report()) localstack_main | botocore.exceptions.ParamValidationError: Parameter validation failed: localstack_main | Missing required parameter in input: "FunctionName" localstack_main | localstack_main | 2020-10-27T20:26:42:WARNING:bootstrap.py: Thread run method <function apply_patches..cloudformation_backend_execute_change_set..do_execute at 0x7fec4a5ac280>(None) failed: Parameter validation failed: localstack_main | Missing required parameter in input: "FunctionName" Traceback (most recent call last): localstack_main | File "/opt/code/localstack/localstack/utils/bootstrap.py", line 534, in run localstack_main | result = self.func(self.params) localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 1065, in do_execute localstack_main | cloudformation_backend_execute_change_set_orig(self, change_set_name, stack_name) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/cloudformation/models.py", line 682, in execute_change_set localstack_main | stack.initialize_resources() localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 989, in initialize_resources localstack_main | self.resource_map.create(self.template_dict) localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/cloudformation/parsing.py", line 589, in create localstack_main | if isinstance(self[resource], ec2_models.TaggedEC2Resource): localstack_main | File "/opt/code/localstack/.venv/lib/python3.8/site-packages/moto/cloudformation/parsing.py", line 451, in getitem localstack_main | new_resource = parse_and_create_resource( localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 283, in parse_and_create_resource localstack_main | return parseand_create_resource( localstack_main | File "/opt/code/localstack/localstack/services/cloudformation/cloudformation_starter.py", line 395, in parseand_create_resource localstack_main | result = deploy_func(logical_id, resource_map_new, stack_name=stack_name) localstack_main | File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1163, in deploy_resource localstack_main | return execute_resource_action(resource_id, resources, stack_name, ACTION_CREATE) localstack_main | File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1206, in execute_resource_action localstack_main | result = configure_resource_via_sdk(resource_id, resources, resource_type, func, stack_name) localstack_main | File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1292, in configure_resource_via_sdk localstack_main | raise e localstack_main | File "/opt/code/localstack/localstack/utils/cloudformation/template_deployer.py", line 1289, in configure_resource_via_sdk localstack_main | result = function(params)I verified in the generated cloudformation template that the resource cogsignupPreSignUpCognito639C1C9E has a FunctionName parameter in

"cogsignupPreSignUpCognito639C1C9E": { "Type": "AWS::Lambda::Permission", "Properties": { "Action": "lambda:InvokeFunction", "FunctionName": { "Fn::GetAtt": [ "cogsignupF20EC8E8", "Arn" ] }, "Principal": "cognito-idp.amazonaws.com" }, "Metadata": { "aws:cdk:path": "ReproStack/cogsignup/PreSignUpCognito" } }, Here is the CDK template (I have tried with CDK dependencies pinned to 1.64.1):

import as cdk from "@aws-cdk/core"; import as ddb from "@aws-cdk/aws-dynamodb"; import as lambda from "@aws-cdk/aws-lambda"; import as apigw from "@aws-cdk/aws-apigateway"; import as cognito from "@aws-cdk/aws-cognito"; import {UserPool, AccountRecovery, StringAttribute} from "@aws-cdk/aws-cognito"; import { Duration } from "@aws-cdk/core"; import as path from "path";

export class ReproStack extends cdk.Stack { constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) { super(scope, id, props);

// Create databases const myTable = new ddb.Table(this, "mytable", { partitionKey: { name: "Pk", type: ddb.AttributeType.STRING, }, tableName: "mytable", billingMode: ddb.BillingMode.PAY_PER_REQUEST, });

const lambdaFn = new lambda.Function(this, "apilambda", { code: lambda.Code.fromAsset( path.join(__dirname, "../../../out/function.zip") ), timeout: cdk.Duration.seconds(300), runtime: lambda.Runtime.GO_1_X, handler: "server_unix", environment: { TABLE_NAME: myTable.tableName, }, });

const signUpLambdaFn = new lambda.Function(this, "cogsignup", { code: lambda.Code.fromAsset( path.join(__dirname, "../../../out/cogs.zip") ), timeout: cdk.Duration.seconds(300), runtime: lambda.Runtime.GO_1_X, handler: "cog_signup", environment: { USER_PROFILE_TABLE_NAME: myTable.tableName, }, });

const postConfLambdaFn = new lambda.Function(this, "cogpostconf", { code: lambda.Code.fromAsset( path.join(__dirname, "../../../out/cogp.zip") ), timeout: cdk.Duration.seconds(300), runtime: lambda.Runtime.GO_1_X, handler: "cog_postconf", environment: { USER_PROFILE_TABLE_NAME: myTable.tableName, }, });

// Create user pool const userPool: UserPool = new cognito.UserPool(this, id + "pool", { userPoolName: ${id}-pool, autoVerify: { email: true }, passwordPolicy: { minLength: 8, requireDigits: false, requireLowercase: false, requireSymbols: false, requireUppercase: false, tempPasswordValidity: Duration.days(7) }, selfSignUpEnabled: true, accountRecovery: AccountRecovery.EMAIL_ONLY, signInAliases: { email: true, preferredUsername: true, username: true }, signInCaseSensitive: false, standardAttributes: { givenName: { mutable: true, required: false }, familyName: { mutable: true, required: false }, email: { mutable: true, required: true }, phoneNumber: { mutable: true, required: false }, profilePicture: { mutable: true, required: false }, birthdate: { mutable: true, required: false } }, customAttributes: { 'dummystuff': new StringAttribute({ mutable: true

}) }, lambdaTriggers: { preSignUp: signUpLambdaFn, postConfirmation: postConfLambdaFn } });

// Create client with some cfn goodness const userPoolClient = new cognito.UserPoolClient(this, id + "web", { userPool: userPool, generateSecret: false, authFlows: { adminUserPassword: true, userPassword: true }, oAuth: { callbackUrls: ["http://localhost:3000"], scopes: [ cognito.OAuthScope.COGNITO_ADMIN, cognito.OAuthScope.EMAIL, cognito.OAuthScope.OPENID, cognito.OAuthScope.PHONE, cognito.OAuthScope.PROFILE ], flows: { authorizationCodeGrant: true, implicitCodeGrant: true } } });

myTable.grantReadWriteData(lambdaFn); myTable.grantReadWriteData(signUpLambdaFn); myTable.grantReadWriteData(postConfLambdaFn);

const api = new apigw.RestApi(this, "myapiendpoint", { restApiName: "MyRestApi", }); const apiRoot = api.root.addResource("api"); const integration = new apigw.LambdaIntegration(lambdaFn); const proxy = apiRoot.addProxy({ anyMethod: true, defaultIntegration: integration, }); } }

sync-by-unito[bot] commented 3 years ago

➤ msteve-tokzu commented:

This PR looks like a similar issue but after looking at the code, I'm not sure it's going to fix the root cause here: https://github.com/spulec/moto/pull/3396