- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Sam Deploy 错误提示“需要 DefinitionBody 或 DefinitionUri 的值”。
以下是使用的完整 sam 模板:
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: >
try
Sample SAM Template for try
# More info about Globals: https://github.com/awslabs/serverless-application-model/blob/master/docs/globals.rst
Globals:
Function:
Timeout: 3
Tracing: Active
Api:
TracingEnabled: true
Resources:
ApiGatewayApi:
Type: AWS::Serverless::Api
Properties:
StageName: Prod
CreateFunction:
Type: AWS::Serverless::Function # More info about Function Resource: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#awsserverlessfunction
Properties:
CodeUri: ./create
Handler: app.lambdaHandler
Runtime: nodejs18.x
Architectures:
- x86_64
Events:
CreateItem:
Type: Api # More info about API Event Source: https://github.com/awslabs/serverless-application-model/blob/master/versions/2016-10-31.md#api
Properties:
RestApiId: !Ref ApiGatewayApi
Path: /create
Method: post
Environment:
Variables:
DBTable: !Ref myDynamoDBTable
Policies:
- DynamoDBWritePolicy:
TableName: !Ref myDynamoDBTable
GetFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./get
Handler: app.lambdaHandler
Runtime: nodejs18.x
Architectures:
- x86_64
Events:
CreateItem:
Type: Api
Properties:
RestApiId: !Ref ApiGatewayApi
Path: get
Method: get
GetAllFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./getAll
Handler: app.lambdaHandler
Runtime: nodejs18.x
Architectures:
- x86_64
Events:
CreateItem:
Type: Api
Properties:
RestApiId: !Ref ApiGatewayApi
Path: /getAll
Method: get
UpdateFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./update
Handler: app.lambdaHandler
Runtime: nodejs18.x
Architectures:
- x86_64
Events:
CreateItem:
Type: Api
Properties:
RestApiId: !Ref ApiGatewayApi
Path: /update
Method: put
Environment:
Variables:
DBTable: !Ref myDynamoDBTable
Policies:
- DynamoDBWritePolicy:
TableName: !Ref myDynamoDBTable
DeleteFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: ./delete
Handler: app.lambdaHandler
Runtime: nodejs18.x
Architectures:
- x86_64
Events:
CreateItem:
Type: Api
Properties:
RestApiId: !Ref ApiGatewayApi
Path: /delete
Method: delete
myDynamoDBTable:
Type: AWS::DynamoDB::Table
Properties:
AttributeDefinitions:
-
AttributeName: "user_id"
AttributeType: "S"
-
AttributeName: "timestamp"
AttributeType: "S"
KeySchema:
-
AttributeName: "user_id"
KeyType: "HASH"
-
AttributeName: "timestamp"
KeyType: "RANGE"
ProvisionedThroughput:
ReadCapacityUnits: "5"
WriteCapacityUnits: "5"
TableName: "dynamoDBTable"
ApplicationResourceGroup:
Type: AWS::ResourceGroups::Group
Properties:
Name:
Fn::Join:
- ''
- - ApplicationInsights-SAM-
- Ref: AWS::StackName
ResourceQuery:
Type: CLOUDFORMATION_STACK_1_0
ApplicationInsightsMonitoring:
Type: AWS::ApplicationInsights::Application
Properties:
ResourceGroupName:
Fn::Join:
- ''
- - ApplicationInsights-SAM-
- Ref: AWS::StackName
AutoConfigurationEnabled: 'true'
DependsOn: ApplicationResourceGroup
Outputs:
# ServerlessRestApi is an implicit API created out of Events key under Serverless::Function
# Find out more about other implicit resources you can reference within SAM
# https://github.com/awslabs/serverless-application-model/blob/master/docs/internals/generated_resources.rst#api
Api:
Description: API Gateway endpoint URL for Prod stage for Create function
Value: !Sub "https://${ApiGatewayApi}.execute-api.${AWS::Region}.amazonaws.com/Prod"
CreateFunction:
Description: Create Lambda Function ARN
Value: !GetAtt CreateFunction.Arn
CreateFunctionIamRole:
Description: Implicit IAM Role created for Create function
Value: !GetAtt CreateFunctionRole.Arn
UpdateFunction:
Description: Update Lambda Function ARN
Value: !GetAtt UpdateFunction.Arn
UpdateFunctionIamRole:
Description: Implicit IAM Role created for Update function
Value: !GetAtt UpdateFunctionRole.Arn
GetFunctionIamRole:
Description: Implicit IAM Role created for Get function
Value: !GetAtt GetFunctionRole.Arn
GetFunction:
Description: Get Lambda Function ARN
Value: !GetAtt GetFunction.Arn
GetAllFunctionIamRole:
Description: Implicit IAM Role created for GetAll function
Value: !GetAtt GetAllFunctionRole.Arn
GetAllFunction:
Description: GetAll Lambda Function ARN
Value: !GetAtt GetAllFunction.Arn
DeleteFunctionIamRole:
Description: Implicit IAM Role created for Delete function
Value: !GetAtt DeleteFunctionRole.Arn
DeleteFunction:
Description: Delete Lambda Function ARN
Value: !GetAtt DeleteFunction.Arn
DynamoDB:
Description: DynamoDB Table Name
Value: !Ref myDynamoDBTable
完整错误引用:
Error: Require value for either DefinitionBody or DefinitionUri
Traceback:
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1055, in main
rv = self.invoke(ctx)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\cli_validation\image_repository_validation.py", line 92, in wrapped
return func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metric.py", line 183, in wrapped
raise exception # pylint: disable=raising-bad-type
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\telemetry\metric.py", line 148, in wrapped
return_value = func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\lib\utils\version_checker.py", line 42, in wrapped
actual_result = func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\cli\main.py", line 92, in wrapper
return func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\_utils\cdk_support_decorators.py", line 39, in wrapped
return func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\_utils\command_exception_handler.py", line 93, in wrapper_command_exception_handler
raise ex
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\_utils\command_exception_handler.py", line 73, in wrapper_command_exception_handler
return func(*args, **kwargs)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\deploy\command.py", line 194, in cli
do_cli(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\deploy\command.py", line 286, in do_cli
guided_context.run()
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\deploy\guided_context.py", line 558, in run
self.guided_prompts(_parameter_override_keys)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\deploy\guided_context.py", line 161, in guided_prompts
self.prompt_authorization(stacks)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\deploy\guided_context.py", line 205, in prompt_authorization
auth_required_per_resource = auth_per_resource(stacks)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\deploy\auth_utils.py", line 39, in auth_per_resource
_auth_resource_event(sam_function_provider, sam_function, _auth_per_resource)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\deploy\auth_utils.py", line 73, in _auth_resource_event
elif _auth_id(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\deploy\auth_utils.py", line 107, in _auth_id
_auth_definition_body_and_uri(
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\deploy\auth_utils.py", line 133, in _auth_definition_body_and_uri
reader = SwaggerReader(definition_body=definition_body, definition_uri=definition_uri)
File "C:\Program Files\Amazon\AWSSAMCLI\runtime\lib\site-packages\samcli\commands\local\lib\swagger\reader.py", line 91, in __init__
raise ValueError("Require value for either DefinitionBody or DefinitionUri")
我认为一个问题可能是 lambda 函数资源的 codeUri,但处理程序的路径似乎是正确的。我怀疑的另一个问题是没有为 openapi 资源指定 swagger.yaml,但我在其他地方看到过具有一个 api 网关和多个类似格式的 lambda 资源的 sam 模板。非常感谢任何帮助!
最佳答案
问题是我在更新模板文件后忘记再次sam build
。.aws-sam/build 目录
中 template.yaml 中的 lambda 函数资源的 CodeUri 仍然不正确。更新 template.yaml 后使用 sam build -> sam deploy
解决了问题。
关于amazon-web-services - Sam部署错误: Require value for either DefinitionBody or DefinitionUri,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75780164/
我的代码目前是这样工作的 DefinitionBody: 'Fn::Transform': Name: AWS::Include Parameters: Locatio
Sam Deploy 错误提示“需要 DefinitionBody 或 DefinitionUri 的值”。 以下是使用的完整 sam 模板: AWSTemplateFormatVersion: '2
我有一个 OpenAPI 3.0.1 文件,符合标准,它包含一些端点响应示例。现在,由于响应中的某些参数被设置为可为空,因此有一些示例如下所示: examples: account_not_ver
我是一名优秀的程序员,十分优秀!