From 7f1975cd440e9bfe18bfb377f6fe5539e54dd6a0 Mon Sep 17 00:00:00 2001 From: Mark Boyd Date: Wed, 15 Nov 2023 10:39:20 -0500 Subject: [PATCH 1/3] update CDN app to build zip file using terraform null_resource and archive_file --- terraform/modules/test_cdn/test_cdn.tf | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/terraform/modules/test_cdn/test_cdn.tf b/terraform/modules/test_cdn/test_cdn.tf index 71895d7b..704bf74b 100644 --- a/terraform/modules/test_cdn/test_cdn.tf +++ b/terraform/modules/test_cdn/test_cdn.tf @@ -1,5 +1,7 @@ locals { domain_name = var.iaas_stack_name == "staging" ? "fr-stage.cloud.gov" : "fr.cloud.gov" + clone_dir = "${path.module}/cf-hello-worlds" + zip_output_filepath = "${path.module}/hello-world-static.zip" } data "cloudfoundry_domain" "fr_domain" { @@ -15,9 +17,22 @@ data "cloudfoundry_space" "hello_worlds" { org = var.organization_id } -resource "zipper_file" "test_cdn_src" { - source = "https://github.com/cloud-gov/cf-hello-worlds/tree/main/static" - output_path = "test-static-app.zip" +resource "null_resource" "git_clone" { + triggers = { + on_every_apply = timestamp() + } + + provisioner "local-exec" { + command = "git clone https://github.com/cloud-gov/cf-hello-worlds.git ${local.clone_dir}" + } +} + +data "archive_file" "test_cdn_app_src" { + depends_on = [null_resource.git_clone] + + output_path = local.zip_output_filepath + source_dir = "${local.clone_dir}/static" + type = "zip" } resource "cloudfoundry_route" "test_cdn_route" { @@ -40,8 +55,8 @@ resource "cloudfoundry_app" "test-cdn" { name = "test-cdn" buildpack = "staticfile_buildpack" space = data.cloudfoundry_space.hello_worlds.id - path = zipper_file.test_cdn_src.output_path - source_code_hash = zipper_file.test_cdn_src.output_sha + path = local.zip_output_filepath + source_code_hash = data.archive_file.test_cdn_app_src.output_sha256 routes { route = cloudfoundry_route.test_cdn_route.id From 4cc03f2458bad9fbd0eb027980989a70ae1f24ea Mon Sep 17 00:00:00 2001 From: Mark Boyd Date: Wed, 15 Nov 2023 10:45:45 -0500 Subject: [PATCH 2/3] add variables for source code and zipfile information --- terraform/modules/test_cdn/test_cdn.tf | 8 ++++---- terraform/modules/test_cdn/variables.tf | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/terraform/modules/test_cdn/test_cdn.tf b/terraform/modules/test_cdn/test_cdn.tf index 704bf74b..041d1c99 100644 --- a/terraform/modules/test_cdn/test_cdn.tf +++ b/terraform/modules/test_cdn/test_cdn.tf @@ -1,7 +1,7 @@ locals { domain_name = var.iaas_stack_name == "staging" ? "fr-stage.cloud.gov" : "fr.cloud.gov" - clone_dir = "${path.module}/cf-hello-worlds" - zip_output_filepath = "${path.module}/hello-world-static.zip" + clone_dir = "${path.module}/${var.git_clone_dir}" + zip_output_filepath = "${path.module}/${var.zip_output_filename}" } data "cloudfoundry_domain" "fr_domain" { @@ -23,7 +23,7 @@ resource "null_resource" "git_clone" { } provisioner "local-exec" { - command = "git clone https://github.com/cloud-gov/cf-hello-worlds.git ${local.clone_dir}" + command = "git clone ${var.source_code_repo} ${local.clone_dir}" } } @@ -31,7 +31,7 @@ data "archive_file" "test_cdn_app_src" { depends_on = [null_resource.git_clone] output_path = local.zip_output_filepath - source_dir = "${local.clone_dir}/static" + source_dir = "${local.clone_dir}/${var.source_code_path}" type = "zip" } diff --git a/terraform/modules/test_cdn/variables.tf b/terraform/modules/test_cdn/variables.tf index fdd3e9b7..44fa35c8 100644 --- a/terraform/modules/test_cdn/variables.tf +++ b/terraform/modules/test_cdn/variables.tf @@ -11,3 +11,27 @@ variable "space_name" { description = "Space name to use for test CDN app" default = "hello-worlds" } + +variable "source_code_repo" { + type = string + description = "HTTPS link to git repo containing source code for test CDN app" + default = "https://github.com/cloud-gov/cf-hello-worlds.git" +} + +variable "source_code_path" { + type = string + description = "Path in source_code_repo containing app code" + default = "static" +} + +variable "git_clone_dir" { + type = string + description = "Subdirectory of module path to clone git repo" + default = "cf-hello-worlds" +} + +variable "zip_output_filename" { + type = string + description = "Name of zip file containing source code for test CDN app" + default = "hello-world-static.zip" +} From 8a398533a574994be600b2505222a9a63ec5b677 Mon Sep 17 00:00:00 2001 From: Mark Boyd Date: Wed, 15 Nov 2023 10:47:58 -0500 Subject: [PATCH 3/3] remove unnecessary providers --- terraform/modules/test_cdn/versions.tf | 5 ----- terraform/stack/{main.tf => apps.tf} | 1 - terraform/stack/providers.tf | 4 ---- terraform/stack/versions.tf | 5 ----- 4 files changed, 15 deletions(-) rename terraform/stack/{main.tf => apps.tf} (93%) diff --git a/terraform/modules/test_cdn/versions.tf b/terraform/modules/test_cdn/versions.tf index 83fcfd3e..0a9f8a9c 100644 --- a/terraform/modules/test_cdn/versions.tf +++ b/terraform/modules/test_cdn/versions.tf @@ -5,10 +5,5 @@ terraform { source = "cloudfoundry-community/cloudfoundry" version = "< 1.0.0" } - - zipper = { - source = "ArthurHlt/zipper" - version = "0.14.0" - } } } diff --git a/terraform/stack/main.tf b/terraform/stack/apps.tf similarity index 93% rename from terraform/stack/main.tf rename to terraform/stack/apps.tf index 192a3def..31240319 100644 --- a/terraform/stack/main.tf +++ b/terraform/stack/apps.tf @@ -6,6 +6,5 @@ module "test_cdn" { providers = { cloudfoundry = cloudfoundry - zipper = zipper } } diff --git a/terraform/stack/providers.tf b/terraform/stack/providers.tf index 5dd3d779..b912bb86 100644 --- a/terraform/stack/providers.tf +++ b/terraform/stack/providers.tf @@ -1,6 +1,2 @@ provider "cloudfoundry" { } - -provider "zipper" { - skip_ssl_validation = false -} diff --git a/terraform/stack/versions.tf b/terraform/stack/versions.tf index 54355b8a..8ba4e0a4 100644 --- a/terraform/stack/versions.tf +++ b/terraform/stack/versions.tf @@ -5,10 +5,5 @@ terraform { source = "cloudfoundry-community/cloudfoundry" version = "< 1.0.0" } - - zipper = { - source = "ArthurHlt/zipper" - version = "0.14.0" - } } }