简体   繁体   中英

aws codepipline update lambda function source using s3 object

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

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 Stage to update the source using AWS CLI
  • Create a lambda that updates the source
  • Code Deploy + AWS SAM + CFT

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.

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

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.

Ref:

[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] How to retrieve Secret Manager data in buildspec.yaml

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM