From 2352872f8caa1dc56532534d2b9f81a4ca2b2232 Mon Sep 17 00:00:00 2001 From: Peter Deme Date: Mon, 16 Sep 2024 12:59:37 +0200 Subject: [PATCH] feat(azure): publish to community gallery (#62) Signed-off-by: peterdeme --- .github/workflows/build_gcp_azure_manual.yml | 8 +++--- .github/workflows/ci.yml | 6 ++--- azure.pkr.hcl | 27 ++++++++++++-------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build_gcp_azure_manual.yml b/.github/workflows/build_gcp_azure_manual.yml index 8746b90..30d8416 100644 --- a/.github/workflows/build_gcp_azure_manual.yml +++ b/.github/workflows/build_gcp_azure_manual.yml @@ -26,9 +26,9 @@ jobs: PKR_VAR_image_resource_group: rg-worker_images-public-westeurope PKR_VAR_packer_work_group: rg-worker_images_packer-public-westeurope PKR_VAR_gallery_resource_group: rg-worker_images-public-westeurope - PKR_VAR_gallery_name: worker_images_public - PKR_VAR_gallery_image_name: ubuntu_20_04 - PKR_VAR_gallery_replication_regions: '["westeurope"]' + PKR_VAR_gallery_name: spacelift_worker_images_public + PKR_VAR_gallery_image_name: spacelift_worker_image + PKR_VAR_gallery_replication_regions: '["westeurope", "northeurope", "northcentralus", "eastus", "eastus2", "westus2", "westus3"]' PKR_VAR_gallery_image_version: 1.0.${{ github.run_number }} steps: @@ -53,7 +53,7 @@ jobs: - name: Authenticate with GCP if: matrix.cloud == 'gcp' - uses: google-github-actions/auth@v1 + uses: google-github-actions/auth@v2 with: credentials_json: ${{ secrets.GCP_CREDENTIALS_JSON }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 416f589..e54a8ec 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,9 +33,9 @@ jobs: PKR_VAR_image_resource_group: rg-worker_images-public-westeurope PKR_VAR_packer_work_group: rg-worker_images_packer-public-westeurope PKR_VAR_gallery_resource_group: rg-worker_images-public-westeurope - PKR_VAR_gallery_name: worker_images_public - PKR_VAR_gallery_image_name: ubuntu_20_04 - PKR_VAR_gallery_replication_regions: '["westeurope"]' + PKR_VAR_gallery_name: spacelift_worker_images_public + PKR_VAR_gallery_image_name: spacelift_worker_image + PKR_VAR_gallery_replication_regions: '["westeurope", "northeurope", "northcentralus", "eastus", "eastus2", "westus2", "westus3"]' PKR_VAR_gallery_image_version: 1.0.${{ github.run_number }} steps: diff --git a/azure.pkr.hcl b/azure.pkr.hcl index 5c6a5da..3fe1a60 100644 --- a/azure.pkr.hcl +++ b/azure.pkr.hcl @@ -47,7 +47,6 @@ variable "gallery_resource_group" { variable "gallery_name" { type = string - default = null } variable "gallery_image_name" { @@ -111,15 +110,23 @@ source "azure-arm" "spacelift" { managed_image_name = var.image_name managed_image_resource_group_name = var.image_resource_group - dynamic "shared_image_gallery_destination" { - for_each = var.gallery_name != null ? [0] : [] - content { - subscription = var.subscription_id - resource_group = var.gallery_resource_group - gallery_name = var.gallery_name - image_name = var.gallery_image_name - image_version = var.gallery_image_version - replication_regions = var.gallery_replication_regions + shared_image_gallery_destination { + subscription = var.subscription_id + resource_group = var.gallery_resource_group + gallery_name = var.gallery_name + image_name = var.gallery_image_name + image_version = var.gallery_image_version + + target_region { + name = var.location + } + + dynamic target_region { + for_each = var.gallery_replication_regions + + content { + name = target_region.value + } } }