Skip to content

Commit

Permalink
Refactor downloads.tf to use a dynamic list of downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
arnol377 committed Feb 5, 2025
1 parent e53168e commit 12ef537
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
19 changes: 2 additions & 17 deletions downloads.tf
Original file line number Diff line number Diff line change
@@ -1,29 +1,14 @@
locals {
# Define a set of Morpheus binaries to be downloaded
morpheus_binaries = [
{
name = "morpheus-appliance-fips-7.0.10-1.el8.x86_64.rpm"
url = "https://downloads.morpheusdata.com/files/morpheus-appliance-fips-7.0.10-1.el8.x86_64.rpm"
path_prefix = "morpheus"
output_path = "${path.root}/downloads"
},
{
name = "morpheus-appliance-7.0.10-1.el8.x86_64.rpm"
url = "https://downloads.morpheusdata.com/files/morpheus-appliance-7.0.10-1.el8.x86_64.rpm"
path_prefix = "morpheus"
output_path = "${path.root}/downloads"
}
]

# Create a set of download configurations for each binary
downloads = concat(
local.morpheus_binaries
var.downloads
)
}

module downloader {
# Iterate over each download configuration
for_each = tomap({ for download in local.downloads : download.name => download })
for_each = tomap({ for download in local.downloads : download.name => download if download.download })
source = "HappyPathway/downloader/url"
url = each.value.url
output_path = "${each.value.output_path}/${each.key}"
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@ variable "use_rhel9_ami" {
description = "Use RHEL 9 AMI"
type = bool
default = true
}

variable downloads {
description = "List of downloads"
type = list(object({
name = string
url = optional(string, "")
path_prefix = optional(string, "")
output_path = optional(string, "./downloads")
download = optional(bool, true)
}))
default = []
}

0 comments on commit 12ef537

Please sign in to comment.