From c23a5604bec4c58650cecdfc386d6dd842b9864c Mon Sep 17 00:00:00 2001 From: Fer Gonzalez Date: Mon, 14 Apr 2025 09:05:47 -0600 Subject: [PATCH] fix(lambda_update): ignore image_uri based on a var --- main.tf | 11 +++++++++++ variables.tf | 6 ++++++ 2 files changed, 17 insertions(+) diff --git a/main.tf b/main.tf index c67f1bbb..1e9b1399 100644 --- a/main.tf +++ b/main.tf @@ -43,6 +43,17 @@ resource "aws_lambda_function" "this" { replacement_security_group_ids = var.replacement_security_group_ids skip_destroy = var.skip_destroy + /* ignore image_uri when var.ignore_image_uri is true */ + dynamic "lifecycle" { + for_each = var.ignore_image_uri ? [1] : [] + + content { + ignore_changes = [ + image_uri, + ] + } + } + /* ephemeral_storage is not supported in gov-cloud region, so it should be set to `null` */ dynamic "ephemeral_storage" { for_each = var.ephemeral_storage_size == null ? [] : [true] diff --git a/variables.tf b/variables.tf index c71f68ae..cf2442b8 100644 --- a/variables.tf +++ b/variables.tf @@ -224,6 +224,12 @@ variable "image_uri" { default = null } +variable "ignore_image_uri" { + description = "Whether to ignore changes to the function's image URI. Set to true if you manage infrastructure and code deployments separately." + type = bool + default = false +} + variable "image_config_entry_point" { description = "The ENTRYPOINT for the docker image" type = list(string)