如何在cloudformation yml中获取最新的lambda版本? [英] How to get the latest lambda version in cloudformation yml?
问题描述
I'm trying to reference an edge lambda for cloudfront distribution in cloudformation.
我现在拥有的是:
LambdaFunctionARN:
Fn::GetAtt: [BasicAuthLambdaFunction,Arn]
但是我得到这个错误:
发生错误:GGGCloudFrontDistribution-该函数ARN必须引用特定的功能版本.(ARN必须以版本号.)
An error occurred: GGGCloudFrontDistribution - The function ARN must reference a specific function version. (The ARN must end with the version number.)
那么..是否有某种技术可以引用该函数的最新版本?
So.. is there some kind of technique to reference the latest version of the function?
推荐答案
您不能使用最新版本.您必须使用特定版本作为链接的文档:
You can't use the latest version. You have to use a specific version as the documentation you linked states:
您必须指定功能版本的ARN;您不能指定Lambda别名或$ LATEST.
You must specify the ARN of a function version; you can't specify a Lambda alias or $LATEST.
如果要在模板中创建Lambda函数,则还可以创建一个版本并使用该版本.
If you are creating the Lambda function in your template, you can also create a version and use that.
BasicAuthLambdaFunctionVersion:
Type: "AWS::Lambda::Version"
Properties:
FunctionName:
Ref: BasicAuthLambdaFunction
# ...
LambdaFunctionARN:
Fn::GetAtt: [BasicAuthLambdaFunctionVersion,Arn]
请注意,更新堆栈时,Lambda函数代码更改时将不会创建新版本.您必须通过将 BasicAuthLambdaFunctionVersion
的名称更改为 BasicAuthLambdaFunctionVersion2
或其他名称来手动创建和使用新版本.要自动执行此操作,您可以在使用模板之前使用脚本对其进行编辑.
Note that when updating the stack, a new version will not be created when the Lambda function code changes. You have to manually create and use a new version by changing the name of BasicAuthLambdaFunctionVersion
to BasicAuthLambdaFunctionVersion2
or something else. To automate this, you can edit the template with a script before using it.
如果您使用的是无服务器框架,请查看:
If you are using the Serverless Framework, take a look at:
https://github.com/silvermine/serverless-plugin-cloudfront-拉姆达边缘 https://github.com/serverless/serverless/issues/3944
这篇关于如何在cloudformation yml中获取最新的lambda版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!