Skip to content

Support docker-build module with CI pipeline #528

@tkasuz

Description

@tkasuz

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions