terraform-aws-modules / terraform-aws-lambda

Terraform module, which takes care of a lot of AWS Lambda/serverless tasks (build dependencies, packages, updates, deployments) in countless combinations πŸ‡ΊπŸ‡¦
https://registry.terraform.io/modules/terraform-aws-modules/lambda/aws
Apache License 2.0
886 stars 656 forks source link

Support `docker-build` module with CI pipeline #528

Closed tkasuz closed 5 months ago

tkasuz commented 5 months ago

Is your request related to a problem? Please describe.

I've been trying to use docker-build submodule to build a container image in GitHub Actions, and deploy it with CodeDeploy using deploy module but docker_image resource which will be automatically created by docker-build module will be forcibly replaced every time when CI pipeline get triggered withtout changing any code because docker_image refaers to local image, and so the local iamge will be reseted every CI process.

Describe the solution you'd like.

To avoid the avobe behavior, It would be better to have an option to specify whether local docker image is stored on local or not by using ignore_changes of terraform lifecycle. Since ignore_changes doesn't support dynamic paramter on it currently, I think one of the workaround to implement this is like the following:

resource "docker_image" "this" {
  count = var. store_on_local == true ? 1 : 0
  name = local.ecr_image_name
  triggers     = var.triggers
  lifecycle {
    ignore_changes = [id, image_id]
  }
}

resource "docker_image_with_ci" "this" {
  count = var. store_on_local == true ? 0 : 1
  name = local.ecr_image_name
  triggers     = var.triggers
  lifecycle {
    ignore_changes = [id, image_id]
  }
}

If there is another workaround for this problem, or I misunderstand something, please correct me. Thanks!

IlyesDemineExtVeolia commented 5 months ago

@tkasuz I think is the same issue : https://github.com/terraform-aws-modules/terraform-aws-lambda/issues/517

IlyesDemineExtVeolia commented 5 months ago

I created a pull request https://github.com/terraform-aws-modules/terraform-aws-lambda/pull/518 but no response from the reviewer

antonbabenko commented 5 months ago

Fixed in https://github.com/terraform-aws-modules/terraform-aws-lambda/pull/518 by @IlyesDemineExtVeolia

tkasuz commented 5 months ago

@IlyesDemineExtVeolia Thanks! I've checked out if your changes don't trigger to replace docker_image resource but docker_image resource seems to still has problem that I mentioned here while docker_registry_image will be updated properly based on the new trigger you changed though πŸ€”

github-actions[bot] commented 4 months ago

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.