Closed vizero1 closed 1 week ago
Found the fix: In the newer version of the pulumi gcp plugin you can use following flag: update_on_creation_fail=True, WIth that it will create it without aborting. Also add following other flag if you get an error during pulumi destroy: deletion_policy="ABANDON"
My code is now:
def create_private_service_connection(network_id, stack_name):
"""
Creates a private service connection to allow VPC access to Google services (e.g., Cloud SQL).
Args:
name (str): The name of the private service connection.
network_id (str): The ID of the VPC network.
stack_name (str): The current stack name for resource naming.
Returns:
tuple: The allocated IP range and private service connection.
"""
ip_range = compute.GlobalAddress(
f'{stack_name}-vpc-private-service-ip-range',
name=f'{stack_name}-vpc-private-service-ip-range',
purpose='VPC_PEERING',
address_type='INTERNAL',
prefix_length=16,
network=network_id,
)
private_service_connection = servicenetworking.Connection(
f'{stack_name}-vpc-psc',
network=network_id,
service='servicenetworking.googleapis.com',
reserved_peering_ranges=[ip_range.name],
update_on_creation_fail=True,
deletion_policy="ABANDON",
opts=pulumi.ResourceOptions(ignore_changes=["reserved_peering_ranges"])
)
return ip_range, private_service_connection
Glad you figured it out @vizero1! Thanks for also posting your solution here for the next person to find!
Describe what happened
Try to create with pulumi gcp a vpc with private service connection. Getting the below error. Also added a sample program. Anyway to get that fixed or is there something I am doing wrong?
Sample program
def create_private_service_connection(network_id, stack_name): """ Creates a private service connection to allow VPC access to Google services (e.g., Cloud SQL).
Log output
Affected Resource(s)
No response
Output of
pulumi about
CLI
Version 3.118.0 Go Version go1.22.3 Go Compiler gc
Plugins KIND NAME VERSION resource cloudflare 5.35.1 resource gcp 7.38.0 resource google-native 0.32.0 resource kubernetes 4.15.0 resource kubernetes-cert-manager 0.0.6 language python unknown resource random 4.16.3
Host
OS darwin Version 14.5 Arch arm64
This project is written in python: executable='blabla/python3' version='3.12.2'
Backend
Name blabla URL gs://blabla User blabla Organizations
Token type personal
Dependencies: NAME VERSION google-cloud-functions 1.16.3 google-cloud-iam 2.15.0 google-cloud-logging 3.10.0 google-cloud-pubsub 2.21.5 google-cloud-storage 2.17.0 google-cloud-video-transcoder 1.12.3 pip 24.1.2 pulumi_cloudflare 5.35.1 pulumi_gcp 7.38.0 pulumi-google-native 0.32.0 pulumi_kubernetes_cert_manager 0.0.6 pulumi_random 4.16.3 setuptools 69.5.1 wheel 0.43.0
Additional context
My pulumi gcp version is 7.38.0
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).