@@ -176,13 +176,39 @@ jobs:
176176 echo "Please configure the WireGuard configuration secret for this branch/environment"
177177 exit 1
178178 fi
179- echo "${{ secrets.TF_WG_CONFIG }}" | sudo tee /etc/wireguard/wg0.conf
180- # Verify config file is not empty
179+
180+ # Debug: Check if secret is available (without exposing content)
181+ echo "🔍 Checking TF_WG_CONFIG secret..."
182+ if [ ${#TF_WG_CONFIG} -eq 0 ]; then
183+ echo "❌ ERROR: TF_WG_CONFIG environment variable is empty"
184+ echo "Secret may contain only whitespace or special characters"
185+ exit 1
186+ fi
187+ echo "✅ Secret length: ${#TF_WG_CONFIG} characters"
188+
189+ # Create config file with proper handling of multiline content
190+ sudo mkdir -p /etc/wireguard
191+ echo "$TF_WG_CONFIG" | sudo tee /etc/wireguard/wg0.conf > /dev/null
192+
193+ # Verify config file is not empty and has expected content
181194 if [ ! -s /etc/wireguard/wg0.conf ]; then
182- echo "❌ ERROR: WireGuard config file is empty!"
195+ echo "❌ ERROR: WireGuard config file is empty after writing!"
196+ echo "This usually means the secret contains only whitespace or invalid characters"
183197 exit 1
184198 fi
199+
200+ # Basic validation that it looks like a WireGuard config
201+ if ! grep -q "\[Interface\]" /etc/wireguard/wg0.conf; then
202+ echo "❌ ERROR: WireGuard config doesn't contain [Interface] section"
203+ echo "Please check that TF_WG_CONFIG contains a valid WireGuard configuration"
204+ echo "Config file size: $(wc -c < /etc/wireguard/wg0.conf) bytes"
205+ exit 1
206+ fi
207+
185208 echo "✅ WireGuard configuration applied successfully"
209+ echo "Config file size: $(wc -c < /etc/wireguard/wg0.conf) bytes"
210+ env :
211+ TF_WG_CONFIG : ${{ secrets.TF_WG_CONFIG }}
186212 if : " ${{ inputs.TERRAFORM_COMPONENT != 'base-infra' }}"
187213
188214 - name : Start WireGuard
0 commit comments