Open Fjandin opened 4 years ago
You can add use ignore_changes to ignore changes to the code in terraform. Something like this:
lifecycle {
ignore_changes = [filename, source_code_hash]
}
Unfortunately, since neither lifecycle nor ignore_changes can be dynamic or depend on variables, it is impossible to have a module which works both for lambdas where you want to manage the code alongside terraform, and lambdas where the code is managed externally. See https://github.com/hashicorp/terraform/issues/24188
So for example I currently have two modules that are completely identical, except that one has this ignore_changes line, and the other doesn't.
But you do still have to provide some minimal code for the initial creation of the lambda. :frowning_face:
I see this has the upstream
tag. And it would be nice if the AWS API allowed you to create a lambda without any code initially, maybe automatically adding minimal code, similar to what happens when you create a new Lambda from the console.
But this also could be done by terraform by having a mechanism where it creates a minimal zip file for the specified runtime, even just a zip with an empty file would probably work for most runtimes.
Community Note
Description
Sorry if this question has been asked before We have a pipeline where we deploy lambda code via aws cli and would like to keep everything else on terraform. However currently it is not possible to perform terraform updates on a lambda with
aws_lambda_function
without providing code. Would be super nice if i could perform architectural changes to a lambda without having to provide filename or source_code_hashNew or Affected Resource(s)
Potential Terraform Configuration
References