Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating multiple Lambda Functions #121

Open
szaluk opened this issue Oct 20, 2017 · 0 comments
Open

Updating multiple Lambda Functions #121

szaluk opened this issue Oct 20, 2017 · 0 comments

Comments

@szaluk
Copy link

szaluk commented Oct 20, 2017

I am trying to write a task that can update multiple Lambda functions with the same S3File. Here is the code I am using:

def devLambdaFunctionNames = ["function1Dev", "function2Dev", "function3Dev"]
def prodLambdaFunctionNames = ["function1Prod", "function2Prod", "function3Prod"]

task updateLambdas(type: AWSLambdaUpdateFunctionCodeTask, dependsOn: uploadArtifactToS3) {
    doFirst {
        if (apiStage.equalsIgnoreCase("dev")) {
            for(String lambdaFunctionName : devLambdaFunctionNames) {
                logger.lifecycle("LAMBDA: Updating function ${lambdaFunctionName} with S3:${bucket}/${artifactName}..")

                functionName = lambdaFunctionName

                def artifact = new S3File()
                artifact.setBucketName(bucket)
                artifact.setKey(artifactName)

                s3File = artifact
            }
        } else {
            for(String lambdaFunctionName : prodLambdaFunctionNames) {
                logger.lifecycle("LAMBDA: Updating function ${lambdaFunctionName} with S3:${bucket}/${artifactName}..")

                functionName = lambdaFunctionName

                def artifact = new S3File()
                artifact.setBucketName(bucket)
                artifact.setKey(artifactName)

                s3File = artifact
            }
        }
    }
}

What seems to be happening is only the last Lambda function is the list is getting updated - either function3Dev or function3Prod depending on what apiStage is set to. How can I do this so I can iterate over a list of Lambda functions and update them in one task call?

Thanks,
Steve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant