Skip to content

Commit

Permalink
fix: conditionally create volumes
Browse files Browse the repository at this point in the history
A new volume should be created only if the `create` attribute is set to
true. This is useful when the volume is created by another module.
  • Loading branch information
alinefr committed Jun 9, 2023
1 parent 69cfd31 commit 37b6932
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ resource "docker_image" "default" {
}

resource "docker_volume" "default" {
for_each = var.named_volumes
name = each.key
for_each = {
for k, v in var.named_volumes : k => v
if lookup(v, "create", false) != false
}
name = each.key
}

resource "docker_network" "default" {
Expand Down

0 comments on commit 37b6932

Please sign in to comment.