Skip to content

Commit 99d8bb2

Browse files
committed
CI: add conditional for setting GCP firewall rules
1 parent 1591d2f commit 99d8bb2

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

ci/pipelines/stemcells-windows.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ jobs:
737737
file: bosh-windows-stemcell-builder-ci/ci/tasks/firewall-rules/configure-windows-firewall-rules.yml
738738
image: bosh-windows-stemcell-builder-ci-image
739739
params:
740+
CONFIGURE_GCP: true
740741
COMMERCIAL_AWS_ACCESS_KEY_ID: ((aws-stemcells_aws_access_key.username))
741742
COMMERCIAL_AWS_DEFAULT_REGION: ((AWS_PACKER_REGION))
742743
COMMERCIAL_AWS_ROLE_ARN: ((aws-stemcells_aws_access_key.role_arn))

ci/tasks/firewall-rules/configure-windows-firewall-rules.sh

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,22 @@
22
set -eu -o pipefail
33
set -x
44

5-
# We have firewall rules that are necessary when creating Windows stemcells in AWS and GCP.
5+
# We have firewall rules that are necessary when creating Windows stemcells in AWS and GCP (if needed).
66
# This script ensures that the concourse worker egress IPs have access on the
77
# WinRM port (5985).
8-
# Set firewall rules in the GCP project
9-
comma_separated_external_ips=""
10-
for external_ip in $ALLOWED_IP_ADDRESSES; do
11-
comma_separated_external_ips="${external_ip}/32,${comma_separated_external_ips}"
12-
done
13-
comma_separated_external_ips="${comma_separated_external_ips%,}"
8+
# Set firewall rules in the GCP project if needed
9+
if [ -n "${CONFIGURE_GCP}" ]; then
10+
comma_separated_external_ips=""
11+
for external_ip in $ALLOWED_IP_ADDRESSES; do
12+
comma_separated_external_ips="${external_ip}/32,${comma_separated_external_ips}"
13+
done
14+
comma_separated_external_ips="${comma_separated_external_ips%,}"
1415

15-
set +x
16-
echo "${WINDOWS_STEMCELLS_GCP_CREDENTIALS_JSON}" | gcloud auth activate-service-account --key-file - --project cff-bosh-windows-stemcells
17-
set -x
18-
gcloud compute firewall-rules update default-allow-winrm --project cff-bosh-windows-stemcells --source-ranges="${comma_separated_external_ips}"
16+
set +x
17+
echo "${WINDOWS_STEMCELLS_GCP_CREDENTIALS_JSON}" | gcloud auth activate-service-account --key-file - --project cff-bosh-windows-stemcells
18+
set -x
19+
gcloud compute firewall-rules update default-allow-winrm --project cff-bosh-windows-stemcells --source-ranges="${comma_separated_external_ips}"
20+
fi
1921

2022
# Set firewall rules in the AWS project
2123
aws_ip_ranges=""

ci/tasks/firewall-rules/configure-windows-firewall-rules.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ inputs:
55
- name: bosh-windows-stemcell-builder-ci
66

77
params:
8+
CONFIGURE_GCP:
89
COMMERCIAL_AWS_ACCESS_KEY_ID:
910
COMMERCIAL_AWS_DEFAULT_REGION:
1011
COMMERCIAL_AWS_ROLE_ARN:

0 commit comments

Comments
 (0)