mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-12-04 00:56:43 +09:00
## Summary - Adds VPC Serverless Connector so Cloud Run can reach flacfetch via internal IP - Fixes E2E prod test failures after PR #289 restricted flacfetch firewall to Cloudflare IPs only - Updates `flacfetch-api-url` secret to use internal IP (10.128.0.41) ## Changes | File | Change | |------|--------| | `infrastructure/modules/networking.py` | New module with VPC connector | | `infrastructure/modules/secrets.py` | Added internal URL secret version function | | `infrastructure/modules/__init__.py` | Export networking module | | `infrastructure/__main__.py` | Wire up VPC connector + secret version | | `.github/workflows/ci.yml` | Add `--vpc-connector` flags to deploy | ## Test plan - [x] `pulumi preview` shows 3 new resources - [x] `pulumi up` deployed successfully - [x] Verified `flacfetch-api-url` secret contains internal IP - [x] Updated Cloud Run with VPC connector - [x] Tested audio search API - returns results successfully @coderabbitai ignore 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
"""
|
|
Networking resources for serverless VPC access.
|
|
|
|
Manages VPC connectors that allow Cloud Run to access internal VPC resources
|
|
like the flacfetch VM via its internal IP address.
|
|
"""
|
|
|
|
import pulumi
|
|
import pulumi_gcp as gcp
|
|
from pulumi_gcp import vpcaccess
|
|
|
|
from config import PROJECT_ID, REGION
|
|
|
|
|
|
def enable_vpc_access_api() -> gcp.projects.Service:
|
|
"""Enable the Serverless VPC Access API."""
|
|
return gcp.projects.Service(
|
|
"enable-vpcaccess-api",
|
|
service="vpcaccess.googleapis.com",
|
|
project=PROJECT_ID,
|
|
disable_on_destroy=False,
|
|
)
|
|
|
|
|
|
def create_vpc_connector(
|
|
api_service: gcp.projects.Service,
|
|
) -> vpcaccess.Connector:
|
|
"""
|
|
Create VPC connector for Cloud Run to access internal resources.
|
|
|
|
Uses 10.8.0.0/28 which doesn't overlap with default subnet (10.128.0.0/20).
|
|
This allows Cloud Run to reach VMs like flacfetch via their internal IPs,
|
|
bypassing external firewall rules.
|
|
|
|
Args:
|
|
api_service: The VPC Access API service (ensures API is enabled first).
|
|
|
|
Returns:
|
|
vpcaccess.Connector: The VPC connector resource.
|
|
"""
|
|
return vpcaccess.Connector(
|
|
"cloud-run-vpc-connector",
|
|
name="cloud-run-connector",
|
|
region=REGION,
|
|
network="default",
|
|
ip_cidr_range="10.8.0.0/28",
|
|
min_instances=2,
|
|
max_instances=3,
|
|
machine_type="e2-micro",
|
|
opts=pulumi.ResourceOptions(depends_on=[api_service]),
|
|
)
|