Deploying one more lambda function fails

Hi,

I am deploying a list of lambda functions written both in python and Nodejs with one serveless repo like this:

service: xxx

plugins:
  - serverless-python-requirements
  - serverless-plugin-tracing

custom:
  pythonRequirements:
    dockerizePip: non-linux
  stage: ${opt:stage, self:provider.stage}
  securityGroup:
    dev: sg-07a488b8010ccb56b
    staging: sg-0800627978a40527b
  subnetIds:
    dev: 'subnet-0e8ce82de27f146db, subnet-0e0aedab3e14c4614'
    staging: 'subnet-04ad6e355249c757d, subnet-01260544aaa3c6810'
  debugging:
    dev: true
    staging: false
  mongodb:
    url:
      dev: mongodb://xxx-dev:xxx-dev-pwd@${opt:mongodb_ip}:27017/xxx-api-dev
      staging: mongodb://${opt:mongodb_user}:${opt:mongodb_pwd}@${opt:mongodb_ip}:27017/${opt:mongodb_db}
  bucket:
    dev: xxx-uploads-dev
    staging: xxx-uploads-staging
  elasticsearch:
    resource:
      dev: xxx-test
      staging: xxx-staging
    url:
      dev: xxx
      staging: xxx
    index: xxx-data
  sns:
    topicName: "xxx-sns-uploads-${self:custom.stage}"
    arn:
      Fn::Join:
        - ':'
        - - 'arn:aws:sns'
          - Ref: 'AWS::Region'
          - Ref: 'AWS::AccountId'
          - ${self:custom.sns.topicName}

package:
  individually: true
  exclude:
    - .nyc_output/**
    - coverage/**
    - data/**
    - docs/**
    - envs/**
    - samples/**
    - src/**
    - test/**
    - tmp/**
    - tsconfig*
    - "*.yml"
    - "*.md"
    - "*.sh"
    - ".dockerignore"
    - "Dockerfile"
    - "gulpfile.js"

provider:
  name: aws
  apiKeys:
    - ${self:service}-${self:custom.stage}
  region: us-east-1
  stage: dev
  memorySize: 256
  timeout: 180
  tracing: true
  environment:
    DEBUG: ${self:custom.debugging.${self:custom.stage}}
    BUCKET: ${self:custom.bucket.${self:custom.stage}}
    ELASTICSEARCH_URL: ${self:custom.elasticsearch.url.${self:custom.stage}}
    ELASTICSEARCH_INDEX: ${self:custom.elasticsearch.index}
    SNS_TOPIC: ${self:custom.sns.arn}
    CSV_HEADERS_ROWS: 0
    CSV_ARRAY_DELIMITER: ";"
    MONGODB_URL: ${self:custom.mongodb.url.${self:custom.stage}}
  iamRoleStatements:
    - Effect: Allow
      Action:
        - s3:GetObject
        - s3:GetObjectAcl
        - s3:PutObject
        - s3:PutObjectAcl
      Resource: "arn:aws:s3:::${self:custom.bucket.${self:custom.stage}}/*"
    - Effect: Allow
      Action:
        - s3:PutObject
        - s3:PutObjectAcl
      Resource: "arn:aws:s3:::xxx-data-${self:custom.stage}/*"
    - Effect: Allow
      Action:
        - 'es:*'
      Resource: "arn:aws:es:::${self:custom.elasticsearch.resource.${self:custom.stage}}/*"
    - Effect: Allow
      Action:
        - 'xray:*'
      Resource:
        - '*'
    - Effect: Allow
      Action:
        - 'sns:*'
      Resource:
        - '*'
  vpc:
    securityGroupIds:
      - ${self:custom.securityGroup.${self:custom.stage}}
    subnetIds:
      "Fn::Split":
          - ","
          - ${opt:SUBNET_IDS, self:custom.subnetIds.${self:custom.stage}}

functions:
  checkProgress:
    runtime: nodejs12.x
    handler: dist/progress/handler.checkProgress
    memorySize: 128
    reservedConcurrency: 100
    events:
      - sns:
          arn: ${self:custom.sns.arn}
          topicName: ${self:custom.sns.topicName}
          filterPolicy:
            functionName:
              - convertExcelDone
              - convertExcelError
              - convertCsvDone
              - convertCsvError
              - checkExistingDone
              - checkExistingError
              - extendMendeleyDone
              - extendMendeleyError
              - addMetadataDone
              - addMetadataError
              - validateDone
              - validateError
              - copyDone
              - copyError
              - indexJsonDone
              - indexJsonError
  convertExcel:
    runtime: python3.7
    handler: handler.convertExcel
    module: convert_excel
    package:
      exclude:
        - node_modules/**
    events:
      - s3:
          bucket: ${self:custom.bucket.${self:custom.stage}}
          event: s3:ObjectCreated:*
          rules:
            - suffix: .xls
          existing: true
      - s3:
          bucket: ${self:custom.bucket.${self:custom.stage}}
          event: s3:ObjectCreated:*
          rules:
            - suffix: .xlsx
          existing: true
    layers:
      - arn:aws:lambda:us-east-1:113088814899:layer:Klayers-python37-boto3:45
      - arn:aws:lambda:us-east-1:113088814899:layer:Klayers-python37-pandas:18
      - arn:aws:lambda:us-east-1:113088814899:layer:Klayers-python37-aws-xray-sdk:36
  convertCsv:
    runtime: nodejs12.x
    handler: dist/handler.convertCsv
    events:
      - s3:
          bucket: ${self:custom.bucket.${self:custom.stage}}
          event: s3:ObjectCreated:*
          rules:
            - suffix: .csv
          existing: true
  checkExisting:
    runtime: nodejs12.x
    handler: dist/handler.checkExisting
    reservedConcurrency: 2
    events:
      - sns:
          arn: ${self:custom.sns.arn}
          topicName: ${self:custom.sns.topicName}
          filterPolicy:
            functionName:
              - checkExisting
  addMetadata:
    runtime: nodejs12.x
    handler: dist/handler.addMetadata
    events:
      - sns:
          arn: ${self:custom.sns.arn}
          topicName: ${self:custom.sns.topicName}
          filterPolicy:
            functionName:
              - addMetadata
  validate:
    runtime: nodejs12.x
    handler: dist/handler.validate
    events:
      - sns:
          arn: ${self:custom.sns.arn}
          topicName: ${self:custom.sns.topicName}
          filterPolicy:
            functionName:
              - validate
  copy:
    runtime: nodejs12.x
    handler: dist/handler.copy
    memorySize: 128
    timeout: 30
    environment:
      TO_BUCKET: xxx-data-${self:custom.stage}
    events:
      - http:
          path: /copyHestia
          method: post
          private: true
          cors: true
      - sns:
          arn: ${self:custom.sns.arn}
          topicName: ${self:custom.sns.topicName}
          filterPolicy:
            functionName:
              - copy

This deployment works fine.

Now I am trying to add a new lambda function to it, with python, so in functions I add:

myFunction:
  runtime: python3.7
  handler: handler.myFunction
  module: my_function
  package:
    exclude:
      - node_modules/**
  reservedConcurrency: 10
  events:
    - sns:
        arn: ${self:custom.sns.arn}
        topicName: ${self:custom.sns.topicName}
        filterPolicy:
          functionName:
            - myFunction
  layers:
    - arn:aws:lambda:us-east-1:113088814899:layer:Klayers-python37-boto3:45
    - arn:aws:lambda:us-east-1:113088814899:layer:Klayers-python37-aws-xray-sdk:36

But this fails with the following error:

An error occurred: ValidateLambdaFunction - 1 validation error detected: Value ‘[subnet-0e8ce82de27f146db, subnet-0e0aedab3e14c4614]’ at ‘vpcConfig.subnetIds’ failed to satisfy constraint: Member must satisfy constraint: [Member must have length less than or equal to 1024, Member must have length greater than or equal to 0, Member must satisfy regular expression pattern: ^subnet-[0-9a-z]*$] (Service: AWSLambdaInternal; Status Code: 400; Error Code: ValidationException; Request ID: 96f65fd5-98f2-4b5f-8453-ace4e99ce4ec).

This doesnt make any sense as I am not changing the subnets or anything between the 2 versions, just adding a new lambda function, which is very similar to the other existing python function.

1 Like

Just wondering if there was any solution to resolve this? Have the same issue when adding a new lambda with 3 subnets specified.