首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >拆分serverless.yml文件

拆分serverless.yml文件
EN

Stack Overflow用户
提问于 2020-03-30 17:59:14
回答 1查看 858关注 0票数 1

如何将此serverless.yml文件拆分为两个.yml文件?

我碰到了cloudFormation模板验证错误..。资源的数量,202,大于允许的最大值200

我在这个问题上已经被困了5天了,在解决这个问题之前,我不能再继续使用我的应用程序了。

如何将这些服务与主YML文件分割成不同的YML文件?

Serverless.yml

代码语言:javascript
复制
service: p-app-api

# Create an optimized package for our functions
package:
  individually: true

plugins:
  - serverless-bundle # Package our functions with Webpack
  - serverless-offline
  - serverless-dotenv-plugin

provider:
  name: aws
  runtime: nodejs10.x
  stage: dev
  region: us-east-2
  environment:
    stripeSecretKey: ${env:STRIPE_SECRET_KEY}
  # 'iamRoleStatements' defines the permission policy for the Lambda function.
  # In this case Lambda functions are granted with permissions to access DynamoDB.
  iamRoleStatements:
    - Effect: Allow
      Action:
        - dynamodb:DescribeTable
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
      Resource: "arn:aws:dynamodb:us-east-2:433684495079:table/data"
    - Effect: Allow
      Action:
        - dynamodb:Query
        - dynamodb:Scan
      Resource: "arn:aws:dynamodb:us-east-2:433684495079:table/data/index/zipCode-packageSelected-index"
    - Effect: Allow
      Action:
        - dynamodb:Query
        - dynamodb:Scan
      Resource: "arn:aws:dynamodb:us-east-2:433684495079:table/data/index/jobId-index"
    - Effect: Allow
      Action:
        - dynamodb:DescribeTable
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
      Resource: "arn:aws:dynamodb:us-east-2:433684495079:table/Service"
    - Effect: Allow
      Action:
        - dynamodb:Query
        - dynamodb:Scan
      Resource: "arn:aws:dynamodb:us-east-2:433684495079:table/Service/index/index"
    - Effect: Allow
      Action:
        - s3:*
      Resource: "arn:aws:s3:::service/public/*"
    - Effect: Allow
      Action:
        - dynamodb:DescribeTable
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:GetItem
        - dynamodb:PutItem
        - dynamodb:UpdateItem
        - dynamodb:DeleteItem
      Resource: "arn:aws:dynamodb:us-east-2:433684495079:table/Service"
    - Effect: Allow
      Action:
        - dynamodb:Query
        - dynamodb:Scan
      Resource: "arn:aws:dynamodb:us-east-2:433684495079:table/data/index/packageSelected"

functions:
  # Defines an HTTP API endpoint that calls the main function in create.js
  # - path: url path is /notes
  # - method: POST request
  # - cors: enabled CORS (Cross-Origin Resource Sharing) for browser cross
  #     domain api call
  # - authorizer: authenticate using the AWS IAM role
  create:
    handler: create.main
    events:
      - http:
          path: data
          method: post
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  get:
    # Defines an HTTP API endpoint that calls the main function in get.js
    # - path: url path is /notes/{id}
    # - method: GET request
    handler: get.main
    events:
      - http:
          path: data/{id}
          method: get
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  list:
    # Defines an HTTP API endpoint that calls the main function in list.js
    # - path: url path is /notes
    # - method: GET request
    handler: list.main
    events:
      - http:
          path: data
          method: get
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  update:
    # Defines an HTTP API endpoint that calls the main function in update.js
    # - path: url path is /notes/{id}
    # - method: PUT request
    handler: update.main
    events:
      - http:
          path: data/{id}
          method: put
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  delete:
    # Defines an HTTP API endpoint that calls the main function in delete.js
    # - path: url path is /notes/{id}
    # - method: DELETE request
    handler: delete.main
    events:
      - http:
          path: data/{id}
          method: delete
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  createCustomer:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: createCustomer.main
    events:
      - http:
          path: createCustomer
          method: post
          cors: true
          authorizer:
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  updateCustomer:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: updateCustomer.main
    events:
      - http:
          path: updateCustomer
          method: post
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  listCustomerCard:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: listCustomerCard.main
    events:
      - http:
          path: listCustomerCard/{id}
          method: get
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  deleteCard:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: DeleteCard.main
    events:
      - http:
          path: deleteCard/{id}/{card}
          method: delete
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  getCustomerInfo:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: getCustomerInfo.main
    events:
      - http:
          path: getCustomerInfo/{id}
          method: get
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  updateCustomerCard:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: updateCustomerCard.main
    events:
      - http:
          path: updateCustomerCard/{id}
          method: post
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  createInvoice:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: createInvoice.main
    events:
      - http:
          path: createInvoice
          method: post
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  deleteInvoice:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: deleteInvoice.main
    events:
      - http:
          path: deleteInvoice/{id}
          method: delete
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  listInvoices:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: listInvoices.main
    events:
      - http:
          path: listInvoices/{id}
          method: get
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  ListNewJobs:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: ListNewJobs.main
    events:
      - http:
          path: data/ListNewJobs
          method: get
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  jobIndex:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: jobIndex.main
    events:
      - http:
          path: data/jobIndex
          method: get
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  updateJobStatus:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: updateJobStatus.main
    events:
      - http:
          path: data/jobStatus
          method: put
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  createNewJob:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: createNewJob.main
    events:
      - http:
          path: ServiceJobs/createNewJob
          method: post
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  listMyNewJobs:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: listMyNewJobs.main
    events:
      - http:
          path: ServiceJobs/listMyNewJobs
          method: get
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  DeleteMyNewJob:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: DeleteMyNewJob.main
    events:
      - http:
          path: ServiceJobs/DeleteMyNewJob/{id}
          method: delete
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  UpdateServiceJobList:
    # Defines an HTTP API endpoint that calls the main function in update.js
    # - path: url path is /notes/{id}
    # - method: PUT request
    handler: UpdateServiceJobList.main
    events:
      - http:
          path: ServicesJobs/Update
          method: put
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  ServiceIndex:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: ServiceIndex.main
    events:
      - http:
          path: ServiceJobs/ServiceIndex
          method: get
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  UpdateMyJob:
    # Defines an HTTP API endpoint that calls the main function in update.js
    # - path: url path is /notes/{id}
    # - method: PUT request
    handler: UpdateMyJob.main
    events:
      - http:
          path: ServiceJobs/UpdateMyJob
          method: put
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  PayInvoiceStripe:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: PayInvoiceStripe.main
    events:
      - http:
          path: stripe/PayInvoice
          method: post
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  StripeNewContractorAccount:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: StripeNewContractorAccount.main
    events:
      - http:
          path: stripe/NewContractorAccount
          method: post
          cors: true
          authorizer:
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  serviceInfoPut:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: serviceInfoPut.main
    events:
      - http:
          path: serviceInfo/post
          method: post
          cors: true
          authorizer:
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
  ListJobsForEdit:
    # Defines an HTTP API endpoint that calls the main function in billing.js
    # - path: url path is /billing
    # - method: POST request
    handler: ListJobsForEdit.main
    events:
      - http:
          path: data/index/packageSelected
          method: get
          cors: true
          authorizer: aws_iam
          arn: aws:cognito-idp:us-east-2:433684495079:userpool/us-east-2_Q0sUvw4Qy
# Create our resources with separate CloudFormation templates
resources:
  # API Gateway Errors
  - ${file(resources/api-gateway-errors.yml)}
EN

回答 1

Stack Overflow用户

发布于 2020-03-30 18:19:10

我在使用无服务器插件-分割堆栈插件时取得了一些成功。

您可以通过一个少数方法来拆分您的堆栈,但是对于您的情况,您可能希望每个兰卜达拆分。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60936623

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档