[英]Apply AWS Lambda Event configuration in Serverless to specific Lambda version?
I would like to give myself the ability to rollback the Lambda that my SQS events trigger if I ship bad code.我想让自己能够回滚 Lambda,如果我发送错误代码,我的 SQS 事件将触发该事件。
To do this, I would like my SQS event configuration in serverless.yml
to apply to a specific lambda version rather than the default $LATEST.为此,我希望 serverless.yml 中的 SQS 事件配置适用于特定的 lambda 版本
serverless.yml
而不是默认的 $LATEST。 I want to “pin” a specific version of a lambda that events trigger to.我想“固定”事件触发的 lambda 的特定版本。
Is this possible?这可能吗? Basically I'd like to be able to do something like
基本上我希望能够做类似的事情
myLambda:
handler: src/handler.myLambda
events:
- sqs:
arn: arn:my:sqs:queue
targetVersion: 12 <-- Specific Lambda Version that the event configuration applies to
batchSize: 100
maximumBatchingWindow: 30
I don't see something like this mentioned anywhere in the Serverless event docs, but this is so critical it has to exist - right?我在无服务器事件文档中的任何地方都没有看到类似的内容,但这非常重要,它必须存在——对吗?
You can create an event source mapping with lambda with SQS as the event source.您可以使用 SQS 作为事件源,使用 lambda 创建事件源映射。 From the docs:
从文档:
FunctionName
The name of the Lambda function.
FunctionName
The name of the Lambda function.
Name formats
Function name – MyFunction.
Function ARN – arn:aws:lambda:us-west-2:123456789012:function:MyFunction.
Version or Alias ARN – arn:aws:lambda:us-west-2:123456789012:function:MyFunction:PROD.
Partial ARN – 123456789012:function:MyFunction.
The length constraint applies only to the full ARN. If you specify only the function name, it's limited to 64 characters in length.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 140.
Pattern: (arn:(aws[a-zA-Z-]*)?:lambda:)?([a-z]{2}(-gov)?-[a-z]+-\d{1}:)?(\d{12}:)?(function:)?([a-zA-Z0-9-_]+)(:(\$LATEST|[a-zA-Z0-9-_]+))?
Required: Yes
link to doc: https://docs.aws.amazon.com/lambda/latest/dg/API_CreateEventSourceMapping.html文档链接: https://docs.aws.amazon.com/lambda/latest/dg/API_CreateEventSourceMapping.html
so in function name you can pin it down to a specific version所以在 function 名称中,您可以将其固定到特定版本
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.