From 29e90edc231be7bc9ca7900fe79e639336a20382 Mon Sep 17 00:00:00 2001 From: Dmitry Gurevich <99176494+gurevichdmitry@users.noreply.github.com> Date: Wed, 30 Oct 2024 12:25:24 +0200 Subject: [PATCH] Fix GCP Labeling in test environment workflow (#2648) --- .github/workflows/test-environment.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-environment.yml b/.github/workflows/test-environment.yml index 25ac6fe3a5..7d1abb1cc9 100644 --- a/.github/workflows/test-environment.yml +++ b/.github/workflows/test-environment.yml @@ -118,7 +118,6 @@ env: WORKING_DIR: deploy/test-environments INTEGRATIONS_SETUP_DIR: tests/integrations_setup AWS_DEFAULT_TAGS: "Key=division,Value=engineering Key=org,Value=security Key=team,Value=cloud-security-posture Key=project,Value=test-environments" - GCP_DEFAULT_TAGS: "division=engineering,org=security,team=cloud-security-posture,project=test-environments,owner=${{ github.actor }}" GCP_ZONE: "us-central1-a" AZURE_DEFAULT_TAGS: "division=engineering org=security team=cloud-security-posture project=test-environments owner=${{ github.actor }}" TF_VAR_ec_api_key: ${{ secrets.EC_API_KEY }} @@ -403,7 +402,14 @@ jobs: - name: Deploy CSPM GCP agent id: cspm-gcp-agent working-directory: deploy/deployment-manager + env: + ACTOR: ${{ github.actor }} run: | + # GCP labeling rules: + # Only hyphens (-), underscores (_), lowercase characters, and numbers are allowed. International characters are allowed. + # Convert github.actor to lowercase, replace disallowed characters + GCP_LABEL=$(echo "$ACTOR" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_-]/_/g') + GCP_DEFAULT_TAGS="division=engineering,org=security,team=cloud-security-posture,project=test-environments,owner=$GCP_LABEL" . ./set_env.sh && ./deploy.sh && gcloud compute instances update "${DEPLOYMENT_NAME}" --update-labels "${GCP_DEFAULT_TAGS}" --zone="${GCP_ZONE}" - name: Install CSPM Azure integration