Bug: Added support for triggers in docker-build module when hash changes
IlyesDemineExtVeolia opened this issue · 4 comments
Description
Even if triggers parameters is set, docker image is always rebuild.
Terraform plan result :
# module.docker_image_lambda_actiflo_effluent_predict.docker_image.this will be created
+ resource "docker_image" "this" {
+ force_remove = false
+ id = (known after apply)
+ image_id = (known after apply)
+ keep_locally = false
+ name = "423671310539.dkr.ecr.eu-west-1.amazonaws.com/vwt-insight-actiflo-effluent-predict-dev:1.0"
+ repo_digest = (known after apply)
+ triggers = {
+ "dir_lambda" = "304b10ee4074f39e8fb3ccc5eca832dadca25bea"
+ "dir_layer" = "ffc5d2f69b1723ffb97a743f9632e922c31f9b59"
}
+ build {
+ cache_from = []
+ context = "./.."
+ dockerfile = "lambdas/actiflo_effluent/effluent/Dockerfile"
+ extra_hosts = []
+ remove = true
+ security_opt = []
+ tag = []
}
}
# module.docker_image_lambda_actiflo_effluent_predict.docker_registry_image.this must be replaced
-/+ resource "docker_registry_image" "this" {
~ id = "sha256:00b4edb112e88997f64c2d440ca76aa6d9ca27e3d0ef39117aa12877be17797e" -> (known after apply)
name = "423671310539.dkr.ecr.eu-west-1.amazonaws.com/vwt-insight-actiflo-effluent-predict-dev:1.0"
~ sha256_digest = "sha256:00b4edb112e88997f64c2d440ca76aa6d9ca27e3d0ef39117aa12877be17797e" -> (known after apply)
~ triggers = { # forces replacement
- "image_id" = "sha256:adab56e502a001ca849997c22bcbd8b2a656457ca208aedd2d3e052d3f4aab7d"
} -> (known after apply) # forces replacement
# (2 unchanged attributes hidden)
}
- ✋ I have searched the open/closed issues and my issue is not listed.
⚠️ Note
Before you submit an issue, please perform the following first:
- Remove the local
.terraform
directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!):rm -rf .terraform/
- Re-initialize the project root to pull down modules:
terraform init
- Re-attempt your terraform plan or apply and check if the issue still persists
Versions
- Module version [Required]: 6.5.0
Terraform v1.5.2
on darwin_amd64
- provider registry.terraform.io/bdwyertech/json2dynamodb v0.1.11
- provider registry.terraform.io/hashicorp/archive v2.4.0
- provider registry.terraform.io/hashicorp/aws v5.22.0
- provider registry.terraform.io/hashicorp/external v2.3.2
- provider registry.terraform.io/hashicorp/local v2.4.0
- provider registry.terraform.io/hashicorp/null v3.2.2
- provider registry.terraform.io/kreuzwerker/docker v3.0.2
Reproduction Code
module "docker_image_lambda_actiflo_effluent_predict" {
source = "terraform-aws-modules/lambda/aws//modules/docker-build"
version = "6.5.0"
create_ecr_repo = true
ecr_repo = "${local.project_name_actiflo_effluent}-predict-${var.env_name}"
image_tag = "1.0"
docker_file_path = "lambdas/actiflo_effluent/effluent/Dockerfile"
source_path = "${path.module}/.."
scan_on_push = true
triggers = { # rebuild only when one of this files changes
dir_lambda = sha1(join("", [for f in fileset("${path.module}/..", "lambdas/actiflo_effluent/effluent/*") : filesha1("${path.module}/../${f}")])),
dir_layer = sha1(join("", [for f in fileset("${path.module}/..", "layers/utils_actiflo/*") : filesha1("${path.module}/../${f}")]))
}
}
Steps to reproduce the behavior:
Expected behavior
No rebuild if files no changes
Actual behavior
Docker image is always rebuild
Terminal Output Screenshot(s)
Additional context
This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days
This issue was automatically closed because of stale in 10 days
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.