使用s3对象的aws codepipline更新lambda函数源 [英] aws codepipline update lambda function source using s3 object

查看:86
本文介绍了使用s3对象的aws codepipline更新lambda函数源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用terraform在AWS上创建所有基础设施(CodePipeline,lambda,bucket)

I am using terraform to create all the infra(CodePipeline, lambda, buckets) on AWS

当前,我已经创建了一个构建源zip文件并将其放在s3存储桶中的管道,但是lambda仍然继续使用旧的源文件.因此,我在AWS控制台中手动更新了URL,它可以工作.现在,我想使流程自动化,但是可用的解决方案是:

currently, I've created a pipeline that builds the source zip file and puts it on s3 bucket but the lambda still keeps using the older source. So, I update the URL manually in the AWS console and it works. Now I want to automate the flow but available solutions are:

  • AWS SAM + CFT
  • Codebuild阶段以使用AWS CLI更新源
  • 创建一个lambda来更新源代码
  • 代码部署+ AWS SAM + CFT

我根本不愿意使用CFT,因为我们所有的代码都是terraform,并且CFT要求我创建新的lambda,而不是使用旧的lambda.

I am not willing to use CFT at all since all of our code is in terraform and CFT requires me to create new lambdas instead of using old ones.

还有没有其他更简单的方法可以通过Codepipeline更新lambda源

is there any other simpler way to update the lambda source through Codepipeline

推荐答案

通过CodePipeline部署Lambda的首选方法是使用CloudFormation Deploy操作[1].由于您不想使用CloudFormation,因此下一个选择是从管道的一部分CodeBuild作业中运行Terraform Plan/apply命令.您将需要提供CodeBuild角色所需的资源创建权限(或导出环境变量中的凭据以供TF通过此[2]方法使用),并在buildspec的安装阶段中安装TF二进制文件.

The preferred way to deploy a Lambda via CodePipeline is using a CloudFormation Deploy action [1]. Since you are not looking to use CloudFormation, next option could be to run your terraform plan/apply commands from within a CodeBuild job that is part of the pipeline. You will need to provide the CodeBuild role required permission for resource creation (or export the credentials in Environment variabels for TF to use via this [2] method) and install the TF binary within install phase of buildspec.

参考:

[1]使用AWS CodePipeline为Lambda应用程序构建持续交付管道- https://docs.aws.amazon.com/lambda/latest/dg/build-pipeline.html

[1] Building a Continuous Delivery Pipeline for a Lambda Application with AWS CodePipeline - https://docs.aws.amazon.com/lambda/latest/dg/build-pipeline.html

[2] 如何检索秘密buildspec.yaml中的经理数据

这篇关于使用s3对象的aws codepipline更新lambda函数源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆