1

I am trying to create a CI/CD pipeline for Step/Lambda functions and a REST API in an AWS SAM template. The overall architecture is as follows: We take a multi-repository approach to source control of our Lambda functions. Each Lambda function gets its own Git repo, and its own pipeline to zip up the code and push it to an S3 bucket (e.g. lambda-bucket) when a commit is pushed.

A SAM template that builds out the Step/Lambda functions and a REST API is deployed via a CodePipeline that is triggered by a PUT on the S3 bucket that holds the zipped Lambda code. It is deployed via a CloudFormation ChangeSet creation step in the CodePipeline.

The Lambda functions in the SAM template looks like this:

    myFirstLambda:
    Type: AWS::Serverless::Function
    Properties:
        FunctionName: !Sub myFirstLambda-${StackStage}
        CodeUri:
            Bucket: lambda-bucket
            Key: !Sub lambdas/myFirstLambda-${StackStage}.zip
        Handler: lambda_function.lambda_handler
        Runtime: python3.8
        AutoPublishAlias: live

The issue I am having is: when I push an update to a Lambda functions' zip in the S3 lambda-bucket, the SAM template does not see a change. When the ChangeSet is created, it fails because there is nothing new to deploy. I have tried adding in a build stage that would build, package and deploy the SAM template, with the same issue as a result.

Any thoughts or fixes for this? I appreciate any help.

1
  • A note - I am trying to avoid manually adding a new S3 object version ID to the CodeUri parameter. Commented Sep 25, 2021 at 2:16

1 Answer 1

1

Please review this page:

https://docs.aws.amazon.com/codepipeline/latest/userguide/tutorials-serverlessrepo-auto-publish.html

For the me "Step 4: Create the publish action" seems to be a different approach by just adding another step the the pipeline to publish it and not monitoring S3.

But I did not try it yet.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.