如何摆脱无服务器“警告:根目录遇到无效配置:无法识别的属性“deploymentBucket””

发布于 2025-01-17 08:23:14 字数 2833 浏览 3 评论 0原文

我有一个在无服务器框架版本 3.7.5 上运行的 Web 应用程序。每次部署 lambda 函数时,我都会收到此警告:

“警告:根目录遇到无效配置:无法识别的属性‘deploymentBucket’”。

我已附上下面的“serverless.yml”文件以供外部审查。我的“deploymentBucket”属性配置无效吗?我需要更改或编辑任何属性吗?

注意:部署工作正常,因为它只是一个警告,我可以继续测试我的 api 端点...我只是发现这个警告有点麻烦,想一劳永逸地删除它。提前致谢!

这是我的 serverless.yml 文件

# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
#    docs.serverless.com
#
# Happy Coding!

service: poppy-seed
# app and org for use with dashboard.serverless.com
#app: your-app-name
#org: your-org-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
frameworkVersion: '3.7.5'

provider:
  name: aws
  runtime: java11
  timeout: 30
  lambdaHashingVersion: 20201221

# you can overwrite defaults here
#  stage: dev
#  region: us-east-1
    variable1: value1

# you can add packaging information here
package:
  artifact: build/libs/poppy-seed-dev-all.jar

functions:
  poppy-seed:
    handler: com.serverless.lambda.Handler
#    The following are a few example events you can configure
#    NOTE: Please make sure to change your handler code to work with those events
#    Check the event documentation for details
    events:
      - http:
          path: "{proxy+}"
          method: ANY
          cors: true


deploymentBucket:
  blockPublicAccess: true # Prevents public access via ACLs or bucket policies. Default is false
  skipPolicySetup: false # Prevents creation of default bucket policy when framework creates the deployment bucket. Default is false
  name: # Deployment bucket name. Default is generated by the framework
  maxPreviousDeploymentArtifacts: 5 # On every deployment the framework prunes the bucket to remove artifacts older than this limit. The default is 5
  versioning: false # enable bucket versioning. Default is false
  deploymentPrefix: serverless # The S3 prefix under which deployed artifacts should be stored. Default is serverless
  disableDefaultOutputExportNames: false # optional, if set to 'true', disables default behavior of generating export names for CloudFormation outputs
  lambdaHashingVersion: 20201221 # optional, version of hashing algorithm that should be used by the framework


plugins:
  - serverless-sam
#  Resources:
#    NewResource:
#      Type: AWS::S3::Bucket
#      Properties:
#        BucketName: my-new-bucket
#  Outputs:
#     NewOutput:
#       Description: "Description for the output"
#       Value: "Some output value"

I've got a web application running on the serverless framework version 3.7.5. Every time I deploy my lambda function I get this warning:

"Warning: Invalid configuration encountered at root: unrecognised property 'deploymentBucket'".

I have attached the "serverless.yml" file below for external scrutiny. Is my configuration of the "deploymentBucket" property not valid? Do I need to change or edit any of the properties?

Note: Deployment works fine as it's simply a warning and I am able to proceed to testing my api endpoints... I just find this warning a tad bothersome and would like to erase it once and for all. Thanks in advance!

Here's my serverless.yml file

# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
#    docs.serverless.com
#
# Happy Coding!

service: poppy-seed
# app and org for use with dashboard.serverless.com
#app: your-app-name
#org: your-org-name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
frameworkVersion: '3.7.5'

provider:
  name: aws
  runtime: java11
  timeout: 30
  lambdaHashingVersion: 20201221

# you can overwrite defaults here
#  stage: dev
#  region: us-east-1
    variable1: value1

# you can add packaging information here
package:
  artifact: build/libs/poppy-seed-dev-all.jar

functions:
  poppy-seed:
    handler: com.serverless.lambda.Handler
#    The following are a few example events you can configure
#    NOTE: Please make sure to change your handler code to work with those events
#    Check the event documentation for details
    events:
      - http:
          path: "{proxy+}"
          method: ANY
          cors: true


deploymentBucket:
  blockPublicAccess: true # Prevents public access via ACLs or bucket policies. Default is false
  skipPolicySetup: false # Prevents creation of default bucket policy when framework creates the deployment bucket. Default is false
  name: # Deployment bucket name. Default is generated by the framework
  maxPreviousDeploymentArtifacts: 5 # On every deployment the framework prunes the bucket to remove artifacts older than this limit. The default is 5
  versioning: false # enable bucket versioning. Default is false
  deploymentPrefix: serverless # The S3 prefix under which deployed artifacts should be stored. Default is serverless
  disableDefaultOutputExportNames: false # optional, if set to 'true', disables default behavior of generating export names for CloudFormation outputs
  lambdaHashingVersion: 20201221 # optional, version of hashing algorithm that should be used by the framework


plugins:
  - serverless-sam
#  Resources:
#    NewResource:
#      Type: AWS::S3::Bucket
#      Properties:
#        BucketName: my-new-bucket
#  Outputs:
#     NewOutput:
#       Description: "Description for the output"
#       Value: "Some output value"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情泪▽动烟 2025-01-24 08:23:14

警告意味着deploymentBucket属性未识别,因此它没有做您认为应该做的事情。

根据“ nofollow noreferrer”> serverless declosementbucket /代码>应为提供者下的属性而不是root属性。

The warning means that the deploymentBucket property is not recognized and as such it is not doing what you think it should be doing.

According to serverless docs, deploymentBucket should be a property under provider not a root property.

永不分离 2025-01-24 08:23:14

通过将 deploymentBucket 属性移动到 provider 下而不是将其注册为根属性,我能够摆脱此警告。修改后的 serverless.yml 文件附在下面:

service: poppy-seed

provider:
  name: aws
  runtime: java11
  timeout: 30
  lambdaHashingVersion: 20201221 
  deploymentBucket:
    blockPublicAccess: true 
    skipPolicySetup: false 
    name: poppy-seed
    maxPreviousDeploymentArtifacts: 5
    versioning: false # enable bucket versioning. Default is false


package:
  artifact: build/libs/poppy-seed-dev-all.jar

functions:
  poppy-seed:
    handler: com.serverless.lambda.Handler


events:
  - http:
      path: "{proxy+}"
      method: ANY
      cors: true

plugins:
  - serverless-sam

另请阅读 无服务器文档以更加清晰。再次感谢@NoelLlevares 的提示。

I was able to get rid of this warning by moving the deploymentBucket property under provider instead of registering it as a root property. The modified serverless.yml file is attached below:

service: poppy-seed

provider:
  name: aws
  runtime: java11
  timeout: 30
  lambdaHashingVersion: 20201221 
  deploymentBucket:
    blockPublicAccess: true 
    skipPolicySetup: false 
    name: poppy-seed
    maxPreviousDeploymentArtifacts: 5
    versioning: false # enable bucket versioning. Default is false


package:
  artifact: build/libs/poppy-seed-dev-all.jar

functions:
  poppy-seed:
    handler: com.serverless.lambda.Handler


events:
  - http:
      path: "{proxy+}"
      method: ANY
      cors: true

plugins:
  - serverless-sam

Also read up the serverless documentation for more clarity. Thanks again to @NoelLlevares for the tip.

抹茶夏天i‖ 2025-01-24 08:23:14

还要尝试更新到最新版本的无服务器,但在我的情况下,一些键在旧版本中未被识别

Also try to update to latest version of serverless in my case some keys were unrecognized in old version

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文