skysoft999
skysoft999

Reputation: 579

serverless deployment issue upon adding serverless-split-stack plugin and provisionalConcurrency configuration

I have come across a condition where my project resource ran out of the 500 cloud stack limit of AWS, and because of that, I was forced to use the serverless-split-stack plugin. It was deploying as expected without adding the provisionalConcurrency parameter to the function. Upon adding this config deployment starts failing, Has anyone faced a similar situation ever? It would be great if someone could help me to resolve this issue.

getting error:

Stack dm-scratch-v2-test failed to deploy (1359s) Environment: darwin, node 14.15.4, framework 3.34.0 (local) 3.34.0v (global), plugin 6.2.3, SDK 4.3.2 Credentials: Local, environment variables

The CloudFormation template is invalid: Template format error: Unresolved resource dependencies [AuthorizerFuncLambdaFunctionArnParameter] in the Resources block of the template

service: dm-scratch-v2

frameworkVersion: '3'

# general configurations
provider:
  runtime: python3.8
  name: aws
  logs:
    restApi: true
  timeout: 29  # in seconds
  ecr:
    images:
      appimage:
        path: ./
  httpApi:
    cors: true
    authorizers:
      Authorizer:
        type: request
        functionName: authorizerFunc
        resultTtlInSeconds: 300
        identitySource:
          - $request.header.Authorization
  deploymentBucket:
    name: mysvc-v2-deployments
    serverSideEncryption: AES256
  versionFunctions: false
  stage: dev
  region: us-west-1


custom:
  basename: ${self:service}-${self:provider.stage}
  pythonRequirements:
    dockerizePip: true
    slim: true
    usePipenv: false
    zip: true
  splitStacks:
    nestedStackCount: 20 # Controls the number of created nested stacks
    perFunction: false
    perType: true
    perGroupFunction: true

functions:
  authorizerFunc:
    provisionedConcurrency: 1
    image:
      name: appimage
      command:
        - gateway.policy.auth.user_token_authorizer
      entryPoint:
        - '/lambda-entrypoint.sh'
  user_roles:
    provisionedConcurrency: 1
    image:
      name: appimage
      command:
        - user.events.roles.main
      entryPoint:
        - '/lambda-entrypoint.sh'
    events:
      - httpApi:
          path: /roles
          method: get
          authorizer:
            name: Authorizer

  get_role_info:
    provisionedConcurrency: 1
    image:
      name: appimage
      command:
        - user.events.roles.get_role_id_by_token
      entryPoint:
        - '/lambda-entrypoint.sh'
    events:
      - httpApi:
          path: /role/info
          method: get
          authorizer:
            name: Authorizer

    ......................
    ......................
    ......................
    ......................
    ......................
    
  clear_all:
    provisionedConcurrency: 1
    image:
      name: appimage
      command:
        - device.events.devices.clearall
      entryPoint:
        - '/lambda-entrypoint.sh'
    events:
      - httpApi:
          path: /devices/{device_id}/clearall
          method: delete
          authorizer:
            name: Authorizer

  list_all_policy:
    provisionedConcurrency: 1
    image:
      name: appimage
      command:
        - policy.events.main.policy
      entryPoint:
        - '/lambda-entrypoint.sh'
    events:
      - httpApi:
          path: /policy/list
          method: get
          authorizer:
            name: Authorizer

# place to manage plugins
plugins:
  - serverless-offline
  - serverless-python-requirements
  - serverless-plugin-split-stacks

Upvotes: 0

Views: 270

Answers (1)

pgrzesik
pgrzesik

Reputation: 2427

It looks like by default the plugin splits the resources to stacks in a way that the authorizer function isn't in the same stack as the APIGW resources anymore. You might want to experiment with different splitting setup, the plugin offers full customization of how the resources should be split: https://github.com/dougmoscrop/serverless-plugin-split-stacks#advanced-usage

Upvotes: 1

Related Questions