编辑过的
在尝试将我的应用程序部署到AWS之后,我从Serverless框架中获得了这些错误
环境信息
操作系统: Windows 64
备用节点版本: 12.22.6(14.17.3,也是因为我正在使用NVM)
框架版本: 2.60.0
插件版本: 5.4.4
SDK版本: 4.3.0
组件版本: 3.17.1
复制错误的步骤
npm i -g serverlessserverless deploy --verbose --aws-account default简而言之,这些是剩下的错误:
控制台
Serverless Warning --------------------------------------
CLI options definitions were upgraded with "type" property (which could be one of "string", "boolean", "multiple"). Below listed plugins do not predefine type for introduced options:
- ServerlessWebpack for "out"
Please report this issue in plugin issue tracker.
Serverless: Using configuration:
{
"webpackConfig": "webpack.config.js",
"includeModules": false,
"packager": "npm",
"packagerOptions": {}
}
Serverless: Removing C:\Users\ouss\Desktop\contrib\serverless_todo_app\backend\.webpack
Serverless: Bundling with Webpack...
(node:9148) [DEP_WEBPACK_MODULE_ERRORS] DeprecationWarning: Module.errors was removed (use getErrors instead)
asset src/lambda/http/getTodo.js 4.6 MiB [emitted] [minimized] (name: src/lambda/http/getTodo) 2 related assets
asset src/lambda/http/generateUploadUrl.js 4.42 MiB [emitted] [minimized] (name: src/lambda/http/generateUploadUrl) 2 related assets
asset src/lambda/http/updateTodo.js 4.42 MiB [emitted] [minimized] (name: src/lambda/http/updateTodo) 2 related assets
asset src/lambda/http/deleteTodo.js 4.42 MiB [emitted] [minimized] (name: src/lambda/http/deleteTodo) 2 related assets
asset src/lambda/http/createTodo.js 4.42 MiB [emitted] [minimized] (name: src/lambda/http/createTodo) 2 related assets
asset src/lambda/http/getTodos.js 4.42 MiB [emitted] [minimized] (name: src/lambda/http/getTodos) 2 related assets
asset src/lambda/auth/auth0Authorizer.js 296 KiB [emitted] [minimized] (name: src/lambda/auth/auth0Authorizer) 1 related asset
runtime modules 5.68 KiB 29 modules
orphan modules 5.96 KiB [orphan] 6 modules
javascript modules 3.21 MiB
modules by path ./node_modules/ 3.17 MiB
cacheable modules 3.17 MiB 848 modules
6 modules
modules by path ./src/lambda/ 38.4 KiB 7 modules
json modules 3.14 MiB
modules by path ./node_modules/aws-sdk/apis/*.json 3.12 MiB 403 modules
modules by path ./node_modules/aws-xray-sdk-core/ 12.8 KiB 3 modules
modules by path ./node_modules/ajv/lib/ 3.11 KiB
./node_modules/ajv/lib/refs/json-schema-draft-07.json 2.72 KiB [built] [code generated]
./node_modules/ajv/lib/refs/data.json 407 bytes [built] [code generated]
4 modules
WARNING in ./node_modules/aws-xray-sdk-core/lib/patchers/call_capturer.js 41:32-47
Critical dependency: the request of a dependency is an expression
@ ./node_modules/aws-xray-sdk-core/lib/segments/attributes/aws.js 1:19-61
@ ./node_modules/aws-xray-sdk-core/lib/aws-xray.js 77:19-71 86:22-77
@ ./node_modules/aws-xray-sdk-core/lib/index.js 2:0-38
@ ./node_modules/aws-xray-sdk/lib/index.js 2:14-42
@ ./src/helpers/attachmentUtils.ts 2:0-40 3:13-31
@ ./src/lambda/http/generateUploadUrl.ts 4:0-61 11:22-34
WARNING in ./node_modules/aws-xray-sdk-core/node_modules/colors/lib/colors.js 127:29-43
Critical dependency: the request of a dependency is an expression
@ ./node_modules/aws-xray-sdk-core/node_modules/colors/safe.js 8:13-36
@ ./node_modules/aws-xray-sdk-core/node_modules/winston/lib/winston/config.js 9:13-35
@ ./node_modules/aws-xray-sdk-core/node_modules/winston/lib/winston.js 29:25-52
@ ./node_modules/aws-xray-sdk-core/lib/logger.js 1:14-32
@ ./node_modules/aws-xray-sdk-core/lib/aws-xray.js 2:14-33
@ ./node_modules/aws-xray-sdk-core/lib/index.js 2:0-38
@ ./node_modules/aws-xray-sdk/lib/index.js 2:14-42
@ ./src/helpers/attachmentUtils.ts 2:0-40 3:13-31
@ ./src/lambda/http/generateUploadUrl.ts 4:0-61 11:22-34
2 warnings have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
webpack compiled with 2 warnings in 114413 ms
Serverless: Zip service: C:\Users\ouss\Desktop\contrib\serverless_todo_app\backend\.webpack\service [6555 ms]
Serverless: Packaging service...
Serverless: Remove C:\Users\ouss\Desktop\contrib\serverless_todo_app\backend\.webpack
Serverless: Installing dependencies for custom CloudFormation resources...
Serverless: Tracing DISABLED for function "serverless-todo-app-dev-Auth"
Serverless: Tracing DISABLED for function "serverless-todo-app-dev-GetTodos"
Serverless: Tracing DISABLED for function "serverless-todo-app-dev-GetTodo"
Serverless: Tracing DISABLED for function "serverless-todo-app-dev-CreateTodo"
Serverless: Tracing DISABLED for function "serverless-todo-app-dev-UpdateTodo"
Serverless: Tracing DISABLED for function "serverless-todo-app-dev-DeleteTodo"
Serverless: Tracing DISABLED for function "serverless-todo-app-dev-GenerateUploadUrl"
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service serverless-todo-app.zip file to S3 (13.55 MB)...
Serverless: Uploading custom CloudFormation resources...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Publishing service to the Serverless Dashboard...
Serverless: Successfully published your service to the Serverless Dashboard: https://app.serverless.com/oussamabouchikhi/apps/serverless-todo-app/serverless-todo-app/dev/us-east-1
Serverless Error ----------------------------------------
Stack:arn:aws:cloudformation:us-east-1:515681156515:stack/serverless-todo-app-dev/6fc5b880-2128-11ec-b839-0e6d2682b977 is in DELETE_FAILED state and can not be updated.
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: win32
Node Version: 12.22.6
Framework Version: 2.60.0
Plugin Version: 5.4.4
SDK Version: 4.3.0
Components Version: 3.17.1
Serverless: Deprecation warning: Starting with next major version, "http.request.schema" property will be replaced by "http.request.schemas".
More Info: https://www.serverless.com/framework/docs/deprecations/#AWS_API_GATEWAY_SCHEMASserverless.yaml
org: oussamabouchikhi
app: serverless-todo-app
service: serverless-todo-app
plugins:
- serverless-webpack
- serverless-iam-roles-per-function
- serverless-plugin-tracing
provider:
name: aws
runtime: nodejs12.x
lambdaHashingVersion: '20201221'
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-east-1'}
tracing:
lambda: true
apiGateway: true
# Use these variables in the functions and resouorces section below. For example,
# ${self:provider.environment.ATTACHMENT_S3_BUCKET}
environment:
TODOS_TABLE: Todos-${self:provider.stage}
TODOS_CREATED_AT_INDEX: CreatedAtIndex
ATTACHMENTS_S3_BUCKET: serverless-c4-todo-images-${self:provider.stage}
SIGNED_URL_EXPIRATION: 300
logs:
# Enable API Gateway logs
restApi: true
iam:
role:
statements:
- Effect: Allow
Action:
- xray:PutTelemetryRecords
- xray:PutTraceSegments
Resource: '*'
functions:
Auth:
handler: src/lambda/auth/auth0Authorizer.handler
# Provide iamRoleStatements property for performing Actions on DynamoDB
GetTodos:
handler: src/lambda/http/getTodos.handler
events:
- http:
method: get
path: todos
cors: true
authorizer: Auth
iamRoleStatements:
- Effect: Allow
Action:
- s3:GetObject
Resource: arn:aws:s3:::${self:provider.environment.ATTACHMENTS_S3_BUCKET}/*
- Effect: Allow
Action:
- dynamodb:Query
Resource: arn:aws:dynamodb:${self:provider.region}:*:table/${self:provider.environment.TODOS_TABLE}
GetTodo:
handler: src/lambda/http/getTodo.handler
events:
- http:
method: get
path: todos/{todoId}
cors: true
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
Resource: arn:aws:dynamodb:${self:provider.region}:*:table/${self:provider.environment.TODOS_TABLE}
# Provide iamRoleStatements property. Decide the Actions and AWS Resource.
# To refer to an AWS resource defined in the "Resources" section, you can use "Resource: !GetAtt <resource-name>.Arn"
# To validate incoming HTTP requests, we have provided the request schemas in function definition below.
CreateTodo:
handler: src/lambda/http/createTodo.handler
events:
- http:
method: post
path: todos
cors: true
authorizer: Auth
request:
schemas:
application/json: ${file(models/create-todo-model.json)}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:PutItem
Resource: arn:aws:dynamodb:${self:provider.region}:*:table/${self:provider.environment.TODOS_TABLE}
# Provide property for setting up CORS, Authorizer, iamRoleStatements, and request schemas
UpdateTodo:
handler: src/lambda/http/updateTodo.handler
events:
- http:
method: patch
path: todos/{todoId}
cors: true
authorizer: Auth
request:
schema:
application/json: ${file(models/update-todo-model.json)}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:UpdateItem
- dynamodb:Query
Resource: arn:aws:dynamodb:${self:provider.region}:*:table/${self:provider.environment.TODOS_TABLE}
# Provide property for setting up CORS, Authorizer, iamRoleStatements
DeleteTodo:
handler: src/lambda/http/deleteTodo.handler
events:
- http:
method: delete
path: todos/{todoId}
cors: true
authorizer: Auth
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:DeleteItem
- dynamodb:Query
Resource: arn:aws:dynamodb:${self:provider.region}:*:table/${self:provider.environment.TODOS_TABLE}
# Provide property for setting up CORS, Authorizer, iamRoleStatements
GenerateUploadUrl:
handler: src/lambda/http/generateUploadUrl.handler
events:
- http:
method: post
path: todos/{todoId}/attachment
cors: true
authorizer: Auth
iamRoleStatements:
- Effect: Allow
Action:
- s3:PutObject
- s3:GetObject
Resource: arn:aws:s3:::${self:provider.environment.ATTACHMENTS_S3_BUCKET}/*
- Effect: Allow
Action:
- dynamodb:UpdateItem
- dynamodb:Query
Resource: arn:aws:dynamodb:${self:provider.region}:*:table/${self:provider.environment.TODOS_TABLE}
resources:
Resources:
# Add necessary AWS resources. You will need at least the following AWS resources
GatewayResponseDefault4XX:
Type: AWS::ApiGateway::GatewayResponse
Properties:
ResponseParameters:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
gatewayresponse.header.Access-Control-Allow-Methods: "'GET,OPTIONS,POST'"
ResponseType: DEFAULT_4XX
RestApiId:
Ref: ApiGatewayRestApi
# Create a DynamoDB table with local secondary index and a composite key
TodosTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
- AttributeName: userId
AttributeType: S
- AttributeName: todoId
AttributeType: S
KeySchema:
- AttributeName: userId
KeyType: HASH
- AttributeName: todoId
KeyType: RANGE
BillingMode: PAY_PER_REQUEST
TableName: ${self:provider.environment.TODOS_TABLE}
AttachmentsBucket:
Type: AWS::S3::Bucket
Properties:
BucketName: ${self:provider.environment.ATTACHMENTS_S3_BUCKET}
CorsConfiguration:
CorsRules:
- AllowedOrigins:
- '*'
AllowedHeaders:
- '*'
AllowedMethods:
- GET
- PUT
- POST
- DELETE
- HEAD
MaxAge: 3000
# Complete the policy below and attach it to the bucket defined above
# For cross referencing the name of the bucket, use "!Ref AttachmentsBucket"
BucketPolicy:
Type: AWS::S3::BucketPolicy
Properties:
PolicyDocument:
Id: MyPolicy
Version: '2012-10-17'
Statement:
- Sid: PublicReadForGetBucketObjects
Effect: Allow
Principal: '*'
Action: 's3:GetObject'
Resource: 'arn:aws:s3:::${self:provider.environment.ATTACHMENTS_S3_BUCKET}/*'
Bucket: !Ref AttachmentsBucket发布于 2021-09-30 15:52:19
在声明为CloudFormation的API响应资源中,您错误地缩进了ResponseType属性。它应该在Properties块中。
错误是:The CloudFormation template is invalid: Invalid template resource property 'ResponseType',它给了我小费。
这应该是可行的:
resources:
Resources:
# Add necessary AWS resources. You will need at least the following AWS resources
GatewayResponseDefault4XX:
Type: AWS::ApiGateway::GatewayResponse
Properties:
gatewayresponse.header.Access-Control-Allow-Origin: "'*'"
gatewayresponse.header.Access-Control-Allow-Headers: "'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token'"
gatewayresponse.header.Access-Control-Allow-Methods: "'GET,OPTIONS,POST'"
ResponseType: DEFAULT_4XX
RestApiId:
Ref: ApiGatewayRestApi您可以查看此这里的其余文档。
发布于 2022-01-26 11:24:53
实际错误是:
<yourLambdaARN> is in DELETE_FAILED state and can not be updated.这意味着您尝试删除您的lambda函数或整个应用程序,它在某个时候失败了,也许您有一个非空的桶或类似的东西,您可以在控制台的CloudFormation部分搜索这个lambda的DELETE_FAILED事件,它会告诉您出了什么问题。
如果应用程序处于这种状态,Serverless将不会进行部署,因此您别无选择,只能找到导致其失败的原因。一旦您解决了它,您将能够重新部署。
https://stackoverflow.com/questions/69393069
复制相似问题